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

duanzhengqiang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shardingsphere-on-cloud.git


The following commit(s) were added to refs/heads/main by this push:
     new 6f8de7d  fix(Reconcile): fix create HPA logic
     new de8ee1b  Merge pull request #47 from windghoul/Hpafix
6f8de7d is described below

commit 6f8de7d531cc9d056062337f636605e358134a6d
Author: windghoul <[email protected]>
AuthorDate: Wed Aug 24 19:05:53 2022 +0800

    fix(Reconcile): fix create HPA logic
    
    Signed-off-by: windghoul <[email protected]>
---
 charts/shardingsphere-operator/values.yaml         |  4 +-
 shardingsphere-operator/build/Dockerfile           |  2 +-
 .../pkg/controllers/proxy_controller.go            | 47 ++++++++++++----------
 3 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/charts/shardingsphere-operator/values.yaml 
b/charts/shardingsphere-operator/values.yaml
index 4eb19fe..23f54ad 100644
--- a/charts/shardingsphere-operator/values.yaml
+++ b/charts/shardingsphere-operator/values.yaml
@@ -22,13 +22,13 @@ replicaCount: 2
 image:
   ## @param image.repository operator image name
   ##
-  repository: "ghcr.io/sphereex/shardingsphere-on-cloud"
+  repository: "ghcr.io/apache/shardingsphere-on-cloud"
   ## @param image.pullPolicy image pull policy
   ##
   pullPolicy: IfNotPresent
   ## @param image.tag image tag
   ##
-  tag: "v0.1.0"
+  tag: "main"
 ## @param imagePullSecrets image pull secret of private repository
 ## e.g:
 ## imagePullSecrets:
diff --git a/shardingsphere-operator/build/Dockerfile 
b/shardingsphere-operator/build/Dockerfile
index 78c2ffa..e21a1c4 100644
--- a/shardingsphere-operator/build/Dockerfile
+++ b/shardingsphere-operator/build/Dockerfile
@@ -25,7 +25,7 @@ COPY shardingsphere-operator/go.mod go.mod
 COPY shardingsphere-operator/go.sum go.sum
 # cache deps before building and copying source so that we don't need to 
re-download as much
 # and so that source changes don't invalidate our downloaded layer
-#ENV GOPROXY=https://proxy.golang.com.cn
+#ENV GOPROXY=https://goproxy.cn
 RUN go mod download
 
 # Copy the go source
diff --git a/shardingsphere-operator/pkg/controllers/proxy_controller.go 
b/shardingsphere-operator/pkg/controllers/proxy_controller.go
index 251af23..93ae6dd 100644
--- a/shardingsphere-operator/pkg/controllers/proxy_controller.go
+++ b/shardingsphere-operator/pkg/controllers/proxy_controller.go
@@ -101,36 +101,39 @@ func (r *ProxyReconciler) Reconcile(ctx context.Context, 
req ctrl.Request) (ctrl
                log.Error(err, "Error getting cascaded HPA")
                return ctrl.Result{}, err
        }
-       if apierrors.IsNotFound(err) && run.Spec.AutomaticScaling != nil {
-               cascadingHPA := reconcile.ConstructHPA(run)
-               err = r.Create(ctx, cascadingHPA)
-               if err != nil {
-                       run.SetInitializationFailed()
-                       _ = r.Status().Update(ctx, run)
-                       log.Error(err, "Error creating cascaded HPA")
-                       return ctrl.Result{}, err
-               }
-
-       } else if run.Spec.AutomaticScaling == nil {
-               err = r.Delete(ctx, runtimeHPA)
-               if err != nil {
-                       log.Error(err, "Error delete cascaded HPA")
-                       return ctrl.Result{}, err
+       if apierrors.IsNotFound(err) {
+               if run.Spec.AutomaticScaling != nil {
+                       cascadingHPA := reconcile.ConstructHPA(run)
+                       err = r.Create(ctx, cascadingHPA)
+                       if err != nil {
+                               run.SetInitializationFailed()
+                               _ = r.Status().Update(ctx, run)
+                               log.Error(err, "Error creating cascaded HPA")
+                               return ctrl.Result{}, err
+                       }
                }
        } else {
-               originHPA := runtimeHPA.DeepCopy()
-               reconcile.UpdateHPA(run, originHPA)
-               err = r.Update(ctx, originHPA)
-               if err != nil {
-                       log.Error(err, "Error updating cascaded HPA")
-                       return ctrl.Result{}, err
+               if run.Spec.AutomaticScaling == nil {
+                       err = r.Delete(ctx, runtimeHPA)
+                       if err != nil {
+                               log.Error(err, "Error delete cascaded HPA")
+                               return ctrl.Result{}, err
+                       }
+               } else {
+                       originHPA := runtimeHPA.DeepCopy()
+                       reconcile.UpdateHPA(run, originHPA)
+                       err = r.Update(ctx, originHPA)
+                       if err != nil {
+                               log.Error(err, "Error updating cascaded HPA")
+                               return ctrl.Result{}, err
+                       }
                }
        }
 
        runtimeService := &v1.Service{}
        err = r.Get(ctx, req.NamespacedName, runtimeService)
        if err != nil && !apierrors.IsNotFound(err) {
-               log.Error(err, "Error getting cascaded HPA")
+               log.Error(err, "Error getting cascaded Service")
                return ctrl.Result{}, err
        }
        if apierrors.IsNotFound(err) {

Reply via email to