Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into do-main
Browse files Browse the repository at this point in the history
  • Loading branch information
bsnyder788 committed May 2, 2024
2 parents 3df72ef + 28d139c commit aa091cc
Show file tree
Hide file tree
Showing 288 changed files with 1,032 additions and 583 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-kind-create.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Cockroach Authors
# Copyright 2024 The Cockroach Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-kind-decommission.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Cockroach Authors
# Copyright 2024 The Cockroach Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-kind-upgrades.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Cockroach Authors
# Copyright 2024 The Cockroach Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-kind-upgradessha256.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Cockroach Authors
# Copyright 2024 The Cockroach Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-kind-versionchecker.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Cockroach Authors
# Copyright 2024 The Cockroach Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-smoketest.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Cockroach Authors
# Copyright 2024 The Cockroach Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/templates.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Cockroach Authors
# Copyright 2024 The Cockroach Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Cockroach Authors
# Copyright 2024 The Cockroach Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
24 changes: 14 additions & 10 deletions .github/workflows/update-crdb-versions.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Cockroach Authors
# Copyright 2024 The Cockroach Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,13 +31,17 @@ jobs:
with:
path: "~/.cache/bazel"
key: bazel
- name: Update CRDB versions
uses: technote-space/create-pr-action@v2
- name: Update CRDB version
run: make release/gen-templates
- name: Create PR
uses: peter-evans/create-pull-request@v5
with:
EXECUTE_COMMANDS: |
make release/gen-templates
COMMIT_MESSAGE: 'Update CRDB versions'
COMMIT_NAME: 'GitHub Actions'
COMMIT_EMAIL: '[email protected]'
PR_BRANCH_NAME: 'crdb-update-${PR_ID}'
PR_TITLE: 'Update CRDB versions'
base: "master"
branch: 'crdb-version-update'
title: "Update CRDB versions"
author: "CRL Release bot <[email protected]>"
body: |
Update supported CRDB versions.
commit-message: |
Update supported CRDB versions.
delete-branch: true
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Cockroach Authors
# Copyright 2024 The Cockroach Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [Unreleased](https://github.com/cockroachdb/cockroach-operator/compare/v2.11.0...master)
# [Unreleased](https://github.com/cockroachdb/cockroach-operator/compare/v2.14.0...master)

# [v2.14.0](https://github.com/cockroachdb/cockroach-operator/compare/v2.13.0...v2.14.0)

# [v2.13.0](https://github.com/cockroachdb/cockroach-operator/compare/v2.12.0...v2.13.0)

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

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

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

## Changed
* Update validation webhook to reject changes to cluster spec's AdditionalLabels field

# [v2.7.0](https://github.com/cockroachdb/cockroach-operator/compare/v2.6.0...v2.7.0)

## Fixed
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Cockroach Authors
# Copyright 2024 The Cockroach Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions apis/v1alpha1/action_status.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023 The Cockroach Authors
Copyright 2024 The Cockroach Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@ limitations under the License.

package v1alpha1

//ActionStatus struct used to save the status of each action that the controller runs
// ActionStatus struct used to save the status of each action that the controller runs
type ActionStatus int

const (
Expand Down
4 changes: 2 additions & 2 deletions apis/v1alpha1/action_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023 The Cockroach Authors
Copyright 2024 The Cockroach Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@ limitations under the License.

package v1alpha1

//ActionType type alias
// ActionType type alias
type ActionType string

// All possible action types
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023 The Cockroach Authors
Copyright 2024 The Cockroach Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha1/cluster_types_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023 The Cockroach Authors
Copyright 2024 The Cockroach Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions apis/v1alpha1/condition_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023 The Cockroach Authors
Copyright 2024 The Cockroach Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@ limitations under the License.

package v1alpha1

//ClusterConditionType type alias
// ClusterConditionType type alias
type ClusterConditionType string

const (
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023 The Cockroach Authors
Copyright 2024 The Cockroach Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023 The Cockroach Authors
Copyright 2024 The Cockroach Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions apis/v1alpha1/restart_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023 The Cockroach Authors
Copyright 2024 The Cockroach Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@ limitations under the License.

package v1alpha1

//ClusterRestartType type alias
// ClusterRestartType type alias
type ClusterRestartType int

const (
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha1/volume.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023 The Cockroach Authors
Copyright 2024 The Cockroach Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha1/volume_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023 The Cockroach Authors
Copyright 2024 The Cockroach Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
20 changes: 17 additions & 3 deletions apis/v1alpha1/webhook.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023 The Cockroach Authors
Copyright 2024 The Cockroach Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,8 @@ package v1alpha1

import (
"fmt"
"reflect"

v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
kerrors "k8s.io/apimachinery/pkg/util/errors"
Expand Down Expand Up @@ -51,7 +53,7 @@ func (r *CrdbCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).For(r).Complete()
}

//+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
// +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

// Default implements webhook.Defaulter so a webhook will be registered for the type.
func (r *CrdbCluster) Default() {
Expand Down Expand Up @@ -79,7 +81,7 @@ func (r *CrdbCluster) Default() {
}
}

//+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
// +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

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

oldCluster, ok := old.(*CrdbCluster)
if !ok {
webhookLog.Info(fmt.Sprintf("unexpected old cluster type %T", old))
} else {
// Validate if labels changed.
// k8s does not support changing selector/labels on sts:
// https://github.com/kubernetes/kubernetes/issues/90519.
if !reflect.DeepEqual(oldCluster.Spec.AdditionalLabels, r.Spec.AdditionalLabels) {
errors = append(errors, fmt.Errorf("mutating additionalLabels field is not supported"))
}
}

if r.Spec.Ingress != nil {
if err := r.ValidateIngress(); err != nil {
errors = append(errors, err...)
Expand Down
89 changes: 88 additions & 1 deletion apis/v1alpha1/webhook_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023 The Cockroach Authors
Copyright 2024 The Cockroach Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -23,6 +23,7 @@ import (
. "github.com/cockroachdb/cockroach-operator/apis/v1alpha1"
"github.com/stretchr/testify/require"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)

func TestCrdbClusterDefault(t *testing.T) {
Expand Down Expand Up @@ -181,3 +182,89 @@ func TestUpdateCrdbCluster(t *testing.T) {
require.Equal(t, err.Error(), testcase.ErrMsg)
}
}

func TestUpdateCrdbClusterLabels(t *testing.T) {
oldCluster := CrdbCluster{
Spec: CrdbClusterSpec{
Image: &PodImage{},
AdditionalLabels: map[string]string{
"k": "v",
},
},
}
fs := v1.PersistentVolumeFilesystem

testcases := []struct {
Cluster *CrdbCluster
ShouldError bool
}{
{
Cluster: &CrdbCluster{Spec: CrdbClusterSpec{
Image: &PodImage{Name: "testImage"},
AdditionalLabels: map[string]string{"k": "v"},
DataStore: Volume{
VolumeClaim: &VolumeClaim{
PersistentVolumeClaimSpec: v1.PersistentVolumeClaimSpec{
VolumeMode: &fs,
},
},
},
}},
ShouldError: false,
},
{
Cluster: &CrdbCluster{Spec: CrdbClusterSpec{
Image: &PodImage{Name: "testImage"},
AdditionalLabels: map[string]string{"k": "x"},
DataStore: Volume{
VolumeClaim: &VolumeClaim{
PersistentVolumeClaimSpec: v1.PersistentVolumeClaimSpec{
VolumeMode: &fs,
},
},
},
}},
// label k has a different value.
ShouldError: true,
},
{
Cluster: &CrdbCluster{Spec: CrdbClusterSpec{
Image: &PodImage{Name: "testImage"},
DataStore: Volume{
VolumeClaim: &VolumeClaim{
PersistentVolumeClaimSpec: v1.PersistentVolumeClaimSpec{
VolumeMode: &fs,
},
},
},
}},
// labels are missing / empty.
ShouldError: true,
},
{
Cluster: &CrdbCluster{Spec: CrdbClusterSpec{
Image: &PodImage{Name: "testImage"},
AdditionalLabels: map[string]string{"k": "v", "kk": "v"},
DataStore: Volume{
VolumeClaim: &VolumeClaim{
PersistentVolumeClaimSpec: v1.PersistentVolumeClaimSpec{
VolumeMode: &fs,
},
},
},
}},
// labels contain additional kv.
ShouldError: true,
},
}

for _, tc := range testcases {
err := tc.Cluster.ValidateUpdate(runtime.Object(&oldCluster))
if tc.ShouldError {
require.Error(t, err)
require.Equal(t, err.Error(), "mutating additionalLabels field is not supported")
} else {
require.NoError(t, err)
}
}
}
2 changes: 1 addition & 1 deletion apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/release/teamcity-publish-openshift-bundle.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Copyright 2023 The Cockroach Authors
# Copyright 2024 The Cockroach Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit aa091cc

Please sign in to comment.