Skip to content

Commit

Permalink
fix: fix nil pointer error
Browse files Browse the repository at this point in the history
Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z committed Aug 31, 2024
1 parent 7305791 commit d62a6c1
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions controllers/apps/v2beta1/update_emqx_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,21 @@ func (u *updateStatus) reconcile(ctx context.Context, logger logr.Logger, instan
}
}

isEnterpriser := false
for _, node := range coreNodes {
if node.ControllerUID == currentSts.UID && node.Edition == "Enterprise" {
isEnterpriser = true
break
if currentSts != nil {
isEnterpriser := false
for _, node := range coreNodes {
if node.ControllerUID == currentSts.UID && node.Edition == "Enterprise" {
isEnterpriser = true
break
}
}
}
if isEnterpriser {
nodeEvacuationsStatus, err := getNodeEvacuationStatusByAPI(r)
if err != nil {
u.EventRecorder.Event(instance, corev1.EventTypeWarning, "FailedToGetNodeEvacuationStatuses", err.Error())
if isEnterpriser {
nodeEvacuationsStatus, err := getNodeEvacuationStatusByAPI(r)
if err != nil {
u.EventRecorder.Event(instance, corev1.EventTypeWarning, "FailedToGetNodeEvacuationStatuses", err.Error())
}
instance.Status.NodeEvacuationsStatus = nodeEvacuationsStatus
}
instance.Status.NodeEvacuationsStatus = nodeEvacuationsStatus
}

// update status condition
Expand Down

0 comments on commit d62a6c1

Please sign in to comment.