Skip to content

Commit 8e87297

Browse files
committed
kubelet: improve allocated resources checkpointing
changed calls to set allocation from container level to pod level on status manager.
1 parent a499fac commit 8e87297

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

pkg/kubelet/kubelet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2922,7 +2922,7 @@ func (kl *Kubelet) handlePodResourcesResize(pod *v1.Pod, podStatus *kubecontaine
29222922
if fit {
29232923
// Update pod resource allocation checkpoint
29242924
if err := kl.statusManager.SetPodAllocation(pod); err != nil {
2925-
return nil, err
2925+
klog.ErrorS(err, "SetPodAllocation failed", "pod", klog.KObj(pod))
29262926
}
29272927
for i, container := range pod.Spec.Containers {
29282928
if !apiequality.Semantic.DeepEqual(container.Resources, allocatedPod.Spec.Containers[i].Resources) {

pkg/kubelet/status/status_manager.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,17 @@ func (m *manager) GetPodResizeStatus(podUID types.UID) v1.PodResizeStatus {
296296
func (m *manager) SetPodAllocation(pod *v1.Pod) error {
297297
m.podStatusesLock.RLock()
298298
defer m.podStatusesLock.RUnlock()
299+
300+
podUID := string(pod.UID)
301+
podAlloc := state.PodResourceAllocation{}
302+
podAlloc[podUID] = make(map[string]v1.ResourceRequirements)
303+
299304
for _, container := range pod.Spec.Containers {
300305
alloc := *container.Resources.DeepCopy()
301-
if err := m.state.SetContainerResourceAllocation(string(pod.UID), container.Name, alloc); err != nil {
302-
return err
303-
}
306+
podAlloc[podUID][container.Name] = alloc
304307
}
305-
return nil
308+
309+
return m.state.SetPodResourceAllocation(podUID, podAlloc)
306310
}
307311

308312
// SetPodResizeStatus checkpoints the last resizing decision for the pod.

0 commit comments

Comments
 (0)