Skip to content

Commit

Permalink
checking if NHC is a remediation owner before assuming it was created…
Browse files Browse the repository at this point in the history
… by MHC

Signed-off-by: Michael Shitrit <[email protected]>
  • Loading branch information
mshitrit committed Nov 28, 2023
1 parent e80b04d commit b201de9
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions controllers/selfnoderemediation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,13 +644,14 @@ func (r *SelfNodeRemediationReconciler) getNodeFromSnr(snr *v1alpha1.SelfNodeRem
//SNR could be created by either machine based controller (e.g. MHC) or
//by a node based controller (e.g. NHC). This assumes that machine based controller
//will create the snr with machine owner reference

for _, ownerRef := range snr.OwnerReferences {
if ownerRef.Kind == "Machine" {
r.mutex.Lock()
wasLastSeenSnrMachine = true
r.mutex.Unlock()
return r.getNodeFromMachine(ownerRef, snr.Namespace)
if !r.isOwnedByNHC(snr) {
for _, ownerRef := range snr.OwnerReferences {
if ownerRef.Kind == "Machine" {
r.mutex.Lock()
wasLastSeenSnrMachine = true
r.mutex.Unlock()
return r.getNodeFromMachine(ownerRef, snr.Namespace)
}
}
}

Expand Down Expand Up @@ -927,3 +928,12 @@ func (r *SelfNodeRemediationReconciler) getRuntimeStrategy(strategy v1alpha1.Rem
return v1alpha1.ResourceDeletionRemediationStrategy

}

func (r *SelfNodeRemediationReconciler) isOwnedByNHC(snr *v1alpha1.SelfNodeRemediation) bool {
for _, ownerRef := range snr.OwnerReferences {
if ownerRef.Kind == "NodeHealthCheck" {
return true
}
}
return false
}

0 comments on commit b201de9

Please sign in to comment.