You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2023/01/11 11:04:52 UTC

[shardingsphere-on-cloud] branch main updated: refactor: remove unused status functions (#180)

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

zhaojinchao 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 b34a2f6  refactor: remove unused status functions (#180)
b34a2f6 is described below

commit b34a2f6dbfa2befb1daf6d2728d902b7b17d2527
Author: liyao <ma...@126.com>
AuthorDate: Wed Jan 11 19:04:46 2023 +0800

    refactor: remove unused status functions (#180)
    
    Signed-off-by: mlycore <ma...@126.com>
    
    Signed-off-by: mlycore <ma...@126.com>
---
 .../api/v1alpha1/proxy_status.go                   | 61 ----------------------
 .../pkg/controllers/proxy_controller.go            |  9 +---
 2 files changed, 1 insertion(+), 69 deletions(-)

diff --git a/shardingsphere-operator/api/v1alpha1/proxy_status.go b/shardingsphere-operator/api/v1alpha1/proxy_status.go
index 278e3cb..3064141 100644
--- a/shardingsphere-operator/api/v1alpha1/proxy_status.go
+++ b/shardingsphere-operator/api/v1alpha1/proxy_status.go
@@ -71,64 +71,3 @@ type Condition struct {
 	Status         v1.ConditionStatus `json:"status"`
 	LastUpdateTime metav1.Time        `json:"lastUpdateTime,omitempty"`
 }
-
-func (p *ShardingSphereProxy) SetInitialized() {
-	p.Status.Phase = StatusNotReady
-	p.Status.Conditions = append([]Condition{}, Condition{
-		Type:           ConditionInitialized,
-		Status:         v1.ConditionTrue,
-		LastUpdateTime: metav1.Now(),
-	})
-}
-
-func (p *ShardingSphereProxy) SetInitializationFailed() {
-	p.Status.Phase = StatusNotReady
-	p.Status.Conditions = append([]Condition{}, Condition{
-		Type:           ConditionInitialized,
-		Status:         v1.ConditionFalse,
-		LastUpdateTime: metav1.Now(),
-	})
-}
-
-func (p *ShardingSphereProxy) SetPodStarted(readyNodes int32) {
-	p.Status.Phase = StatusNotReady
-	p.Status.Conditions = append([]Condition{}, Condition{
-		Type:           ConditionStarted,
-		Status:         v1.ConditionTrue,
-		LastUpdateTime: metav1.Now(),
-	})
-	p.Status.ReadyNodes = readyNodes
-}
-
-func (p *ShardingSphereProxy) SetPodNotStarted(readyNodes int32) {
-	p.Status.Phase = StatusNotReady
-	p.Status.Conditions = append([]Condition{}, Condition{
-		Type:           ConditionStarted,
-		Status:         v1.ConditionFalse,
-		LastUpdateTime: metav1.Now(),
-	})
-	p.Status.ReadyNodes = readyNodes
-}
-
-func (p *ShardingSphereProxy) SetReady(readyNodes int32) {
-	p.Status.Phase = StatusReady
-	p.Status.Conditions = append([]Condition{}, Condition{
-		Type:           ConditionReady,
-		Status:         v1.ConditionTrue,
-		LastUpdateTime: metav1.Now(),
-	})
-	p.Status.ReadyNodes = readyNodes
-
-}
-
-func (p *ShardingSphereProxy) SetFailed() {
-	p.Status.Phase = StatusNotReady
-	p.Status.Conditions = append([]Condition{}, Condition{
-		Type:           ConditionUnknown,
-		Status:         v1.ConditionTrue,
-		LastUpdateTime: metav1.Now(),
-	})
-}
-func (p *ShardingSphereProxy) UpdateReadyNodes(readyNodes int32) {
-	p.Status.ReadyNodes = readyNodes
-}
diff --git a/shardingsphere-operator/pkg/controllers/proxy_controller.go b/shardingsphere-operator/pkg/controllers/proxy_controller.go
index 9df369a..ad5ab81 100644
--- a/shardingsphere-operator/pkg/controllers/proxy_controller.go
+++ b/shardingsphere-operator/pkg/controllers/proxy_controller.go
@@ -120,8 +120,6 @@ func (r *ProxyReconciler) reconcileDeployment(ctx context.Context, namespacedNam
 		} else {
 			exp := reconcile.NewDeployment(ssproxy)
 			if err := r.Create(ctx, exp); err != nil {
-				ssproxy.SetInitializationFailed()
-				_ = r.Status().Update(ctx, ssproxy)
 				return ctrl.Result{}, err
 			}
 		}
@@ -154,8 +152,6 @@ func (r *ProxyReconciler) reconcileHPA(ctx context.Context, namespacedName types
 			if ssproxy.Spec.AutomaticScaling != nil && ssproxy.Spec.AutomaticScaling.Enable {
 				exp := reconcile.NewHPA(ssproxy)
 				if err := r.Create(ctx, exp); err != nil {
-					ssproxy.SetInitializationFailed()
-					_ = r.Status().Update(ctx, ssproxy)
 					return ctrl.Result{}, err
 				}
 			}
@@ -191,12 +187,9 @@ func (r *ProxyReconciler) reconcileService(ctx context.Context, namespacedName t
 		} else {
 			exp := reconcile.NewService(ssproxy)
 			if err := r.Create(ctx, exp); err != nil {
-				ssproxy.SetInitializationFailed()
-				_ = r.Status().Update(ctx, ssproxy)
 				return ctrl.Result{}, err
 			}
-			ssproxy.SetInitialized()
-			return ctrl.Result{RequeueAfter: WaitingForReady}, nil
+			return ctrl.Result{}, nil
 		}
 	} else {
 		act := service.DeepCopy()