@@ -1772,23 +1772,40 @@ func (kl *Kubelet) determinePodResizeStatus(allocatedPod *v1.Pod, podStatus *kub
1772
1772
func allocatedResourcesMatchStatus (allocatedPod * v1.Pod , podStatus * kubecontainer.PodStatus ) bool {
1773
1773
for _ , c := range allocatedPod .Spec .Containers {
1774
1774
if cs := podStatus .FindContainerStatusByName (c .Name ); cs != nil {
1775
- if cs .State != kubecontainer .ContainerStateRunning || cs . Resources == nil {
1775
+ if cs .State != kubecontainer .ContainerStateRunning {
1776
1776
// If the container isn't running, it isn't resizing.
1777
1777
continue
1778
1778
}
1779
1779
1780
+ cpuReq , hasCPUReq := c .Resources .Requests [v1 .ResourceCPU ]
1781
+ cpuLim , hasCPULim := c .Resources .Limits [v1 .ResourceCPU ]
1782
+ memLim , hasMemLim := c .Resources .Limits [v1 .ResourceMemory ]
1783
+
1784
+ if cs .Resources == nil {
1785
+ if hasCPUReq || hasCPULim || hasMemLim {
1786
+ // Container status is missing Resources information, but the container does
1787
+ // have resizable resources configured.
1788
+ klog .ErrorS (nil , "Missing runtime resources information for resizing container" ,
1789
+ "pod" , format .Pod (allocatedPod ), "container" , c .Name )
1790
+ return false // We don't want to clear resize status with insufficient information.
1791
+ } else {
1792
+ // No resizable resources configured; this might be ok.
1793
+ continue
1794
+ }
1795
+ }
1796
+
1780
1797
// Only compare resizeable resources, and only compare resources that are explicitly configured.
1781
- if cpuReq , present := c . Resources . Requests [ v1 . ResourceCPU ]; present {
1798
+ if hasCPUReq {
1782
1799
if ! cpuReq .Equal (* cs .Resources .CPURequest ) {
1783
1800
return false
1784
1801
}
1785
1802
}
1786
- if cpuLim , present := c . Resources . Limits [ v1 . ResourceCPU ]; present {
1803
+ if hasCPULim {
1787
1804
if ! cpuLim .Equal (* cs .Resources .CPULimit ) {
1788
1805
return false
1789
1806
}
1790
1807
}
1791
- if memLim , present := c . Resources . Limits [ v1 . ResourceMemory ]; present {
1808
+ if hasMemLim {
1792
1809
if ! memLim .Equal (* cs .Resources .MemoryLimit ) {
1793
1810
return false
1794
1811
}
0 commit comments