@@ -72,9 +72,10 @@ type manager struct {
72
72
kubeClient clientset.Interface
73
73
podManager PodManager
74
74
// Map from pod UID to sync status of the corresponding pod.
75
- podStatuses map [types.UID ]versionedPodStatus
76
- podStatusesLock sync.RWMutex
77
- podStatusChannel chan struct {}
75
+ podStatuses map [types.UID ]versionedPodStatus
76
+ podResizeStatuses map [types.UID ]v1.PodResizeStatus
77
+ podStatusesLock sync.RWMutex
78
+ podStatusChannel chan struct {}
78
79
// Map from (mirror) pod UID to latest status version successfully sent to the API server.
79
80
// apiStatusVersions must only be accessed from the sync thread.
80
81
apiStatusVersions map [kubetypes.MirrorPodUID ]uint64
@@ -174,6 +175,7 @@ func NewManager(kubeClient clientset.Interface, podManager PodManager, podDeleti
174
175
kubeClient : kubeClient ,
175
176
podManager : podManager ,
176
177
podStatuses : make (map [types.UID ]versionedPodStatus ),
178
+ podResizeStatuses : make (map [types.UID ]v1.PodResizeStatus ),
177
179
podStatusChannel : make (chan struct {}, 1 ),
178
180
apiStatusVersions : make (map [kubetypes.MirrorPodUID ]uint64 ),
179
181
podDeletionSafety : podDeletionSafety ,
@@ -303,7 +305,7 @@ func updatePodFromAllocation(pod *v1.Pod, allocs state.PodResourceAllocation) (*
303
305
func (m * manager ) GetPodResizeStatus (podUID types.UID ) v1.PodResizeStatus {
304
306
m .podStatusesLock .RLock ()
305
307
defer m .podStatusesLock .RUnlock ()
306
- return m .state . GetPodResizeStatus ( string ( podUID ))
308
+ return m .podResizeStatuses [ podUID ]
307
309
}
308
310
309
311
// SetPodAllocation checkpoints the resources allocated to a pod's containers
@@ -331,9 +333,9 @@ func (m *manager) SetPodAllocation(pod *v1.Pod) error {
331
333
332
334
// SetPodResizeStatus checkpoints the last resizing decision for the pod.
333
335
func (m * manager ) SetPodResizeStatus (podUID types.UID , resizeStatus v1.PodResizeStatus ) {
334
- m .podStatusesLock .RLock ()
335
- defer m .podStatusesLock .RUnlock ()
336
- m .state . SetPodResizeStatus ( string ( podUID ), resizeStatus )
336
+ m .podStatusesLock .Lock ()
337
+ defer m .podStatusesLock .Unlock ()
338
+ m .podResizeStatuses [ podUID ] = resizeStatus
337
339
}
338
340
339
341
func (m * manager ) GetPodStatus (uid types.UID ) (v1.PodStatus , bool ) {
@@ -803,6 +805,7 @@ func (m *manager) deletePodStatus(uid types.UID) {
803
805
delete (m .podStatuses , uid )
804
806
m .podStartupLatencyHelper .DeletePodStartupState (uid )
805
807
if utilfeature .DefaultFeatureGate .Enabled (features .InPlacePodVerticalScaling ) {
808
+ delete (m .podResizeStatuses , uid )
806
809
m .state .Delete (string (uid ), "" )
807
810
}
808
811
}
@@ -816,6 +819,7 @@ func (m *manager) RemoveOrphanedStatuses(podUIDs map[types.UID]bool) {
816
819
klog .V (5 ).InfoS ("Removing pod from status map." , "podUID" , key )
817
820
delete (m .podStatuses , key )
818
821
if utilfeature .DefaultFeatureGate .Enabled (features .InPlacePodVerticalScaling ) {
822
+ delete (m .podResizeStatuses , key )
819
823
m .state .Delete (string (key ), "" )
820
824
}
821
825
}
0 commit comments