diff --git a/apis/apps/v1alpha1/nebulacluster_types.go b/apis/apps/v1alpha1/nebulacluster_types.go index 9e845969..b914a108 100644 --- a/apis/apps/v1alpha1/nebulacluster_types.go +++ b/apis/apps/v1alpha1/nebulacluster_types.go @@ -497,7 +497,7 @@ type StoragedSpec struct { // ComponentSpec is a common set of k8s resource configs for nebula components. type ComponentSpec struct { // K8S deployment replicas setting. - // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Minimum=1 Replicas *int32 `json:"replicas,omitempty"` // K8S resources settings. diff --git a/charts/nebula-operator/crds/nebulaclusters.yaml b/charts/nebula-operator/crds/nebulaclusters.yaml index 5a11fed0..f295f8e3 100644 --- a/charts/nebula-operator/crds/nebulaclusters.yaml +++ b/charts/nebula-operator/crds/nebulaclusters.yaml @@ -1813,7 +1813,7 @@ spec: type: object replicas: format: int32 - minimum: 0 + minimum: 1 type: integer resources: properties: @@ -4553,7 +4553,7 @@ spec: type: object replicas: format: int32 - minimum: 0 + minimum: 1 type: integer resources: properties: @@ -7378,7 +7378,7 @@ spec: type: object replicas: format: int32 - minimum: 0 + minimum: 1 type: integer resources: properties: @@ -10228,7 +10228,7 @@ spec: type: object replicas: format: int32 - minimum: 0 + minimum: 1 type: integer resources: properties: diff --git a/config/crd/bases/apps.nebula-graph.io_nebulaclusters.yaml b/config/crd/bases/apps.nebula-graph.io_nebulaclusters.yaml index 5a11fed0..f295f8e3 100644 --- a/config/crd/bases/apps.nebula-graph.io_nebulaclusters.yaml +++ b/config/crd/bases/apps.nebula-graph.io_nebulaclusters.yaml @@ -1813,7 +1813,7 @@ spec: type: object replicas: format: int32 - minimum: 0 + minimum: 1 type: integer resources: properties: @@ -4553,7 +4553,7 @@ spec: type: object replicas: format: int32 - minimum: 0 + minimum: 1 type: integer resources: properties: @@ -7378,7 +7378,7 @@ spec: type: object replicas: format: int32 - minimum: 0 + minimum: 1 type: integer resources: properties: @@ -10228,7 +10228,7 @@ spec: type: object replicas: format: int32 - minimum: 0 + minimum: 1 type: integer resources: properties: diff --git a/pkg/controller/component/storaged_cluster.go b/pkg/controller/component/storaged_cluster.go index 40383930..87d07354 100644 --- a/pkg/controller/component/storaged_cluster.go +++ b/pkg/controller/component/storaged_cluster.go @@ -306,7 +306,8 @@ func (c *storagedCluster) syncNebulaClusterStatus( return err } - if updating && nc.Status.Metad.Phase != v1alpha1.UpdatePhase { + if updating && !strings.Contains(string(nc.Status.Storaged.Phase), "Scale") && + nc.Status.Metad.Phase != v1alpha1.UpdatePhase { nc.Status.Storaged.Phase = v1alpha1.UpdatePhase } diff --git a/pkg/controller/component/storaged_scaler.go b/pkg/controller/component/storaged_scaler.go index d467d81a..1269890f 100644 --- a/pkg/controller/component/storaged_scaler.go +++ b/pkg/controller/component/storaged_scaler.go @@ -23,6 +23,7 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/klog/v2" + "k8s.io/utils/pointer" nebulago "github.com/vesoft-inc/nebula-go/v3/nebula" "github.com/vesoft-inc/nebula-operator/apis/apps/v1alpha1" @@ -63,7 +64,7 @@ func (ss *storageScaler) ScaleOut(nc *v1alpha1.NebulaCluster) error { return err } - if !nc.StoragedComponent().IsReady() { + if !isStoragedCreatedPodReady(nc) { klog.Infof("storaged cluster [%s/%s] status not ready", ns, componentName) return nil } @@ -235,3 +236,10 @@ func (ss *storageScaler) ScaleIn(nc *v1alpha1.NebulaCluster, oldReplicas, newRep nc.Status.Storaged.Phase = v1alpha1.RunningPhase return ss.clientSet.NebulaCluster().UpdateNebulaClusterStatus(nc) } + +func isStoragedCreatedPodReady(nc *v1alpha1.NebulaCluster) bool { + if nc.Status.Storaged.Workload == nil { + return false + } + return pointer.Int32Deref(nc.Spec.Storaged.Replicas, 0) == nc.Status.Storaged.Workload.ReadyReplicas +}