kubelet: improve allocated resources checkpointing

changed calls to set allocation from container level to pod level on status manager.
This commit is contained in:
Filipe Xavier 2025-01-07 09:20:36 -03:00
parent a499facee6
commit 8e872978e8
2 changed files with 9 additions and 5 deletions

View File

@ -2922,7 +2922,7 @@ func (kl *Kubelet) handlePodResourcesResize(pod *v1.Pod, podStatus *kubecontaine
if fit {
// Update pod resource allocation checkpoint
if err := kl.statusManager.SetPodAllocation(pod); err != nil {
return nil, err
klog.ErrorS(err, "SetPodAllocation failed", "pod", klog.KObj(pod))
}
for i, container := range pod.Spec.Containers {
if !apiequality.Semantic.DeepEqual(container.Resources, allocatedPod.Spec.Containers[i].Resources) {

View File

@ -296,13 +296,17 @@ func (m *manager) GetPodResizeStatus(podUID types.UID) v1.PodResizeStatus {
func (m *manager) SetPodAllocation(pod *v1.Pod) error {
m.podStatusesLock.RLock()
defer m.podStatusesLock.RUnlock()
podUID := string(pod.UID)
podAlloc := state.PodResourceAllocation{}
podAlloc[podUID] = make(map[string]v1.ResourceRequirements)
for _, container := range pod.Spec.Containers {
alloc := *container.Resources.DeepCopy()
if err := m.state.SetContainerResourceAllocation(string(pod.UID), container.Name, alloc); err != nil {
return err
}
podAlloc[podUID][container.Name] = alloc
}
return nil
return m.state.SetPodResourceAllocation(podUID, podAlloc)
}
// SetPodResizeStatus checkpoints the last resizing decision for the pod.