mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 20:42:26 +00:00
kubelet: improve allocated resources checkpointing
changed calls to set allocation from container level to pod level on status manager.
This commit is contained in:
parent
a499facee6
commit
8e872978e8
@ -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) {
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user