File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -110,20 +110,30 @@ func (s *Scheduler) onUpdatePod(_, newObj any) {
110110}
111111
112112func (s * Scheduler ) onDelPod (obj any ) {
113- pod , ok := obj .(* corev1.Pod )
114- if ! ok {
115- klog .Errorf ("unknown add object type" )
116- return
117- }
118- _ , ok = pod .Annotations [util .AssignedNodeAnnotations ]
119- if ! ok {
113+ var pod * corev1.Pod
114+ switch t := obj .(type ) {
115+ case * corev1.Pod :
116+ pod = t
117+ case cache.DeletedFinalStateUnknown :
118+ // Handle tombstone objects to avoid missing deletes on relist/reconnect
119+ if p , ok := t .Obj .(* corev1.Pod ); ok {
120+ pod = p
121+ } else {
122+ klog .Errorf ("tombstone contained object that is not a Pod: %#v" , t .Obj )
123+ return
124+ }
125+ default :
126+ klog .Errorf ("unknown delete object type: %#v" , obj )
120127 return
121128 }
122129 s .delPod (pod )
123130
124131 // release node lock if this pod owned one on a best-effort basis.
125132 // this is safe because ReleaseNodeLock checks the lock owner and no-ops if different.
126- nodeName := pod .Annotations [util .AssignedNodeAnnotations ]
133+ nodeName := ""
134+ if pod .Annotations != nil {
135+ nodeName = pod .Annotations [util .AssignedNodeAnnotations ]
136+ }
127137 if nodeName == "" {
128138 return
129139 }
You can’t perform that action at this time.
0 commit comments