Skip to content

Commit 883c9ba

Browse files
authored
Merge branch 'master' into update_service_account
2 parents 8cbc336 + dd940d0 commit 883c9ba

21 files changed

+511
-221
lines changed

CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ 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.10.0...master)
8+
# [Unreleased](https://github.com/cockroachdb/cockroach-operator/compare/v2.11.0...master)
9+
10+
# [v2.11.0](https://github.com/cockroachdb/cockroach-operator/compare/v2.10.0...v2.11.0)
11+
12+
* Bug fix to return correct error message if value passed for `whenUnsatisfiable` under `topologySpreadConstraints` field is invalid.
13+
* Add openshift release process for cockroach operator
914

1015
# [v2.10.0](https://github.com/cockroachdb/cockroach-operator/compare/v2.9.0...v2.10.0)
1116

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

40+
## Changed
41+
* Update validation webhook to reject changes to cluster spec's AdditionalLabels field
42+
3543
# [v2.7.0](https://github.com/cockroachdb/cockroach-operator/compare/v2.6.0...v2.7.0)
3644

3745
## Fixed

apis/v1alpha1/webhook.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -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

+87
Original file line numberDiff line numberDiff line change
@@ -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+
}

build/release/teamcity-publish-openshift.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ set -euxo pipefail
1818
source "$(dirname "${0}")/teamcity-support.sh"
1919

2020
RH_PROJECT_ID="5e6027425c5456060d5f6084"
21-
RH_REGISTRY="scan.connect.redhat.com"
22-
RH_OPERATOR_IMG="${RH_REGISTRY}/ospid-cf721588-ad8a-4618-938c-5191c5e10ae4/cockroachdb-operator:${TAG}"
21+
RH_REGISTRY="quay.io"
22+
RH_OPERATOR_IMG="${RH_REGISTRY}/redhat-isv-containers/${RH_PROJECT_ID}:${TAG}"
2323

2424
OPERATOR_IMG="docker.io/cockroachdb/cockroach-operator:${TAG}"
2525
if ! [[ -z "${DRY_RUN}" ]] ; then

config/manager/patches/image.yaml

+27-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
spec:
2525
containers:
2626
- name: cockroach-operator
27-
image: cockroachdb/cockroach-operator:v2.10.0
27+
image: cockroachdb/cockroach-operator:v2.11.0
2828
env:
2929
- name: RELATED_IMAGE_COCKROACH_v20_1_4
3030
value: cockroachdb/cockroach:v20.1.4
@@ -192,6 +192,8 @@ spec:
192192
value: cockroachdb/cockroach:v22.1.18
193193
- name: RELATED_IMAGE_COCKROACH_v22_1_20
194194
value: cockroachdb/cockroach:v22.1.20
195+
- name: RELATED_IMAGE_COCKROACH_v22_1_22
196+
value: cockroachdb/cockroach:v22.1.22
195197
- name: RELATED_IMAGE_COCKROACH_v22_2_0
196198
value: cockroachdb/cockroach:v22.2.0
197199
- name: RELATED_IMAGE_COCKROACH_v22_2_1
@@ -212,9 +214,33 @@ spec:
212214
value: cockroachdb/cockroach:v22.2.8
213215
- name: RELATED_IMAGE_COCKROACH_v22_2_9
214216
value: cockroachdb/cockroach:v22.2.9
217+
- name: RELATED_IMAGE_COCKROACH_v22_2_10
218+
value: cockroachdb/cockroach:v22.2.10
219+
- name: RELATED_IMAGE_COCKROACH_v22_2_12
220+
value: cockroachdb/cockroach:v22.2.12
221+
- name: RELATED_IMAGE_COCKROACH_v22_2_14
222+
value: cockroachdb/cockroach:v22.2.14
215223
- name: RELATED_IMAGE_COCKROACH_v23_1_0
216224
value: cockroachdb/cockroach:v23.1.0
217225
- name: RELATED_IMAGE_COCKROACH_v23_1_1
218226
value: cockroachdb/cockroach:v23.1.1
219227
- name: RELATED_IMAGE_COCKROACH_v23_1_2
220228
value: cockroachdb/cockroach:v23.1.2
229+
- name: RELATED_IMAGE_COCKROACH_v23_1_3
230+
value: cockroachdb/cockroach:v23.1.3
231+
- name: RELATED_IMAGE_COCKROACH_v23_1_4
232+
value: cockroachdb/cockroach:v23.1.4
233+
- name: RELATED_IMAGE_COCKROACH_v23_1_5
234+
value: cockroachdb/cockroach:v23.1.5
235+
- name: RELATED_IMAGE_COCKROACH_v23_1_6
236+
value: cockroachdb/cockroach:v23.1.6
237+
- name: RELATED_IMAGE_COCKROACH_v23_1_7
238+
value: cockroachdb/cockroach:v23.1.7
239+
- name: RELATED_IMAGE_COCKROACH_v23_1_8
240+
value: cockroachdb/cockroach:v23.1.8
241+
- name: RELATED_IMAGE_COCKROACH_v23_1_9
242+
value: cockroachdb/cockroach:v23.1.9
243+
- name: RELATED_IMAGE_COCKROACH_v23_1_10
244+
value: cockroachdb/cockroach:v23.1.10
245+
- name: RELATED_IMAGE_COCKROACH_v23_1_11
246+
value: cockroachdb/cockroach:v23.1.11

0 commit comments

Comments
 (0)