Skip to content

Commit 7cf3bb9

Browse files
authored
fix(vmip): fix vmip phase assignment for a vm in the terminating phase (#2048)
Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
1 parent 11d243a commit 7cf3bb9

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

images/virtualization-artifact/pkg/controller/vmip/internal/attached_handler.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ func (h *AttachedHandler) getAttachedVirtualMachine(ctx context.Context, vmip *v
125125
}
126126

127127
if attachedVM != nil {
128+
// A VM that is being deleted is not considered attached so the VMIP can be released and, if managed, removed (e.g. during cascade deletion).
129+
if !attachedVM.GetDeletionTimestamp().IsZero() && len(attachedVM.Status.VirtualMachinePods) == 0 {
130+
return nil, nil
131+
}
128132
if network.HasMainNetworkStatus(attachedVM.Status.Networks) {
129133
return attachedVM, nil
130134
}

images/virtualization-artifact/pkg/controller/vmip/internal/watcher/vm_watcher.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ func (w VirtualMachineWatcher) Watch(mgr manager.Manager, ctr controller.Control
7171
return true
7272
}
7373

74+
if len(oldVM.Status.VirtualMachinePods) != len(newVM.Status.VirtualMachinePods) {
75+
return true
76+
}
77+
7478
return false
7579
},
7680
},

0 commit comments

Comments
 (0)