Skip to content

Commit aa091cc

Browse files
committed
Merge remote-tracking branch 'upstream/master' into do-main
2 parents 3df72ef + 28d139c commit aa091cc

File tree

288 files changed

+1032
-583
lines changed

Some content is hidden

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

288 files changed

+1032
-583
lines changed

.github/workflows/e2e-kind-create.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 The Cockroach Authors
1+
# Copyright 2024 The Cockroach Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

.github/workflows/e2e-kind-decommission.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 The Cockroach Authors
1+
# Copyright 2024 The Cockroach Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

.github/workflows/e2e-kind-upgrades.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 The Cockroach Authors
1+
# Copyright 2024 The Cockroach Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

.github/workflows/e2e-kind-upgradessha256.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 The Cockroach Authors
1+
# Copyright 2024 The Cockroach Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

.github/workflows/e2e-kind-versionchecker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 The Cockroach Authors
1+
# Copyright 2024 The Cockroach Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

.github/workflows/nightly-smoketest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 The Cockroach Authors
1+
# Copyright 2024 The Cockroach Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

.github/workflows/templates.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 The Cockroach Authors
1+
# Copyright 2024 The Cockroach Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 The Cockroach Authors
1+
# Copyright 2024 The Cockroach Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

.github/workflows/update-crdb-versions.yaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 The Cockroach Authors
1+
# Copyright 2024 The Cockroach Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -31,13 +31,17 @@ jobs:
3131
with:
3232
path: "~/.cache/bazel"
3333
key: bazel
34-
- name: Update CRDB versions
35-
uses: technote-space/create-pr-action@v2
34+
- name: Update CRDB version
35+
run: make release/gen-templates
36+
- name: Create PR
37+
uses: peter-evans/create-pull-request@v5
3638
with:
37-
EXECUTE_COMMANDS: |
38-
make release/gen-templates
39-
COMMIT_MESSAGE: 'Update CRDB versions'
40-
COMMIT_NAME: 'GitHub Actions'
41-
COMMIT_EMAIL: '[email protected]'
42-
PR_BRANCH_NAME: 'crdb-update-${PR_ID}'
43-
PR_TITLE: 'Update CRDB versions'
39+
base: "master"
40+
branch: 'crdb-version-update'
41+
title: "Update CRDB versions"
42+
author: "CRL Release bot <[email protected]>"
43+
body: |
44+
Update supported CRDB versions.
45+
commit-message: |
46+
Update supported CRDB versions.
47+
delete-branch: true

.golangci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 The Cockroach Authors
1+
# Copyright 2024 The Cockroach Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
66
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
# [Unreleased](https://github.com/cockroachdb/cockroach-operator/compare/v2.11.0...master)
8+
# [Unreleased](https://github.com/cockroachdb/cockroach-operator/compare/v2.14.0...master)
9+
10+
# [v2.14.0](https://github.com/cockroachdb/cockroach-operator/compare/v2.13.0...v2.14.0)
11+
12+
# [v2.13.0](https://github.com/cockroachdb/cockroach-operator/compare/v2.12.0...v2.13.0)
13+
14+
# [v2.12.0](https://github.com/cockroachdb/cockroach-operator/compare/v2.11.0...v2.12.0)
915

1016
# [v2.11.0](https://github.com/cockroachdb/cockroach-operator/compare/v2.10.0...v2.11.0)
1117

@@ -37,6 +43,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
3743
* Correctly detect failed version checker Pods
3844
* retry cluster status updates, reducing test flakes
3945

46+
## Changed
47+
* Update validation webhook to reject changes to cluster spec's AdditionalLabels field
48+
4049
# [v2.7.0](https://github.com/cockroachdb/cockroach-operator/compare/v2.6.0...v2.7.0)
4150

4251
## Fixed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 The Cockroach Authors
1+
# Copyright 2024 The Cockroach Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

apis/v1alpha1/action_status.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 The Cockroach Authors
2+
Copyright 2024 The Cockroach Authors
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
package v1alpha1
1818

19-
//ActionStatus struct used to save the status of each action that the controller runs
19+
// ActionStatus struct used to save the status of each action that the controller runs
2020
type ActionStatus int
2121

2222
const (

apis/v1alpha1/action_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 The Cockroach Authors
2+
Copyright 2024 The Cockroach Authors
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
package v1alpha1
1818

19-
//ActionType type alias
19+
// ActionType type alias
2020
type ActionType string
2121

2222
// All possible action types

apis/v1alpha1/cluster_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 The Cockroach Authors
2+
Copyright 2024 The Cockroach Authors
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

apis/v1alpha1/cluster_types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 The Cockroach Authors
2+
Copyright 2024 The Cockroach Authors
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

apis/v1alpha1/condition_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 The Cockroach Authors
2+
Copyright 2024 The Cockroach Authors
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
package v1alpha1
1818

19-
//ClusterConditionType type alias
19+
// ClusterConditionType type alias
2020
type ClusterConditionType string
2121

2222
const (

apis/v1alpha1/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 The Cockroach Authors
2+
Copyright 2024 The Cockroach Authors
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

apis/v1alpha1/groupversion_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 The Cockroach Authors
2+
Copyright 2024 The Cockroach Authors
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

apis/v1alpha1/restart_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 The Cockroach Authors
2+
Copyright 2024 The Cockroach Authors
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
package v1alpha1
1818

19-
//ClusterRestartType type alias
19+
// ClusterRestartType type alias
2020
type ClusterRestartType int
2121

2222
const (

apis/v1alpha1/volume.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 The Cockroach Authors
2+
Copyright 2024 The Cockroach Authors
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

apis/v1alpha1/volume_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 The Cockroach Authors
2+
Copyright 2024 The Cockroach Authors
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

apis/v1alpha1/webhook.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 The Cockroach Authors
2+
Copyright 2024 The Cockroach Authors
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@ package v1alpha1
1818

1919
import (
2020
"fmt"
21+
"reflect"
22+
2123
v1 "k8s.io/api/core/v1"
2224
"k8s.io/apimachinery/pkg/runtime"
2325
kerrors "k8s.io/apimachinery/pkg/util/errors"
@@ -51,7 +53,7 @@ func (r *CrdbCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
5153
return ctrl.NewWebhookManagedBy(mgr).For(r).Complete()
5254
}
5355

54-
//+kubebuilder:webhook:path=/mutate-crdb-cockroachlabs-com-v1alpha1-crdbcluster,mutating=true,failurePolicy=fail,groups=crdb.cockroachlabs.com,resources=crdbclusters,verbs=create;update,versions=v1alpha1,name=mcrdbcluster.kb.io,sideEffects=None,admissionReviewVersions=v1
56+
// +kubebuilder:webhook:path=/mutate-crdb-cockroachlabs-com-v1alpha1-crdbcluster,mutating=true,failurePolicy=fail,groups=crdb.cockroachlabs.com,resources=crdbclusters,verbs=create;update,versions=v1alpha1,name=mcrdbcluster.kb.io,sideEffects=None,admissionReviewVersions=v1
5557

5658
// Default implements webhook.Defaulter so a webhook will be registered for the type.
5759
func (r *CrdbCluster) Default() {
@@ -79,7 +81,7 @@ func (r *CrdbCluster) Default() {
7981
}
8082
}
8183

82-
//+kubebuilder:webhook:path=/validate-crdb-cockroachlabs-com-v1alpha1-crdbcluster,mutating=false,failurePolicy=fail,groups=crdb.cockroachlabs.com,resources=crdbclusters,verbs=create;update,versions=v1alpha1,name=vcrdbcluster.kb.io,sideEffects=None,admissionReviewVersions=v1
84+
// +kubebuilder:webhook:path=/validate-crdb-cockroachlabs-com-v1alpha1-crdbcluster,mutating=false,failurePolicy=fail,groups=crdb.cockroachlabs.com,resources=crdbclusters,verbs=create;update,versions=v1alpha1,name=vcrdbcluster.kb.io,sideEffects=None,admissionReviewVersions=v1
8385

8486
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
8587
func (r *CrdbCluster) ValidateCreate() error {
@@ -111,6 +113,18 @@ func (r *CrdbCluster) ValidateUpdate(old runtime.Object) error {
111113
webhookLog.Info("validate update", "name", r.Name)
112114
var errors []error
113115

116+
oldCluster, ok := old.(*CrdbCluster)
117+
if !ok {
118+
webhookLog.Info(fmt.Sprintf("unexpected old cluster type %T", old))
119+
} else {
120+
// Validate if labels changed.
121+
// k8s does not support changing selector/labels on sts:
122+
// https://github.com/kubernetes/kubernetes/issues/90519.
123+
if !reflect.DeepEqual(oldCluster.Spec.AdditionalLabels, r.Spec.AdditionalLabels) {
124+
errors = append(errors, fmt.Errorf("mutating additionalLabels field is not supported"))
125+
}
126+
}
127+
114128
if r.Spec.Ingress != nil {
115129
if err := r.ValidateIngress(); err != nil {
116130
errors = append(errors, err...)

apis/v1alpha1/webhook_test.go

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 The Cockroach Authors
2+
Copyright 2024 The Cockroach Authors
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import (
2323
. "github.com/cockroachdb/cockroach-operator/apis/v1alpha1"
2424
"github.com/stretchr/testify/require"
2525
v1 "k8s.io/api/core/v1"
26+
"k8s.io/apimachinery/pkg/runtime"
2627
)
2728

2829
func TestCrdbClusterDefault(t *testing.T) {
@@ -181,3 +182,89 @@ func TestUpdateCrdbCluster(t *testing.T) {
181182
require.Equal(t, err.Error(), testcase.ErrMsg)
182183
}
183184
}
185+
186+
func TestUpdateCrdbClusterLabels(t *testing.T) {
187+
oldCluster := CrdbCluster{
188+
Spec: CrdbClusterSpec{
189+
Image: &PodImage{},
190+
AdditionalLabels: map[string]string{
191+
"k": "v",
192+
},
193+
},
194+
}
195+
fs := v1.PersistentVolumeFilesystem
196+
197+
testcases := []struct {
198+
Cluster *CrdbCluster
199+
ShouldError bool
200+
}{
201+
{
202+
Cluster: &CrdbCluster{Spec: CrdbClusterSpec{
203+
Image: &PodImage{Name: "testImage"},
204+
AdditionalLabels: map[string]string{"k": "v"},
205+
DataStore: Volume{
206+
VolumeClaim: &VolumeClaim{
207+
PersistentVolumeClaimSpec: v1.PersistentVolumeClaimSpec{
208+
VolumeMode: &fs,
209+
},
210+
},
211+
},
212+
}},
213+
ShouldError: false,
214+
},
215+
{
216+
Cluster: &CrdbCluster{Spec: CrdbClusterSpec{
217+
Image: &PodImage{Name: "testImage"},
218+
AdditionalLabels: map[string]string{"k": "x"},
219+
DataStore: Volume{
220+
VolumeClaim: &VolumeClaim{
221+
PersistentVolumeClaimSpec: v1.PersistentVolumeClaimSpec{
222+
VolumeMode: &fs,
223+
},
224+
},
225+
},
226+
}},
227+
// label k has a different value.
228+
ShouldError: true,
229+
},
230+
{
231+
Cluster: &CrdbCluster{Spec: CrdbClusterSpec{
232+
Image: &PodImage{Name: "testImage"},
233+
DataStore: Volume{
234+
VolumeClaim: &VolumeClaim{
235+
PersistentVolumeClaimSpec: v1.PersistentVolumeClaimSpec{
236+
VolumeMode: &fs,
237+
},
238+
},
239+
},
240+
}},
241+
// labels are missing / empty.
242+
ShouldError: true,
243+
},
244+
{
245+
Cluster: &CrdbCluster{Spec: CrdbClusterSpec{
246+
Image: &PodImage{Name: "testImage"},
247+
AdditionalLabels: map[string]string{"k": "v", "kk": "v"},
248+
DataStore: Volume{
249+
VolumeClaim: &VolumeClaim{
250+
PersistentVolumeClaimSpec: v1.PersistentVolumeClaimSpec{
251+
VolumeMode: &fs,
252+
},
253+
},
254+
},
255+
}},
256+
// labels contain additional kv.
257+
ShouldError: true,
258+
},
259+
}
260+
261+
for _, tc := range testcases {
262+
err := tc.Cluster.ValidateUpdate(runtime.Object(&oldCluster))
263+
if tc.ShouldError {
264+
require.Error(t, err)
265+
require.Equal(t, err.Error(), "mutating additionalLabels field is not supported")
266+
} else {
267+
require.NoError(t, err)
268+
}
269+
}
270+
}

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/release/teamcity-publish-openshift-bundle.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Copyright 2023 The Cockroach Authors
2+
# Copyright 2024 The Cockroach Authors
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)