Catch the deletion key before type assertion causes a panic
fixes:
@@ -1196,6 +1196,27 @@ func (c *VMIController) addVirtualMachineInstance(obj interface{}) {
func (c *VMIController) deleteVirtualMachineInstance(obj interface{}) {
c.lowerVMIExpectation(obj)
+
+ _, ok := obj.(*virtv1.VirtualMachineInstance)
+
+ // When a delete is dropped, the relist will notice a vmi in the store not
+ // in the list, leading to the insertion of a tombstone object which contains
+ // the deleted key/value. Note that this value might be stale.
+ if !ok {
+ tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
+ if !ok {
+ log.Log.Reason(fmt.Errorf("couldn't get object from tombstone %+v", obj)).Error("Failed to process delete notification")
+ return
+ }
+ _, ok = tombstone.Obj.(*virtv1.VirtualMachineInstance)
+ if !ok {
+ log.Log.Reason(fmt.Errorf("tombstone contained object that is not a vmi %#v", obj)).Error("Failed to process delete notification")
+ return
+ }
+ // The VMI object has been deleted
+ return
+ }
+
c.enqueueVirtualMachine(obj)
}
