Skip to content

Commit

Permalink
Move up part that updates state to Running
Browse files Browse the repository at this point in the history
  • Loading branch information
SaaldjorMike committed Oct 21, 2024
1 parent 65f4045 commit 496ac2b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions controllers/humiocluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)))
Expand Down

0 comments on commit 496ac2b

Please sign in to comment.