diff --git a/opensearch-operator/pkg/reconcilers/rollingRestart.go b/opensearch-operator/pkg/reconcilers/rollingRestart.go index b00088f1..d3f08cc1 100644 --- a/opensearch-operator/pkg/reconcilers/rollingRestart.go +++ b/opensearch-operator/pkg/reconcilers/rollingRestart.go @@ -14,7 +14,6 @@ import ( opsterv1 "opensearch.opster.io/api/v1" "opensearch.opster.io/opensearch-gateway/services" "opensearch.opster.io/pkg/builders" - "opensearch.opster.io/pkg/helpers" "opensearch.opster.io/pkg/reconcilers/util" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -67,28 +66,26 @@ func (r *RollingRestartReconciler) Reconcile() (ctrl.Result, error) { status := r.findStatus() var pendingUpdate bool - // Check that all data nodes are ready before doing work - // Also check if there are pending updates + // Check that all nodes are ready before doing work + // Also check if there are pending updates for all nodes. for _, nodePool := range r.instance.Spec.NodePools { - if helpers.ContainsString(nodePool.Roles, "data") { - sts := &appsv1.StatefulSet{} - if err := r.Get(r.ctx, types.NamespacedName{ - Name: builders.StsName(r.instance, &nodePool), - Namespace: r.instance.Namespace, - }, sts); err != nil { - return ctrl.Result{}, err - } - if sts.Status.ReadyReplicas != pointer.Int32Deref(sts.Spec.Replicas, 1) { - return ctrl.Result{ - Requeue: true, - RequeueAfter: 10 * time.Second, - }, nil - } - - if sts.Status.UpdateRevision != "" && - sts.Status.UpdatedReplicas != pointer.Int32Deref(sts.Spec.Replicas, 1) { - pendingUpdate = true - } + sts := &appsv1.StatefulSet{} + if err := r.Get(r.ctx, types.NamespacedName{ + Name: builders.StsName(r.instance, &nodePool), + Namespace: r.instance.Namespace, + }, sts); err != nil { + return ctrl.Result{}, err + } + if sts.Status.UpdateRevision != "" && + sts.Status.UpdatedReplicas != pointer.Int32Deref(sts.Spec.Replicas, 1) { + pendingUpdate = true + break + } + if sts.Status.ReadyReplicas != pointer.Int32Deref(sts.Spec.Replicas, 1) { + return ctrl.Result{ + Requeue: true, + RequeueAfter: 10 * time.Second, + }, nil } } @@ -126,18 +123,16 @@ func (r *RollingRestartReconciler) Reconcile() (ctrl.Result, error) { // Restart statefulset pod. Order is not important so we just pick the first we find for _, nodePool := range r.instance.Spec.NodePools { - if helpers.ContainsString(nodePool.Roles, "data") { - sts := &appsv1.StatefulSet{} - if err := r.Get(r.ctx, types.NamespacedName{ - Name: builders.StsName(r.instance, &nodePool), - Namespace: r.instance.Namespace, - }, sts); err != nil { - return ctrl.Result{}, err - } - if sts.Status.UpdateRevision != "" && - sts.Status.UpdatedReplicas != pointer.Int32Deref(sts.Spec.Replicas, 1) { - return r.restartStatefulSetPod(sts) - } + sts := &appsv1.StatefulSet{} + if err := r.Get(r.ctx, types.NamespacedName{ + Name: builders.StsName(r.instance, &nodePool), + Namespace: r.instance.Namespace, + }, sts); err != nil { + return ctrl.Result{}, err + } + if sts.Status.UpdateRevision != "" && + sts.Status.UpdatedReplicas != pointer.Int32Deref(sts.Spec.Replicas, 1) { + return r.restartStatefulSetPod(sts) } }