From 14c176cd36acd8b354a0fba449455852034f2a9b Mon Sep 17 00:00:00 2001 From: doyoubi Date: Sat, 18 Dec 2021 12:05:59 +0800 Subject: [PATCH] Add migration_limit config in Undermoon CR --- api/v1alpha1/undermoon_types.go | 4 ++++ config/cr/bases/undermoon_v1alpha1_undermoon.yaml | 1 + config/cr/overlays/helm/replace_values.yaml | 3 +++ .../crd/bases/undermoon.doyoubi.mydomain_undermoons.yaml | 7 +++++++ controllers/broker.go | 6 +++++- helm/undermoon-cluster/templates/undermoon.yaml | 1 + helm/undermoon-cluster/values.yaml | 1 + .../templates/undermoon.doyoubi.mydomain_undermoons.yaml | 6 ++++++ 8 files changed, 28 insertions(+), 1 deletion(-) diff --git a/api/v1alpha1/undermoon_types.go b/api/v1alpha1/undermoon_types.go index bbbbc01..ca52766 100644 --- a/api/v1alpha1/undermoon_types.go +++ b/api/v1alpha1/undermoon_types.go @@ -51,6 +51,10 @@ type UndermoonSpec struct { // COUNT arguments for SCAN command during migration. // +kubebuilder:validation:Minimum=1 MigrationScanCount uint32 `json:"migrationScanCount"` + // Maximum concurrent migration shard number. + // This can't be updated. + // +kubebuilder:validation:Minimum=1 + MigrationLimit uint32 `json:"migrationLimit"` // Disable failover for server proxies. DisableFailover bool `json:"disableFailover"` diff --git a/config/cr/bases/undermoon_v1alpha1_undermoon.yaml b/config/cr/bases/undermoon_v1alpha1_undermoon.yaml index d191cea..f262294 100644 --- a/config/cr/bases/undermoon_v1alpha1_undermoon.yaml +++ b/config/cr/bases/undermoon_v1alpha1_undermoon.yaml @@ -11,6 +11,7 @@ spec: proxyThreads: 2 migrationScanInterval: 1000 migrationScanCount: 16 + migrationLimit: 2 disableFailover: false undermoonImage: localhost:5000/undermoon_test undermoonImagePullPolicy: IfNotPresent diff --git a/config/cr/overlays/helm/replace_values.yaml b/config/cr/overlays/helm/replace_values.yaml index 00d4f21..39f6d72 100644 --- a/config/cr/overlays/helm/replace_values.yaml +++ b/config/cr/overlays/helm/replace_values.yaml @@ -26,6 +26,9 @@ - op: replace path: /spec/migrationScanCount value: "{{ .Values.cluster.migrationScanCount }}" +- op: replace + path: /spec/migrationLimit + value: "{{ .Values.cluster.migrationLimit }}" - op: replace path: /spec/disableFailover value: "{{ .Values.cluster.disableFailover }}" diff --git a/config/crd/bases/undermoon.doyoubi.mydomain_undermoons.yaml b/config/crd/bases/undermoon.doyoubi.mydomain_undermoons.yaml index 04a9e19..960720e 100644 --- a/config/crd/bases/undermoon.doyoubi.mydomain_undermoons.yaml +++ b/config/crd/bases/undermoon.doyoubi.mydomain_undermoons.yaml @@ -712,6 +712,12 @@ spec: format: int32 minimum: 1 type: integer + migrationLimit: + description: Maximum concurrent migration shard number. This can't + be updated. + format: int32 + minimum: 1 + type: integer migrationScanCount: description: COUNT arguments for SCAN command during migration. format: int32 @@ -2323,6 +2329,7 @@ spec: - clusterName - disableFailover - maxMemory + - migrationLimit - migrationScanCount - migrationScanInterval - port diff --git a/controllers/broker.go b/controllers/broker.go index fe09b60..44643f5 100644 --- a/controllers/broker.go +++ b/controllers/broker.go @@ -111,7 +111,7 @@ func createBrokerStatefulSet(cr *undermoonv1alpha1.Undermoon) *appsv1.StatefulSe }, { Name: "UNDERMOON_MIGRATION_LIMIT", - Value: "2", + Value: fmt.Sprintf("%d", cr.Spec.MigrationLimit), }, { Name: "UNDERMOON_RECOVER_FROM_META_FILE", @@ -242,6 +242,10 @@ func brokerStatefulSetChanged(reqLogger logr.Logger, cr *undermoonv1alpha1.Under return true } + // Since changing migration_limit for broker may result in + // inconsistent generated metadata for the same epoch in different brokers, + // we won't update migration_limit. + return false } diff --git a/helm/undermoon-cluster/templates/undermoon.yaml b/helm/undermoon-cluster/templates/undermoon.yaml index 62be722..2085f40 100644 --- a/helm/undermoon-cluster/templates/undermoon.yaml +++ b/helm/undermoon-cluster/templates/undermoon.yaml @@ -13,6 +13,7 @@ spec: disableFailover: {{ .Values.cluster.disableFailover }} imagePullSecrets: {{- toYaml .Values.imagePullSecrets | nindent 4 }} maxMemory: {{ .Values.cluster.maxMemory }} + migrationLimit: {{ .Values.cluster.migrationLimit }} migrationScanCount: {{ .Values.cluster.migrationScanCount }} migrationScanInterval: {{ .Values.cluster.migrationScanInterval }} nodeSelector: {{- toYaml .Values.nodeSelector | nindent 4 }} diff --git a/helm/undermoon-cluster/values.yaml b/helm/undermoon-cluster/values.yaml index 73c174f..1e2379a 100644 --- a/helm/undermoon-cluster/values.yaml +++ b/helm/undermoon-cluster/values.yaml @@ -11,6 +11,7 @@ cluster: proxyThreads: 4 migrationScanInterval: 1000 migrationScanCount: 16 + migrationLimit: 2 disableFailover: false image: diff --git a/helm/undermoon-operator/templates/undermoon.doyoubi.mydomain_undermoons.yaml b/helm/undermoon-operator/templates/undermoon.doyoubi.mydomain_undermoons.yaml index c72f5bc..3709c58 100644 --- a/helm/undermoon-operator/templates/undermoon.doyoubi.mydomain_undermoons.yaml +++ b/helm/undermoon-operator/templates/undermoon.doyoubi.mydomain_undermoons.yaml @@ -444,6 +444,11 @@ spec: format: int32 minimum: 1 type: integer + migrationLimit: + description: Maximum concurrent migration shard number. This can't be updated. + format: int32 + minimum: 1 + type: integer migrationScanCount: description: COUNT arguments for SCAN command during migration. format: int32 @@ -1548,6 +1553,7 @@ spec: - clusterName - disableFailover - maxMemory + - migrationLimit - migrationScanCount - migrationScanInterval - port