@@ -132,7 +132,18 @@ func newNfdController(config *restclient.Config, nfdApiControllerOptions nfdApiC
132132 }
133133 },
134134 DeleteFunc : func (obj interface {}) {
135- nfr := obj .(* nfdv1alpha1.NodeFeature )
135+ // obj may be a DeletedFinalStateUnknown if the watch was missed
136+ if deletedFinalStateUnknown , ok := obj .(cache.DeletedFinalStateUnknown ); ok {
137+ klog .V (2 ).InfoS ("found stale NodeFeature object" , "object" , obj )
138+ obj = deletedFinalStateUnknown .Obj
139+ }
140+
141+ nfr , ok := obj .(* nfdv1alpha1.NodeFeature )
142+ if ! ok {
143+ klog .ErrorS (fmt .Errorf ("unexpected object type %T" , obj ), "cannot convert object to NodeFeature" )
144+ return
145+ }
146+
136147 klog .V (2 ).InfoS ("NodeFeature deleted" , "nodefeature" , klog .KObj (nfr ))
137148 c .updateOneNode ("NodeFeature" , nfr )
138149 if ! nfdApiControllerOptions .DisableNodeFeatureGroup {
@@ -179,7 +190,18 @@ func newNfdController(config *restclient.Config, nfdApiControllerOptions nfdApiC
179190 c .updateNodeFeatureGroup (nfg .Name )
180191 },
181192 DeleteFunc : func (obj interface {}) {
182- nfg := obj .(* nfdv1alpha1.NodeFeatureGroup )
193+ // obj may be a DeletedFinalStateUnknown if the watch was missed
194+ if deletedFinalStateUnknown , ok := obj .(cache.DeletedFinalStateUnknown ); ok {
195+ klog .V (2 ).InfoS ("found stale NodeFeatureGroup object" , "object" , obj )
196+ obj = deletedFinalStateUnknown .Obj
197+ }
198+
199+ nfg , ok := obj .(* nfdv1alpha1.NodeFeatureGroup )
200+ if ! ok {
201+ klog .ErrorS (fmt .Errorf ("unexpected object type %T" , obj ), "cannot convert object to NodeFeatureGroup" )
202+ return
203+ }
204+
183205 klog .V (2 ).InfoS ("NodeFeatureGroup deleted" , "nodeFeatureGroup" , klog .KObj (nfg ))
184206 c .updateNodeFeatureGroup (nfg .Name )
185207 },
0 commit comments