Skip to content

Commit

Permalink
Do not validate resources during restore.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 706820039
  • Loading branch information
nybidari authored and gvisor-bot committed Dec 16, 2024
1 parent 3f058a8 commit 0f8216c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions runsc/boot/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func validateResources(field, cName string, oldR, newR *specs.LinuxResources) er
before := *oldR
after := *newR
if err := validateArray(field+".HugepageLimits", cName, before.HugepageLimits, after.HugepageLimits); err != nil {
return validateError(field, cName, oldR, newR)
return validateError(field+".HugepageLimits", cName, oldR, newR)
}
before.HugepageLimits, after.HugepageLimits = nil, nil

Expand All @@ -369,6 +369,15 @@ func validateResources(field, cName string, oldR, newR *specs.LinuxResources) er
// to nil as there is no need to validate each device.
before.Devices, after.Devices = nil, nil

if err := validateMap(field+".Rdma", cName, before.Rdma, after.Rdma); err != nil {
return err
}
before.Rdma, after.Rdma = nil, nil
if err := validateMap(field+".Unified", cName, before.Unified, after.Unified); err != nil {
return err
}
before.Unified, after.Unified = nil, nil

if !reflect.DeepEqual(before, after) {
return validateError(field, cName, oldR, newR)
}
Expand Down Expand Up @@ -476,7 +485,9 @@ func validateSpecForContainer(oSpec, nSpec *specs.Spec, cName string) error {
}
oldLinux.Devices, newLinux.Devices = nil, nil
if err := validateResources("Resources", cName, oldLinux.Resources, newLinux.Resources); err != nil {
return err
// Resource limits can be changed during restore, log a warning and do not
// return error.
log.Warningf("specs.Linux.Resources has been changed during restore, err %v", err)
}
oldLinux.Resources, newLinux.Resources = nil, nil
if err := validateArray("UIDMappings", cName, oldLinux.UIDMappings, newLinux.UIDMappings); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion runsc/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3852,7 +3852,7 @@ func TestSpecValidation(t *testing.T) {
},
}
},
wantErr: "Resources does not match across checkpoint restore",
wantErr: "",
},
}
for _, test := range tests {
Expand Down

0 comments on commit 0f8216c

Please sign in to comment.