Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix scale and rolling update operation at the same time #505

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apis/apps/v1alpha1/nebulacluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions charts/nebula-operator/crds/nebulaclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1813,7 +1813,7 @@ spec:
type: object
replicas:
format: int32
minimum: 0
minimum: 1
type: integer
resources:
properties:
Expand Down Expand Up @@ -4553,7 +4553,7 @@ spec:
type: object
replicas:
format: int32
minimum: 0
minimum: 1
type: integer
resources:
properties:
Expand Down Expand Up @@ -7378,7 +7378,7 @@ spec:
type: object
replicas:
format: int32
minimum: 0
minimum: 1
type: integer
resources:
properties:
Expand Down Expand Up @@ -10228,7 +10228,7 @@ spec:
type: object
replicas:
format: int32
minimum: 0
minimum: 1
type: integer
resources:
properties:
Expand Down
8 changes: 4 additions & 4 deletions config/crd/bases/apps.nebula-graph.io_nebulaclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1813,7 +1813,7 @@ spec:
type: object
replicas:
format: int32
minimum: 0
minimum: 1
type: integer
resources:
properties:
Expand Down Expand Up @@ -4553,7 +4553,7 @@ spec:
type: object
replicas:
format: int32
minimum: 0
minimum: 1
type: integer
resources:
properties:
Expand Down Expand Up @@ -7378,7 +7378,7 @@ spec:
type: object
replicas:
format: int32
minimum: 0
minimum: 1
type: integer
resources:
properties:
Expand Down Expand Up @@ -10228,7 +10228,7 @@ spec:
type: object
replicas:
format: int32
minimum: 0
minimum: 1
type: integer
resources:
properties:
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/component/storaged_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
10 changes: 9 additions & 1 deletion pkg/controller/component/storaged_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}