diff --git a/controllers/humiocluster_controller.go b/controllers/humiocluster_controller.go index 9a26d4e78..a82b076b0 100644 --- a/controllers/humiocluster_controller.go +++ b/controllers/humiocluster_controller.go @@ -1844,6 +1844,17 @@ func (r *HumioClusterReconciler) ensureMismatchedPodsAreDeleted(ctx context.Cont } } + // when no more changes are needed, update state to Running + if hnp.GetState() != humiov1alpha1.HumioClusterStateRunning && + !podsStatus.waitingOnPods() && + !desiredLifecycleState.FoundConfigurationDifference() && + !desiredLifecycleState.FoundVersionDifference() { + r.Log.Info(fmt.Sprintf("updating cluster state as no difference was detected, updating from=%s to=%s", hnp.GetState(), humiov1alpha1.HumioClusterStateRunning)) + _, err := r.updateStatus(ctx, r.Client.Status(), hc, statusOptions(). + withNodePoolState(humiov1alpha1.HumioClusterStateRunning, hnp.GetNodePoolName(), hnp.GetDesiredPodRevision(), hnp.GetDesiredPodHash(), hnp.GetDesiredBootstrapTokenHash(), "")) + return reconcile.Result{Requeue: true}, err + } + // we expect an annotation for the bootstrap token to be present desiredBootstrapTokenHash, found := desiredPod.Annotations[BootstrapTokenHashAnnotation] if !found { @@ -1880,17 +1891,6 @@ func (r *HumioClusterReconciler) ensureMismatchedPodsAreDeleted(ctx context.Cont } } - // when no more changes are needed, update state to Running - if hnp.GetState() != humiov1alpha1.HumioClusterStateRunning && - !podsStatus.waitingOnPods() && - !desiredLifecycleState.FoundConfigurationDifference() && - !desiredLifecycleState.FoundVersionDifference() { - r.Log.Info(fmt.Sprintf("updating cluster state as no difference was detected, updating from=%s to=%s", hnp.GetState(), humiov1alpha1.HumioClusterStateRunning)) - _, err := r.updateStatus(ctx, r.Client.Status(), hc, statusOptions(). - withNodePoolState(humiov1alpha1.HumioClusterStateRunning, hnp.GetNodePoolName(), hnp.GetDesiredPodRevision(), hnp.GetDesiredPodHash(), hnp.GetDesiredBootstrapTokenHash(), "")) - return reconcile.Result{Requeue: true}, err - } - // delete evicted pods and pods attached using PVC's attached to worker nodes that no longer exists if podsStatus.foundEvictedPodsOrPodsWithOrpahanedPVCs() { r.Log.Info(fmt.Sprintf("found %d humio pods requiring deletion", len(podsStatus.podsEvictedOrUsesPVCAttachedToHostThatNoLongerExists)))