Skip to content

Commit

Permalink
add validation for type assert
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-kun committed Dec 29, 2021
1 parent 37c4ccb commit 5548f1e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/util/provider/machinecontroller/machine_safety.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ func (c *controller) updateMachineToSafety(oldObj, newObj interface{}) {
oldMachine := oldObj.(*v1alpha1.Machine)
newMachine := newObj.(*v1alpha1.Machine)

if oldMachine == nil || newMachine == nil {
klog.Errorf("Couldn't convert to machine resource from object")
return
}

if !strings.Contains(oldMachine.Status.LastOperation.Description, codes.OutOfRange.String()) && strings.Contains(newMachine.Status.LastOperation.Description, codes.OutOfRange.String()) {
klog.Warningf("Multiple VMs backing machine obj %q found, triggering orphan collection.", newMachine.Name)
c.enqueueMachineSafetyOrphanVMsKey(newMachine)
Expand All @@ -322,6 +327,10 @@ func (c *controller) updateMachineToSafety(oldObj, newObj interface{}) {
// deleteMachineToSafety enqueues into machineSafetyQueue when a new machine is deleted
func (c *controller) deleteMachineToSafety(obj interface{}) {
machine := obj.(*v1alpha1.Machine)
if machine == nil {
klog.Errorf("Couldn't convert to machine resource from object")
return
}
c.enqueueMachineSafetyOrphanVMsKey(machine)
}

Expand Down

0 comments on commit 5548f1e

Please sign in to comment.