Ensure when pod-level memory is modified, skip cgroup writes, but ensure actuated pod-level resources are updated

This commit is contained in:
ndixita
2026-03-19 06:34:10 +00:00
parent 991f2d727a
commit ecb1f49627

View File

@@ -925,7 +925,6 @@ func (m *kubeGenericRuntimeManager) doPodResizeAction(ctx context.Context, pod *
}
case v1.ResourceMemory:
if !setLimitValue {
// Memory requests aren't written to cgroups.
return nil
}
resizedResources.Memory = podResources.Memory
@@ -951,11 +950,6 @@ func (m *kubeGenericRuntimeManager) doPodResizeAction(ctx context.Context, pod *
// Update our tracking of the current state.
currentPodResources = mergedPodResources
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodLevelResourcesVerticalScaling) {
if err = updateActuatedPodLevelResources(rName); err != nil {
logger.Error(err, "Failed to update pod-level actuated resources", "resource", rName, "pod", klog.KObj(pod))
}
}
return nil
}
@@ -984,6 +978,7 @@ func (m *kubeGenericRuntimeManager) doPodResizeAction(ctx context.Context, pod *
return err
}
}
// At downsizing, requests should shrink prior to limits in order to keep "requests <= limits".
if newPodCgReqValue < currPodCgReqValue {
// TODO: Pass logger from context once contextual logging migration is complete
@@ -997,6 +992,12 @@ func (m *kubeGenericRuntimeManager) doPodResizeAction(ctx context.Context, pod *
return err
}
}
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodLevelResourcesVerticalScaling) && podContainerChanges.UpdatePodLevelResources {
if err = updateActuatedPodLevelResources(rName); err != nil {
logger.Error(err, "Failed to update pod-level actuated resources", "resource", rName, "pod", klog.KObj(pod))
}
}
return err
}