Skip to content

Commit

Permalink
fix: fix nil point error
Browse files Browse the repository at this point in the history
When the EMQX resource is in `coreNodesProgressing/replicantNodesProgressing` state, if the user manually deletes `currentSts/currentRs`, it will cause a nil point error.

Signed-off-by: Rory Z <16801068+Rory-Z@users.noreply.github.com>
  • Loading branch information
Rory-Z committed Jan 25, 2024
1 parent 14e0ed9 commit 5cbe8df
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions controllers/apps/v2beta1/update_emqx_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func (u *updateStatus) reconcile(ctx context.Context, logger logr.Logger, instan
}

updateSts, currentSts, oldStsList := getStateFulSetList(ctx, u.Client, instance)
if updateSts != nil && updateSts.UID != currentSts.UID {
if currentSts.Status.Replicas == 0 {
if updateSts != nil {
if currentSts == nil || (updateSts.UID != currentSts.UID && currentSts.Status.Replicas == 0) {
var i int
for i = 0; i < len(oldStsList); i++ {
if oldStsList[i].Status.Replicas > 0 {
Expand All @@ -55,8 +55,8 @@ func (u *updateStatus) reconcile(ctx context.Context, logger logr.Logger, instan
}

updateRs, currentRs, oldRsList := getReplicaSetList(ctx, u.Client, instance)
if updateRs != nil && updateRs.UID != currentRs.UID {
if currentRs.Status.Replicas == 0 {
if updateRs != nil {
if currentRs == nil || (updateRs.UID != currentRs.UID && currentRs.Status.Replicas == 0) {
var i int
for i = 0; i < len(oldRsList); i++ {
if oldRsList[i].Status.Replicas > 0 {
Expand Down

0 comments on commit 5cbe8df

Please sign in to comment.