You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by vo...@apache.org on 2019/09/04 07:31:52 UTC

[rocketmq-operator] 20/28: add meta service check size controller logis

This is an automated email from the ASF dual-hosted git repository.

vongosling pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-operator.git

commit cdf841b700482fcc69b6317e7ac0acf684131614
Author: liuruiyiyang <24...@qq.com>
AuthorDate: Tue Sep 3 10:19:18 2019 +0800

    add meta service check size controller logis
---
 pkg/controller/metaservice/metaservice_controller.go | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/pkg/controller/metaservice/metaservice_controller.go b/pkg/controller/metaservice/metaservice_controller.go
index ba4aca7..7b4f268 100644
--- a/pkg/controller/metaservice/metaservice_controller.go
+++ b/pkg/controller/metaservice/metaservice_controller.go
@@ -117,6 +117,19 @@ func (r *ReconcileMetaService) Reconcile(request reconcile.Request) (reconcile.R
 		reqLogger.Error(err, "Failed to get MetaService Deployment.")
 	}
 
+	// Ensure the deployment size is the same as the spec
+	size := instance.Spec.Size
+	if *found.Spec.Replicas != size {
+		found.Spec.Replicas = &size
+		err = r.client.Update(context.TODO(), found)
+		if err != nil {
+			reqLogger.Error(err, "Failed to update Deployment.", "Deployment.Namespace", found.Namespace, "Deployment.Name", found.Name)
+			return reconcile.Result{}, err
+		}
+		// Spec updated - return and requeue
+		return reconcile.Result{Requeue: true}, nil
+	}
+
 	// Update the status with the pod names
 	// List the pods for this broker's deployment
 	podList := &corev1.PodList{}