Fix slice append error

In golang when copy a slice, if the slice is initialized with a
desired length, then appending to it will cause the size double.

Signed-off-by: bin liu <liubin0329@gmail.com>
This commit is contained in:
bin liu
2022-11-12 00:09:31 +08:00
parent 0f401197c8
commit 0c63c42f81
2 changed files with 2 additions and 2 deletions

View File

@@ -219,7 +219,7 @@ func deepCopyOf(s Status) Status {
}
copy.Resources = &runtime.ContainerResources{}
if s.Resources != nil && s.Resources.Linux != nil {
hugepageLimits := make([]*runtime.HugepageLimit, len(s.Resources.Linux.HugepageLimits))
hugepageLimits := make([]*runtime.HugepageLimit, 0)
for _, l := range s.Resources.Linux.HugepageLimits {
hugepageLimits = append(hugepageLimits, &runtime.HugepageLimit{
PageSize: l.PageSize,