Skip to content

Commit d10439b

Browse files
committed
Merge branch 'main' of https://github.com/pingcap/tidb-operator into operator-rm
2 parents a5a734c + c01b1c9 commit d10439b

File tree

73 files changed

+682
-308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+682
-308
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ updates:
2626
- dependency-name: "github.com/onsi/gomega"
2727
- dependency-name: "go.uber.org/mock"
2828
- dependency-name: "github.com/apache/skywalking-eyes"
29+
- dependency-name: "golang.org/*"
2930
ignore:
3031
- dependency-name: "k8s.io/*"
3132
update-types:
@@ -40,6 +41,9 @@ updates:
4041
- "version-update:semver-major"
4142
- "version-update:semver-minor"
4243
groups:
44+
golang:
45+
patterns:
46+
- "golang.org/*"
4347
k8s:
4448
patterns:
4549
- "k8s.io/*"
@@ -55,3 +59,4 @@ updates:
5559
patterns:
5660
- "github.com/onsi/ginkgo/v2"
5761
- "github.com/onsi/gomega"
62+

.github/workflows/dependabot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
go-version-file: ./go.mod
2323
cache-dependency-path: "**/*.sum"
2424
- name: update go toolchain version
25-
if: steps.dependabot-metadata.outputs.package-ecosystem == 'docker' && steps.dependabot-metadata.outputs.dependency-names == 'golang'
25+
if: steps.dependabot-metadata.outputs.package-ecosystem == 'docker' && steps.dependabot-metadata.outputs.dependency-names == 'golang' && steps.dependabot-metadata.outputs.new-version != ''
2626
run: |
2727
go get toolchain@${{ steps.dependabot-metadata.outputs.new-version }}
2828
- name: go build

api/core/v1alpha1/tidb_types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,10 @@ type TiDBServer struct {
242242
Ports TiDBPorts `json:"ports,omitempty"`
243243

244244
// Labels defines the server labels of the TiDB server.
245-
// TiDB Operator will ignore `labels` in TiDB's config file and use this field instead.
246-
// Note these label keys are managed by TiDB Operator, it will be set automatically and you can not modify them:
245+
// Operator will set these `labels` by API.
246+
// If a label in this field is conflict with the config file, this field takes precedence.
247+
// NOTE: Different from other components, TiDB will replace all labels but not only add/update.
248+
// NOTE: these label keys are managed by TiDB Operator, it will be set automatically and you can not modify them:
247249
// - host
248250
// - region
249251
// - zone

api/core/v1alpha1/tiflash_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@ type TiFlashTemplateSpec struct {
183183
type TiFlashServer struct {
184184
// Ports defines all ports listened by tiflash
185185
Ports TiFlashPorts `json:"ports,omitempty"`
186+
187+
// Labels defines the server labels of the TiFlash server.
188+
// Operator will set these `labels` by API.
189+
// If a label in this field is conflict with the config file, this field takes precedence.
190+
// NOTE: If a label is removed, operator will not delete it automatically.
191+
// NOTE: these label keys are managed by TiDB Operator, it will be set automatically and you can not modify them:
192+
// - host
193+
// - region
194+
// - zone
195+
// +kubebuilder:validation:XValidation:rule="!('host' in self) && !('region' in self) && !('zone' in self)",message="labels cannot contain 'host', 'region', or 'zone' keys"
196+
Labels map[string]string `json:"labels,omitempty"`
186197
}
187198

188199
type TiFlashPorts struct {

api/core/v1alpha1/tikv_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,17 @@ type TiKVRemoteWorkers struct {
224224
type TiKVServer struct {
225225
// Ports defines all ports listened by tikv
226226
Ports TiKVPorts `json:"ports,omitempty"`
227+
228+
// Labels defines the server labels of the TiKV server.
229+
// Operator will set these `labels` by API dynamically.
230+
// If a label in this field is conflict with the config file, this field takes precedence.
231+
// NOTE: If a label is removed, operator will not delete it automatically.
232+
// NOTE: these label keys are managed by TiDB Operator, it will be set automatically and you can not modify them:
233+
// - host
234+
// - region
235+
// - zone
236+
// +kubebuilder:validation:XValidation:rule="!('host' in self) && !('region' in self) && !('zone' in self)",message="labels cannot contain 'host', 'region', or 'zone' keys"
237+
Labels map[string]string `json:"labels,omitempty"`
227238
}
228239

229240
type TiKVPorts struct {
@@ -238,6 +249,7 @@ type TiKVGroupStatus struct {
238249
GroupStatus `json:",inline"`
239250
}
240251

252+
// TiKVSpec defines the spec of tikv instance
241253
// +kubebuilder:validation:XValidation:rule="(!has(oldSelf.topology) && !has(self.topology)) || (has(oldSelf.topology) && has(self.topology))",fieldPath=".topology",message="topology can only be set when creating"
242254
type TiKVSpec struct {
243255
// Cluster is a reference of tidb cluster

api/core/v1alpha1/tiproxy_types.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,11 @@ type TiProxyServer struct {
184184
// Port defines all ports listened by TiProxy.
185185
Ports TiProxyPorts `json:"ports,omitempty"`
186186

187-
// Labels defines the server labels of the TiProxy.
188-
// TiDB Operator will ignore `labels` in TiProxy's config file and use this field instead.
189-
// Note these label keys are managed by TiDB Operator, it will be set automatically and you can not modify them:
187+
// Labels defines the server labels of the TiProxy server.
188+
// Operator will set these `labels` by API.
189+
// If a label in this field is conflict with the config file, this field takes precedence.
190+
// NOTE: If a label is removed, operator will not delete it automatically.
191+
// NOTE: these label keys are managed by TiDB Operator, it will be set automatically and you can not modify them:
190192
// - host
191193
// - region
192194
// - zone

api/core/v1alpha1/zz_generated.deepcopy.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/runtime-gen/generators/namer.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ import (
2020
"k8s.io/gengo/v2/types"
2121
)
2222

23+
const (
24+
nameTiDB = "TiDB"
25+
nameTiProxy = "TiProxy"
26+
nameTiKV = "TiKV"
27+
nameTiFlash = "TiFlash"
28+
)
29+
2330
type NameFunc func(t *types.Type) string
2431

2532
func (f NameFunc) Name(t *types.Type) string {
@@ -39,7 +46,7 @@ func GroupToInstanceName(t *types.Type) string {
3946
func GroupToSecurityTypeName(t *types.Type) string {
4047
name := strings.TrimSuffix(t.Name.Name, "Group")
4148
switch name {
42-
case "TiDB", "TiProxy":
49+
case nameTiDB, nameTiProxy:
4350
return name + "Security"
4451
}
4552

@@ -53,7 +60,7 @@ func GroupToSecurityTypeName(t *types.Type) string {
5360
func GroupToTLSTypeName(t *types.Type) string {
5461
name := strings.TrimSuffix(t.Name.Name, "Group")
5562
switch name {
56-
case "TiDB", "TiProxy":
63+
case nameTiDB, nameTiProxy:
5764
return name + "TLSConfig"
5865
}
5966

@@ -71,3 +78,12 @@ func GroupToInternalTLSTypeName(t *types.Type) string {
7178

7279
return "InternalTLS"
7380
}
81+
82+
func InstanceToServerLabelsField(t *types.Type) string {
83+
switch t.Name.Name {
84+
case nameTiDB, nameTiKV, nameTiFlash, nameTiProxy:
85+
return "in.Spec.Server.Labels"
86+
}
87+
88+
return "nil"
89+
}

cmd/runtime-gen/generators/runtime.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ func (g *runtimeGenerator) Filter(_ *generator.Context, t *types.Type) bool {
5454

5555
func (g *runtimeGenerator) Namers(*generator.Context) namer.NameSystems {
5656
return namer.NameSystems{
57-
"pub": namer.NewPublicNamer(0),
58-
"instance": NameFunc(GroupToInstanceName),
59-
"security": NameFunc(GroupToSecurityTypeName),
60-
"tls": NameFunc(GroupToTLSTypeName),
61-
"internaltls": NameFunc(GroupToInternalTLSTypeName),
57+
"pub": namer.NewPublicNamer(0),
58+
"instance": NameFunc(GroupToInstanceName),
59+
"security": NameFunc(GroupToSecurityTypeName),
60+
"tls": NameFunc(GroupToTLSTypeName),
61+
"internaltls": NameFunc(GroupToInternalTLSTypeName),
62+
"serverlabels": NameFunc(InstanceToServerLabelsField),
6263
}
6364
}
6465

@@ -281,6 +282,10 @@ func (in *$.|pub$) Subdomain() string {
281282
return in.Spec.Subdomain
282283
}
283284
285+
func (in *$.|pub$) ServerLabels() map[string]string {
286+
return $.|serverlabels$
287+
}
288+
284289
func (in *$.|pub$) ClusterCertKeyPairSecretName() string {
285290
sec := in.Spec.Security
286291
if sec != nil && sec.TLS != nil && sec.TLS.Cluster != nil && sec.TLS.Cluster.CertKeyPair != nil {

manifests/crd/core.pingcap.com_tidbgroups.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8800,8 +8800,10 @@ spec:
88008800
type: string
88018801
description: |-
88028802
Labels defines the server labels of the TiDB server.
8803-
TiDB Operator will ignore `labels` in TiDB's config file and use this field instead.
8804-
Note these label keys are managed by TiDB Operator, it will be set automatically and you can not modify them:
8803+
Operator will set these `labels` by API.
8804+
If a label in this field is conflict with the config file, this field takes precedence.
8805+
NOTE: Different from other components, TiDB will replace all labels but not only add/update.
8806+
NOTE: these label keys are managed by TiDB Operator, it will be set automatically and you can not modify them:
88058807
- host
88068808
- region
88078809
- zone

0 commit comments

Comments
 (0)