From 3adc0f440d6fb0e7e628a4500197f4864eb40f46 Mon Sep 17 00:00:00 2001 From: 1996wentaozhang <64585711+1996wentaozhang@users.noreply.github.com> Date: Thu, 6 Jun 2024 14:42:07 +0800 Subject: [PATCH] feat: add new cluster phase ClusterRecovering (#2320) Co-authored-by: wtaozzhang --- api/platform/types.go | 2 ++ api/platform/v1/types.go | 2 ++ pkg/platform/controller/cluster/cluster_controller.go | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/api/platform/types.go b/api/platform/types.go index 568dcf1ba..12a41cd33 100644 --- a/api/platform/types.go +++ b/api/platform/types.go @@ -330,6 +330,8 @@ const ( ClusterUpscaling ClusterPhase = "Upscaling" // ClusterDownscaling means the cluster is undergoing graceful down scaling. ClusterDownscaling ClusterPhase = "Downscaling" + // ClusterRecovering means the cluster is recovering form confined. + ClusterRecovering ClusterPhase = "Recovering" ) // ComponentPhase defines the phase of anywhere cluster component diff --git a/api/platform/v1/types.go b/api/platform/v1/types.go index 8effd575d..5d52fae2c 100644 --- a/api/platform/v1/types.go +++ b/api/platform/v1/types.go @@ -345,6 +345,8 @@ const ( ClusterUpscaling ClusterPhase = "Upscaling" // ClusterDownscaling means the cluster is undergoing graceful down scaling. ClusterDownscaling ClusterPhase = "Downscaling" + // ClusterRecovering means the cluster is recovering form confined. + ClusterRecovering ClusterPhase = "Recovering" ) // ComponentPhase defines the phase of anywhere cluster component diff --git a/pkg/platform/controller/cluster/cluster_controller.go b/pkg/platform/controller/cluster/cluster_controller.go index 7f7095ebe..3ad6a50e6 100644 --- a/pkg/platform/controller/cluster/cluster_controller.go +++ b/pkg/platform/controller/cluster/cluster_controller.go @@ -358,7 +358,7 @@ func (c *Controller) reconcile(ctx context.Context, key string, cluster *platfor err = c.onUpdate(ctx, cluster) case platformv1.ClusterUpscaling, platformv1.ClusterDownscaling: err = c.onUpdate(ctx, cluster) - case platformv1.ClusterIdling, platformv1.ClusterConfined: + case platformv1.ClusterIdling, platformv1.ClusterConfined, platformv1.ClusterRecovering: err = c.onUpdate(ctx, cluster) case platformv1.ClusterTerminating: log.FromContext(ctx).Info("Cluster has been terminated. Attempting to cleanup resources") @@ -444,7 +444,8 @@ func (c *Controller) onUpdate(ctx context.Context, cluster *platformv1.Cluster) if clusterWrapper.Status.Phase == platformv1.ClusterRunning || clusterWrapper.Status.Phase == platformv1.ClusterFailed || clusterWrapper.Status.Phase == platformv1.ClusterIdling || - clusterWrapper.Status.Phase == platformv1.ClusterConfined { + clusterWrapper.Status.Phase == platformv1.ClusterConfined || + clusterWrapper.Status.Phase == platformv1.ClusterRecovering { err = provider.OnUpdate(ctx, clusterWrapper) clusterWrapper = c.checkHealth(ctx, clusterWrapper) if err != nil {