Skip to content

Commit

Permalink
Set roster before quiescing next node (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
sud82 authored Jan 13, 2023
1 parent f8dbcda commit 3f5e1f3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
14 changes: 11 additions & 3 deletions controllers/aero_info_calls.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
// The ignorablePods list should be a list of failed or pending pods that are going to be
// deleted eventually and are safe to ignore in stability checks.
func (r *SingleClusterReconciler) waitForMultipleNodesSafeStopReady(
pods []*corev1.Pod, ignorablePods []corev1.Pod,
pods []*corev1.Pod, ignorablePods []corev1.Pod, setRoster bool,
) reconcileResult {
if len(pods) == 0 {
return reconcileSuccess()
Expand All @@ -60,8 +60,16 @@ func (r *SingleClusterReconciler) waitForMultipleNodesSafeStopReady(
return res
}

if err := r.validateSCClusterState(policy, ignorablePods); err != nil {
return reconcileError(err)
if setRoster {
// Setup roster after migration.
if err = r.getAndSetRoster(policy, r.aeroCluster.Spec.RosterNodeBlockList, ignorablePods); err != nil {
r.Log.Error(err, "Failed to set roster for cluster")
return reconcileRequeueAfter(1)
}
} else {
if err := r.validateSCClusterState(policy, ignorablePods); err != nil {
return reconcileError(err)
}
}

if err := r.quiescePods(policy, allHostConns, pods); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions controllers/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (r *SingleClusterReconciler) rollingRestartPods(

if len(activePods) != 0 {
r.Log.Info("Restart active pods", "pods", getPodNames(activePods))
if res := r.waitForMultipleNodesSafeStopReady(activePods, ignorablePods); !res.isSuccess {
if res := r.waitForMultipleNodesSafeStopReady(activePods, ignorablePods, false); !res.isSuccess {
return res
}
if res := r.restartPods(rackState, activePods, restartTypeMap); !res.isSuccess {
Expand Down Expand Up @@ -333,7 +333,7 @@ func (r *SingleClusterReconciler) safelyDeletePodsAndEnsureImageUpdated(

if len(activePods) != 0 {
r.Log.Info("Restart active pods with updated container image", "pods", getPodNames(activePods))
if res := r.waitForMultipleNodesSafeStopReady(activePods, ignorablePods); !res.isSuccess {
if res := r.waitForMultipleNodesSafeStopReady(activePods, ignorablePods, false); !res.isSuccess {
return res
}
if res := r.deletePodAndEnsureImageUpdated(rackState, activePods); !res.isSuccess {
Expand Down
8 changes: 1 addition & 7 deletions controllers/rack.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,16 +621,10 @@ func (r *SingleClusterReconciler) scaleDownRack(

// Ignore safe stop check on pod not in running state.
if utils.IsPodRunningAndReady(pod) {
if res := r.waitForMultipleNodesSafeStopReady([]*corev1.Pod{pod}, ignorablePods); !res.isSuccess {
if res := r.waitForMultipleNodesSafeStopReady([]*corev1.Pod{pod}, ignorablePods, true); !res.isSuccess {
// The pod is running and is unsafe to terminate.
return found, res
}

// Setup roster after migration.
if err = r.getAndSetRoster(policy, r.aeroCluster.Spec.RosterNodeBlockList, ignorablePods); err != nil {
r.Log.Error(err, "Failed to set roster for cluster")
return found, reconcileRequeueAfter(1)
}
}

// set migrate-fill-delay to 0 across all nodes of cluster to scale down fast
Expand Down
6 changes: 4 additions & 2 deletions controllers/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ func (r *SingleClusterReconciler) Reconcile() (ctrl.Result, error) {
}

if asdbv1beta1.IsClusterSCEnabled(r.aeroCluster) {
if res := r.waitForClusterStability(policy, allHostConns); !res.isSuccess {
return res.result, res.err
if r.aeroCluster.Status.AerospikeConfig != nil {
if res := r.waitForClusterStability(policy, allHostConns); !res.isSuccess {
return res.result, res.err
}
}

// Setup roster
Expand Down

0 comments on commit 3f5e1f3

Please sign in to comment.