diff --git a/manifests/crd.yaml b/manifests/crd.yaml index 5ed02618968..871b6c956ed 100644 --- a/manifests/crd.yaml +++ b/manifests/crd.yaml @@ -265,16 +265,19 @@ spec: matchLabels: additionalProperties: type: string - type: object - type: object - namespaces: - items: - type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object type: array - topologyKey: - type: string - required: - - topologyKey + matchLabels: + additionalProperties: + type: string + type: object type: object weight: format: int32 @@ -1608,28 +1611,27 @@ spec: requiredDuringSchedulingIgnoredDuringExecution: items: properties: - labelSelector: + configMap: properties: - matchExpressions: + items: items: properties: key: type: string - operator: + mode: + format: int32 + type: integer + path: type: string - values: - items: - type: string - type: array required: - key - - operator + - path type: object type: array - matchLabels: - additionalProperties: - type: string - type: object + name: + type: string + optional: + type: boolean type: object namespaces: items: @@ -1694,35 +1696,38 @@ spec: properties: labelSelector: properties: - matchExpressions: + items: items: properties: key: type: string - operator: + mode: + format: int32 + type: integer + path: type: string - values: - items: - type: string - type: array required: - key - - operator + - path type: object type: array - matchLabels: - additionalProperties: - type: string - type: object + name: + type: string + optional: + type: boolean + type: object + serviceAccountToken: + properties: + audience: + type: string + expirationSeconds: + format: int64 + type: integer + path: + type: string + required: + - path type: object - namespaces: - items: - type: string - type: array - topologyKey: - type: string - required: - - topologyKey type: object type: array type: object @@ -1855,6 +1860,130 @@ spec: - resource type: object secretKeyRef: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + required: + - topologyKey + type: object + type: array + type: object + type: object + azblob: + properties: + accessTier: + type: string + container: + type: string + path: + type: string + prefix: + type: string + secretName: + type: string + type: object + backupType: + type: string + br: + properties: + checkRequirements: + type: boolean + checksum: + type: boolean + cluster: + type: string + clusterNamespace: + type: string + concurrency: + format: int32 + type: integer + db: + type: string + logLevel: + type: string + onLine: + type: boolean + options: + items: + type: string + type: array + rateLimit: + type: integer + sendCredToTikv: + type: boolean + statusAddr: + type: string + table: + type: string + timeAgo: + type: string + required: + - cluster + type: object + cleanOption: + properties: + batchConcurrency: + format: int32 + type: integer + disableBatchConcurrency: + type: boolean + pageSize: + format: int64 + type: integer + routineConcurrency: + format: int32 + type: integer + type: object + cleanPolicy: + type: string + dumpling: + properties: + options: + items: + type: string + type: array + tableFilter: + items: + type: string + type: array + type: object + env: + items: + properties: + name: + type: string + value: + type: string + valueFrom: + properties: + configMapKeyRef: properties: key: type: string @@ -17419,6 +17548,9 @@ spec: type: string type: array podManagementPolicy: + enum: + - OrderedReady + - Parallel type: string podSecurityContext: properties: diff --git a/manifests/crd/v1/pingcap.com_tidbclusters.yaml b/manifests/crd/v1/pingcap.com_tidbclusters.yaml index eb842958286..7008616f47c 100644 --- a/manifests/crd/v1/pingcap.com_tidbclusters.yaml +++ b/manifests/crd/v1/pingcap.com_tidbclusters.yaml @@ -5110,6 +5110,9 @@ spec: type: string type: array podManagementPolicy: + enum: + - OrderedReady + - Parallel type: string podSecurityContext: properties: diff --git a/manifests/crd/v1beta1/pingcap.com_tidbclusters.yaml b/manifests/crd/v1beta1/pingcap.com_tidbclusters.yaml index 1c95047e6fa..30e41440beb 100644 --- a/manifests/crd/v1beta1/pingcap.com_tidbclusters.yaml +++ b/manifests/crd/v1beta1/pingcap.com_tidbclusters.yaml @@ -5104,6 +5104,9 @@ spec: type: string type: array podManagementPolicy: + enum: + - OrderedReady + - Parallel type: string podSecurityContext: properties: diff --git a/manifests/crd_v1beta1.yaml b/manifests/crd_v1beta1.yaml index e4dee0205b6..193b94e5980 100644 --- a/manifests/crd_v1beta1.yaml +++ b/manifests/crd_v1beta1.yaml @@ -265,16 +265,19 @@ spec: matchLabels: additionalProperties: type: string - type: object - type: object - namespaces: - items: - type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object type: array - topologyKey: - type: string - required: - - topologyKey + matchLabels: + additionalProperties: + type: string + type: object type: object weight: format: int32 @@ -1609,28 +1612,27 @@ spec: requiredDuringSchedulingIgnoredDuringExecution: items: properties: - labelSelector: + configMap: properties: - matchExpressions: + items: items: properties: key: type: string - operator: + mode: + format: int32 + type: integer + path: type: string - values: - items: - type: string - type: array required: - key - - operator + - path type: object type: array - matchLabels: - additionalProperties: - type: string - type: object + name: + type: string + optional: + type: boolean type: object namespaces: items: @@ -1695,35 +1697,38 @@ spec: properties: labelSelector: properties: - matchExpressions: + items: items: properties: key: type: string - operator: + mode: + format: int32 + type: integer + path: type: string - values: - items: - type: string - type: array required: - key - - operator + - path type: object type: array - matchLabels: - additionalProperties: - type: string - type: object + name: + type: string + optional: + type: boolean + type: object + serviceAccountToken: + properties: + audience: + type: string + expirationSeconds: + format: int64 + type: integer + path: + type: string + required: + - path type: object - namespaces: - items: - type: string - type: array - topologyKey: - type: string - required: - - topologyKey type: object type: array type: object @@ -1855,6 +1860,130 @@ spec: - resource type: object secretKeyRef: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + required: + - topologyKey + type: object + type: array + type: object + type: object + azblob: + properties: + accessTier: + type: string + container: + type: string + path: + type: string + prefix: + type: string + secretName: + type: string + type: object + backupType: + type: string + br: + properties: + checkRequirements: + type: boolean + checksum: + type: boolean + cluster: + type: string + clusterNamespace: + type: string + concurrency: + format: int32 + type: integer + db: + type: string + logLevel: + type: string + onLine: + type: boolean + options: + items: + type: string + type: array + rateLimit: + type: integer + sendCredToTikv: + type: boolean + statusAddr: + type: string + table: + type: string + timeAgo: + type: string + required: + - cluster + type: object + cleanOption: + properties: + batchConcurrency: + format: int32 + type: integer + disableBatchConcurrency: + type: boolean + pageSize: + format: int64 + type: integer + routineConcurrency: + format: int32 + type: integer + type: object + cleanPolicy: + type: string + dumpling: + properties: + options: + items: + type: string + type: array + tableFilter: + items: + type: string + type: array + type: object + env: + items: + properties: + name: + type: string + value: + type: string + valueFrom: + properties: + configMapKeyRef: properties: key: type: string @@ -17411,6 +17540,9 @@ spec: type: string type: array podManagementPolicy: + enum: + - OrderedReady + - Parallel type: string podSecurityContext: properties: diff --git a/pkg/apis/pingcap/v1alpha1/tidbcluster_test.go b/pkg/apis/pingcap/v1alpha1/tidbcluster_test.go index 2aceecb9715..c7cc1c5924b 100644 --- a/pkg/apis/pingcap/v1alpha1/tidbcluster_test.go +++ b/pkg/apis/pingcap/v1alpha1/tidbcluster_test.go @@ -27,6 +27,55 @@ import ( "k8s.io/utils/pointer" ) +func TestPodManagementPolicy(t *testing.T) { + g := NewGomegaWithT(t) + + type testcase struct { + name string + update func(c *TidbCluster) + expectFn func(*GomegaWithT, apps.PodManagementPolicyType) + } + testFn := func(test *testcase, t *testing.T) { + t.Log(test.name) + + tc := newTidbCluster() + test.update(tc) + test.expectFn(g, tc.BasePDSpec().PodManagementPolicy()) + } + tests := []testcase{ + { + name: "OrderedReady", + update: func(c *TidbCluster) { + c.Spec.PD.PodManagementPolicy = "OrderedReady" + }, + expectFn: func(g *GomegaWithT, s apps.PodManagementPolicyType) { + g.Expect(s).To(Equal(apps.OrderedReadyPodManagement)) + }, + }, + { + name: "Parallel", + update: func(c *TidbCluster) { + c.Spec.PD.PodManagementPolicy = "Parallel" + }, + expectFn: func(g *GomegaWithT, s apps.PodManagementPolicyType) { + g.Expect(s).To(Equal(apps.ParallelPodManagement)) + }, + }, + { + name: "Invalid pod management policy, should fall back to Parallel", + update: func(c *TidbCluster) { + c.Spec.PD.PodManagementPolicy = "invalid" + }, + expectFn: func(g *GomegaWithT, s apps.PodManagementPolicyType) { + g.Expect(s).To(Equal(apps.ParallelPodManagement)) + }, + }, + } + for i := range tests { + testFn(&tests[i], t) + } +} + func TestPDIsAvailable(t *testing.T) { g := NewGomegaWithT(t) diff --git a/pkg/apis/pingcap/v1alpha1/types.go b/pkg/apis/pingcap/v1alpha1/types.go index e7362282400..97839070e2e 100644 --- a/pkg/apis/pingcap/v1alpha1/types.go +++ b/pkg/apis/pingcap/v1alpha1/types.go @@ -324,6 +324,7 @@ type TidbClusterSpec struct { StatefulSetUpdateStrategy apps.StatefulSetUpdateStrategyType `json:"statefulSetUpdateStrategy,omitempty"` // PodManagementPolicy of TiDB cluster StatefulSets + // +kubebuilder:validation:Enum=OrderedReady;Parallel // +optional PodManagementPolicy apps.PodManagementPolicyType `json:"podManagementPolicy,omitempty"`