Skip to content

Commit

Permalink
Move up node pool status cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SaaldjorMike committed Oct 22, 2024
1 parent ca9dcb0 commit f4554cd
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions controllers/humiocluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ func (r *HumioClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request
withNodeCount(len(podStatusList)))
}(ctx, hc)

// remove unused node pool status entries
if ok, idx := r.hasNoUnusedNodePoolStatus(hc, &humioNodePools); !ok {
r.cleanupUnusedNodePoolStatus(hc, idx)
if result, err := r.updateStatus(ctx, r.Client.Status(), hc, statusOptions().
withNodePoolStatusList(hc.Status.NodePoolStatus)); err != nil {
return result, r.logErrorAndReturn(err, "unable to set cluster state")
}
}

// ensure pods that does not run the desired version or config gets deleted and update state accordingly
for _, pool := range humioNodePools.Items {
if r.nodePoolAllowsMaintenanceOperations(hc, pool, humioNodePools.Items) {
Expand Down Expand Up @@ -2264,14 +2273,6 @@ func (r *HumioClusterReconciler) cleanupUnusedResources(ctx context.Context, hc
withMessage(err.Error()))
}
}

if ok, idx := r.hasNoUnusedNodePoolStatus(hc, &humioNodePools); !ok {
r.cleanupUnusedNodePoolStatus(hc, idx)
if result, err := r.updateStatus(ctx, r.Client.Status(), hc, statusOptions().
withNodePoolStatusList(hc.Status.NodePoolStatus)); err != nil {
return result, r.logErrorAndReturn(err, "unable to set cluster state")
}
}
return reconcile.Result{}, nil
}

Expand Down

0 comments on commit f4554cd

Please sign in to comment.