@@ -338,7 +338,8 @@ tell whether the resize status includes the latest resize request.
338
338
As of Kubernetes v1.20, the CRI has included support for in-place resizing of containers via the
339
339
` UpdateContainerResources ` API, which is implemented by both containerd and CRI-O. Additionally, the
340
340
` ContainerStatus ` message includes a ` ContainerResources ` field, which reports the current resource
341
- configuration of the container.
341
+ configuration of the container. ` UpdateContainerResources ` should be idempotent, if called with the
342
+ same configuration multiple times.
342
343
343
344
Starting with Kubernetes v1.33, the contract on the ` UpdateContainerResources ` call will be updated
344
345
to specify that runtimes should not deliberately restart the container to adjust the resources. If a
@@ -427,7 +428,7 @@ being resized, it adds the new desired resources (i.e
427
428
Spec.Containers[ i] .Resources.Requests) to the sum.
428
429
429
430
* If new desired resources fit, Kubelet accepts the resize, updates
430
- the allocated resourcesa , and sets Status.Resize to
431
+ the allocated resources , and sets Status.Resize to
431
432
"InProgress". It then invokes the UpdateContainerResources CRI API to update
432
433
Container resource limits. Once all Containers are successfully updated, it
433
434
updates Status...Resources to reflect new resource values and unsets
@@ -710,6 +711,28 @@ intended.
710
711
711
712
The atomic resize requirement should be reevaluated prior to GA, and in the context of pod-level resources.
712
713
714
+ ### Edge-triggered Resizes
715
+
716
+ The resources specified by the Kubelet are not guaranteed to be the actual resources configured for
717
+ a pod or container. Examples include:
718
+ - Linux kernel enforced minimums for CPU shares & quota
719
+ - Systemd cgroup driver rounds CPU quota up to the nearest 10ms
720
+ - NRI plugins can change resource configuration
721
+
722
+ Therefore the Kubelet cannot reliably compare desired & actual resources to know whether to trigger
723
+ a resize (a level-triggered approach).
724
+
725
+ To accommodate this, the Kubelet stores a bit along with every resource in the allocated resource
726
+ checkpoint which tracks whether the resource has been successfully resized. For container resources,
727
+ this means the ` UpdateContainerResources ` request succeeded. This status bit is persisted in the
728
+ allocated resources checkpoint to avoid extra resize requests across Kubelet restarts. There is the
729
+ possibility that a poorly timed restart could lead to a resize request being repeated, so
730
+ ` UpdateContainerResources ` should be idempotent.
731
+
732
+ When a resize request succeeds, the pod will be marked for resync to read the latest resources. If
733
+ the actual configured resources do not match the desired resources, this will be reflected in the
734
+ pod status resources.
735
+
713
736
### Memory Limit Decreases
714
737
715
738
Setting the memory limit below current memory usage can cause problems. With cgroups v1 the change
0 commit comments