runsc: restore spec validation rejects restore when only Process.OOMScoreAdj differs (value is derived from node memory capacity)
Description
runsc restore spec validation treats a difference in Process.OOMScoreAdj between the checkpoint spec and the restore spec as a hard validation failure, aborting the restore.
On Kubernetes this field is not set by the workload author — the kubelet computes it from the node's memory capacity. For a Burstable pod, restoring a checkpoint onto a node whose memory capacity differs from the checkpoint node therefore yields a different oomScoreAdj in the restore spec, and the restore fails for a reason the user cannot set, predict or influence.
Expected: restore succeeds, or at most logs a warning — the same treatment already given to Linux.Resources, Hostname, Process.Env and Linux.CgroupsPath, which are explicitly allowed to change across checkpoint/restore.
Observed: restore aborts. Sanitized error:
failed to validate restore spec: failed to validate spec for container "<container-name>": "Process" does not match across checkpoint restore for container: "<container-name>", checkpoint specs.Process{..., OOMScoreAdj:(*int)(...), ...} restore specs.Process{..., OOMScoreAdj:(*int)(...), ...}Where it happens
All references are to master at commit d977b3ceb5562d3dbb5321861639ecd0e962645b.
runsc/specutils/restore.go already tolerates fields that legitimately differ across restore. Changes to Linux.Resources are downgraded to a warning (restore.go:444-448):
if err := validateResources("Resources", cName, oldLinux.Resources, newLinux.Resources); err != nil {
// 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)
}and several fields are zeroed before comparison (restore.go:463-471):
// Hostname, Domainname, Environment variables and CgroupsPath are
// allowed to change during restore. Hooks contain callbacks for
// lifecycle of the container such as prestart and teardown, and can
// change. Do not validate these fields.
oldSpec.Hostname, newSpec.Hostname = "", ""
oldSpec.Domainname, newSpec.Domainname = "", ""
oldProcess.Env, newProcess.Env = nil, nil
oldLinux.CgroupsPath, newLinux.CgroupsPath = "", ""
oldSpec.Hooks, newSpec.Hooks = nil, nilProcess.OOMScoreAdj (a *int in specs.Process) is never zeroed, so it survives into the catch-all comparison at restore.go:474-476, which returns a hard error:
// Validate remaining fields of specs.Process.
if ok := reflect.DeepEqual(oldProcess, newProcess); !ok {
return validateError("Process", cName, oldProcess, newProcess)
}reflect.DeepEqual dereferences pointers, so two different oomScoreAdj values are a mismatch and the restore is aborted by RestoreValidateSpec under the default policy.
Why the value changes, and why the user cannot control it
The kubelet derives the value from node memory capacity. In kubernetes/kubernetes, pkg/kubelet/qos/policy.go:47 — note the memoryCapacity int64 parameter:
func GetContainerOOMScoreAdjust(pod *v1.Pod, container *v1.Container, memoryCapacity int64) int {and for Burstable pods, pkg/kubelet/qos/policy.go:86:
oomScoreAdjust = 1000 - (1000*containerMemReq)/memoryCapacityFor Guaranteed (and node-critical) pods it returns a constant instead, pkg/kubelet/qos/policy.go:54-56:
case v1.PodQOSGuaranteed:
// Guaranteed containers should be the last to get killed.
return guaranteedOOMScoreAdjPodQOSBestEffort likewise returns the constant besteffortOOMScoreAdj. This is why the bug only manifests for Burstable pods: theirs is the only QoS class whose oomScoreAdj is a function of the node.
Consequently, a checkpoint taken on a node with memory capacity A and restored onto a node with memory capacity B (A != B) produces a different oomScoreAdj even though the pod spec, image, requests and limits are all byte-for-byte identical. In a heterogeneous or autoscaled node pool the restore node's size is not something the user chooses.
Steps to reproduce
- Use
runscwith checkpoint/restore and the default--restore-spec-validation=enforce. - Run a Burstable pod (at least one container with a memory request lower than its limit) on a node with memory capacity A.
- Checkpoint the sandbox.
- Restore it onto a node with memory capacity B, where B != A (e.g. a different machine type, or the same machine type with different allocatable/system-reserved).
- The restore fails with the
"Process" does not match across checkpoint restoreerror above. The only differing field in the twospecs.Processvalues isOOMScoreAdj.
The same spec restored onto a node with capacity A succeeds, which isolates the node's memory capacity as the sole variable.
No practical user-side workaround
--restore-spec-validationis registered inrunsc/config/flags.go:123:flagSet.Var(RestoreSpecValidationEnforce.Ptr(), "restore-spec-validation", "how to handle spec validation during restore.")i.e. it defaults to
enforce. The accepted values areignore,warningandenforce(runsc/config/config.go:1519-1531).The flag is not in
overrideAllowlist(runsc/config/flags.go:206-226), so a container author cannot relax it per pod via adev.gvisor.flag.*OCI annotation unless the node administrator has enabled--allow-flag-overridefor the whole runtime. Doing that node-wide would also weaken or disable validation of every other spec field, which defeats the purpose of the check.Making the pod Guaranteed (requests == limits on every container) pins
oomScoreAdjto the constant and does avoid the mismatch — but it is only a partial mitigation: it forces a change to the pod's resource and scheduling model purely to satisfy a validation check, and is not an option for workloads that legitimately need burstable headroom.
Precedent: CRIU treats this field as non-critical
In checkpoint-restore/criu, criu/cr-restore.c:632-634:
/* oom_score_adj is not critical: only log errors */
if (tc->has_oom_score_adj && tc->oom_score_adj != 0)
prepare_oom_score_adj(tc->oom_score_adj);The return value is deliberately ignored — CRIU does not fail a restore on oom_score_adj.
Suggested fix
Either of the following would resolve it, both consistent with how restore.go already handles fields that are permitted to change:
Zero the field before the catch-all comparison, alongside
Env/Hostname/CgroupsPath:oldProcess.OOMScoreAdj, newProcess.OOMScoreAdj = nil, nilOr compare it and downgrade a mismatch to a
log.Warningf, the wayLinux.Resourcesis handled atrestore.go:444-448.
OOMScoreAdj only influences host OOM-kill ordering; it has no bearing on whether the checkpoint image can be correctly restored.
Related issues
- #11248 — sysctl validation failing on restore (another case of restore spec validation being stricter than necessary).
- #11307 / #10673 — earlier reports about restoring a checkpoint with a changed OCI spec, which led to the
--restore-spec-validationflag.
This issue is not a duplicate of those: none of them covers Process.OOMScoreAdj, and the flag added by #11307 is not usable as a per-pod workaround here (see above).
Source: google/gvisor