Skip to content

Commit

Permalink
Optimised isClusterReadinessEnabled flow
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekdwivedi3060 committed May 15, 2024
1 parent a05634d commit 06df89c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion controllers/poddistruptionbudget.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ func (r *SingleClusterReconciler) deletePDB() error {
}

func (r *SingleClusterReconciler) createOrUpdatePDB() error {
if !r.IsStatusEmpty() {
// Check for cluster readiness status only when it's false.
// Once enabled it won't be disabled.
if !r.IsStatusEmpty() && !r.aeroCluster.Status.IsClusterReadinessEnabled {
clusterReadinessEnabled, err := r.getClusterReadinessStatus()
if err != nil {
return fmt.Errorf("failed to get cluster readiness status: %v", err)
Expand Down
14 changes: 9 additions & 5 deletions controllers/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,16 @@ func (r *SingleClusterReconciler) updateStatus() error {
newAeroCluster.Status.AerospikeClusterStatusSpec = *specToStatus
newAeroCluster.Status.Phase = asdbv1.AerospikeClusterCompleted

clusterReadinessEnable, err := r.getClusterReadinessStatus()
if err != nil {
return fmt.Errorf("failed to get cluster readiness status: %v", err)
}
// If IsClusterReadinessEnabled is not enabled, then only check for cluster readiness.
// This is to avoid checking cluster readiness for every reconcile as once it is enabled, it will not be disabled.
if !newAeroCluster.Status.IsClusterReadinessEnabled {
clusterReadinessEnable, gErr := r.getClusterReadinessStatus()
if gErr != nil {
return fmt.Errorf("failed to get cluster readiness status: %v", gErr)
}

newAeroCluster.Status.IsClusterReadinessEnabled = clusterReadinessEnable
newAeroCluster.Status.IsClusterReadinessEnabled = clusterReadinessEnable
}

err = r.patchStatus(newAeroCluster)
if err != nil {
Expand Down

0 comments on commit 06df89c

Please sign in to comment.