From 5940bccb95b4dcbb285279f6d196596ccdd7eff7 Mon Sep 17 00:00:00 2001 From: Alexander Dejanovski Date: Wed, 27 Nov 2024 11:03:57 +0100 Subject: [PATCH 1/3] Upgrade Reaper to 3.7.0 (#1459) --- CHANGELOG/CHANGELOG-1.21.md | 2 +- apis/reaper/v1alpha1/reaper_types.go | 4 ++-- .../k8ssandra-operator/crds/k8ssandra-operator-crds.yaml | 8 ++++---- config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml | 4 ++-- config/crd/bases/reaper.k8ssandra.io_reapers.yaml | 4 ++-- pkg/reaper/deployment.go | 2 +- pkg/reaper/deployment_test.go | 8 ++++---- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/CHANGELOG/CHANGELOG-1.21.md b/CHANGELOG/CHANGELOG-1.21.md index 6d4d84c69..dcd092818 100644 --- a/CHANGELOG/CHANGELOG-1.21.md +++ b/CHANGELOG/CHANGELOG-1.21.md @@ -16,5 +16,5 @@ When cutting a new release, update the `unreleased` heading to the tag being gen ## unreleased * [CHANGE] [#1441](https://github.com/k8ssandra/k8ssandra-operator/issues/1441) Use k8ssandra-client instead of k8ssandra-tools for CRD upgrades -* [BUGFIX] [#1383](https://github.com/k8ssandra/k8ssandra-operator/issues/1383) Do not create MedusaBackup if MadusaBakupJob did not fully succeed +* [BUGFIX] [#1383](https://github.com/k8ssandra/k8ssandra-operator/issues/1383) Do not create MedusaBackup if MedusaBakupJob did not fully succeed * [ENHANCEMENT] [#1667](https://github.com/k8ssahttps://github.com/k8ssandra/k8ssandra/issues/1667) Add `skipSchemaMigration` option to `K8ssandraCluster.spec.reaper` diff --git a/apis/reaper/v1alpha1/reaper_types.go b/apis/reaper/v1alpha1/reaper_types.go index fda1feef5..ca7e8e245 100644 --- a/apis/reaper/v1alpha1/reaper_types.go +++ b/apis/reaper/v1alpha1/reaper_types.go @@ -85,10 +85,10 @@ type ReaperTemplate struct { SecretsProvider string `json:"secretsProvider,omitempty"` // The image to use for the Reaper pod main container. - // The default is "thelastpickle/cassandra-reaper:3.6.1". + // The default is "thelastpickle/cassandra-reaper:3.7.0". // +optional // TODO: update with real release version. - // +kubebuilder:default={repository:"thelastpickle",name:"cassandra-reaper",tag:"3.6.1"} + // +kubebuilder:default={repository:"thelastpickle",name:"cassandra-reaper",tag:"3.7.0"} ContainerImage *images.Image `json:"containerImage,omitempty"` // Deprecated: The main container image will be used for the init container as well. diff --git a/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml b/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml index db9f5e04b..e95dada78 100644 --- a/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml +++ b/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml @@ -27562,10 +27562,10 @@ spec: default: name: cassandra-reaper repository: thelastpickle - tag: 3.6.1 + tag: 3.7.0 description: |- The image to use for the Reaper pod main container. - The default is "thelastpickle/cassandra-reaper:3.6.1". + The default is "thelastpickle/cassandra-reaper:3.7.0". TODO: update with real release version. properties: name: @@ -33690,10 +33690,10 @@ spec: default: name: cassandra-reaper repository: thelastpickle - tag: 3.6.1 + tag: 3.7.0 description: |- The image to use for the Reaper pod main container. - The default is "thelastpickle/cassandra-reaper:3.6.1". + The default is "thelastpickle/cassandra-reaper:3.7.0". TODO: update with real release version. properties: name: diff --git a/config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml b/config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml index 4bccdf4bd..3cb1f2a13 100644 --- a/config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml +++ b/config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml @@ -27500,10 +27500,10 @@ spec: default: name: cassandra-reaper repository: thelastpickle - tag: 3.6.1 + tag: 3.7.0 description: |- The image to use for the Reaper pod main container. - The default is "thelastpickle/cassandra-reaper:3.6.1". + The default is "thelastpickle/cassandra-reaper:3.7.0". TODO: update with real release version. properties: name: diff --git a/config/crd/bases/reaper.k8ssandra.io_reapers.yaml b/config/crd/bases/reaper.k8ssandra.io_reapers.yaml index f32c358ae..19f01584e 100644 --- a/config/crd/bases/reaper.k8ssandra.io_reapers.yaml +++ b/config/crd/bases/reaper.k8ssandra.io_reapers.yaml @@ -1110,10 +1110,10 @@ spec: default: name: cassandra-reaper repository: thelastpickle - tag: 3.6.1 + tag: 3.7.0 description: |- The image to use for the Reaper pod main container. - The default is "thelastpickle/cassandra-reaper:3.6.1". + The default is "thelastpickle/cassandra-reaper:3.7.0". TODO: update with real release version. properties: name: diff --git a/pkg/reaper/deployment.go b/pkg/reaper/deployment.go index cff7af0b4..1fec39b04 100644 --- a/pkg/reaper/deployment.go +++ b/pkg/reaper/deployment.go @@ -27,7 +27,7 @@ import ( const ( DefaultImageRepository = "thelastpickle" DefaultImageName = "cassandra-reaper" - DefaultVersion = "3.6.1" + DefaultVersion = "3.7.0" // When changing the default version above, please also change the kubebuilder markers in // apis/reaper/v1alpha1/reaper_types.go accordingly. diff --git a/pkg/reaper/deployment_test.go b/pkg/reaper/deployment_test.go index 9dc08f590..7ffabc863 100644 --- a/pkg/reaper/deployment_test.go +++ b/pkg/reaper/deployment_test.go @@ -410,8 +410,8 @@ func TestImages(t *testing.T) { reaper.Spec.ContainerImage = nil logger := testlogr.NewTestLogger(t) deployment := NewDeployment(reaper, newTestDatacenter(), nil, nil, logger) - assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.6.1", deployment.Spec.Template.Spec.InitContainers[0].Image) - assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.6.1", deployment.Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.7.0", deployment.Spec.Template.Spec.InitContainers[0].Image) + assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.7.0", deployment.Spec.Template.Spec.Containers[0].Image) assert.Equal(t, corev1.PullIfNotPresent, deployment.Spec.Template.Spec.InitContainers[0].ImagePullPolicy) assert.Equal(t, corev1.PullIfNotPresent, deployment.Spec.Template.Spec.Containers[0].ImagePullPolicy) assert.Empty(t, deployment.Spec.Template.Spec.ImagePullSecrets) @@ -421,8 +421,8 @@ func TestImages(t *testing.T) { reaper.Spec.ContainerImage = nil logger := testlogr.NewTestLogger(t) deployment := NewDeployment(reaper, newTestDatacenter(), nil, nil, logger) - assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.6.1", deployment.Spec.Template.Spec.InitContainers[0].Image) - assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.6.1", deployment.Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.7.0", deployment.Spec.Template.Spec.InitContainers[0].Image) + assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.7.0", deployment.Spec.Template.Spec.Containers[0].Image) assert.Equal(t, corev1.PullIfNotPresent, deployment.Spec.Template.Spec.InitContainers[0].ImagePullPolicy) assert.Equal(t, corev1.PullIfNotPresent, deployment.Spec.Template.Spec.Containers[0].ImagePullPolicy) assert.Empty(t, deployment.Spec.Template.Spec.ImagePullSecrets) From 75c9f2314bb9b3118b58a4d17c9dcfd87a864296 Mon Sep 17 00:00:00 2001 From: Alexander Dejanovski Date: Thu, 28 Nov 2024 08:01:40 +0100 Subject: [PATCH 2/3] Upgrade CRD reference (#1464) --- .../crd/k8ssandra-operator-crds-latest/_index.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/content/en/reference/crd/k8ssandra-operator-crds-latest/_index.md b/docs/content/en/reference/crd/k8ssandra-operator-crds-latest/_index.md index 55e75c63c..83a653329 100644 --- a/docs/content/en/reference/crd/k8ssandra-operator-crds-latest/_index.md +++ b/docs/content/en/reference/crd/k8ssandra-operator-crds-latest/_index.md @@ -54718,10 +54718,10 @@ and must contain two keys: "username" and "password".
object The image to use for the Reaper pod main container. -The default is "thelastpickle/cassandra-reaper:3.6.1". +The default is "thelastpickle/cassandra-reaper:3.7.0". TODO: update with real release version.

- Default: map[name:cassandra-reaper repository:thelastpickle tag:3.6.1]
+ Default: map[name:cassandra-reaper repository:thelastpickle tag:3.7.0]
false @@ -56694,7 +56694,7 @@ TODO: Add other useful fields. apiVersion, kind, uid?
The image to use for the Reaper pod main container. -The default is "thelastpickle/cassandra-reaper:3.6.1". +The default is "thelastpickle/cassandra-reaper:3.7.0". TODO: update with real release version. @@ -84691,10 +84691,10 @@ and must contain two keys: "username" and "password".
@@ -86876,7 +86876,7 @@ TODO: Add other useful fields. apiVersion, kind, uid?
The image to use for the Reaper pod main container. -The default is "thelastpickle/cassandra-reaper:3.6.1". +The default is "thelastpickle/cassandra-reaper:3.7.0". TODO: update with real release version.
object The image to use for the Reaper pod main container. -The default is "thelastpickle/cassandra-reaper:3.6.1". +The default is "thelastpickle/cassandra-reaper:3.7.0". TODO: update with real release version.

- Default: map[name:cassandra-reaper repository:thelastpickle tag:3.6.1]
+ Default: map[name:cassandra-reaper repository:thelastpickle tag:3.7.0]
false
From d00a94bca0d3eba407036623919528628f434870 Mon Sep 17 00:00:00 2001 From: Olivier Michallat Date: Mon, 16 Dec 2024 17:42:28 -0800 Subject: [PATCH 3/3] Add support for priorityClassName (fixes #1034) (#1432) --- CHANGELOG/CHANGELOG-1.21.md | 1 + .../v1alpha1/k8ssandracluster_types.go | 4 ++ .../crds/k8ssandra-operator-crds.yaml | 8 +++ .../bases/k8ssandra.io_k8ssandraclusters.yaml | 8 +++ pkg/cassandra/datacenter.go | 1 + pkg/cassandra/datacenter_test.go | 51 +++++++++++++++++++ 6 files changed, 73 insertions(+) diff --git a/CHANGELOG/CHANGELOG-1.21.md b/CHANGELOG/CHANGELOG-1.21.md index dcd092818..ef7431b9f 100644 --- a/CHANGELOG/CHANGELOG-1.21.md +++ b/CHANGELOG/CHANGELOG-1.21.md @@ -18,3 +18,4 @@ When cutting a new release, update the `unreleased` heading to the tag being gen * [CHANGE] [#1441](https://github.com/k8ssandra/k8ssandra-operator/issues/1441) Use k8ssandra-client instead of k8ssandra-tools for CRD upgrades * [BUGFIX] [#1383](https://github.com/k8ssandra/k8ssandra-operator/issues/1383) Do not create MedusaBackup if MedusaBakupJob did not fully succeed * [ENHANCEMENT] [#1667](https://github.com/k8ssahttps://github.com/k8ssandra/k8ssandra/issues/1667) Add `skipSchemaMigration` option to `K8ssandraCluster.spec.reaper` +* [FEATURE] [#1034](https://github.com/k8ssandra/k8ssandra-operator/issues/1034) Add support for priorityClassName diff --git a/apis/k8ssandra/v1alpha1/k8ssandracluster_types.go b/apis/k8ssandra/v1alpha1/k8ssandracluster_types.go index 1c52b9056..3d71c44fa 100644 --- a/apis/k8ssandra/v1alpha1/k8ssandracluster_types.go +++ b/apis/k8ssandra/v1alpha1/k8ssandracluster_types.go @@ -425,6 +425,10 @@ type DatacenterOptions struct { // +optional PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` + // PodPriorityClassName defines the priority class name for the Cassandra pods. + // +optional + PodPriorityClassName string `json:"podPriorityClassName,omitempty"` + // ManagementApiAuth defines the authentication settings for the management API in the Cassandra pods. // +optional ManagementApiAuth *cassdcapi.ManagementApiAuthConfig `json:"managementApiAuth,omitempty"` diff --git a/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml b/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml index e95dada78..c9f76a440 100644 --- a/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml +++ b/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml @@ -9556,6 +9556,10 @@ spec: type: string type: object x-kubernetes-map-type: atomic + podPriorityClassName: + description: PodPriorityClassName defines the priority class + name for the Cassandra pods. + type: string podSecurityContext: description: PodSecurityContext defines the security context for the Cassandra pods. @@ -22018,6 +22022,10 @@ spec: configuration. This is only useful when PerNodeConfigMapRef is set. The default is "mikefarah/yq:4". type: string + podPriorityClassName: + description: PodPriorityClassName defines the priority class name + for the Cassandra pods. + type: string podSecurityContext: description: PodSecurityContext defines the security context for the Cassandra pods. diff --git a/config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml b/config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml index 3cb1f2a13..2f7151c3d 100644 --- a/config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml +++ b/config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml @@ -9494,6 +9494,10 @@ spec: type: string type: object x-kubernetes-map-type: atomic + podPriorityClassName: + description: PodPriorityClassName defines the priority class + name for the Cassandra pods. + type: string podSecurityContext: description: PodSecurityContext defines the security context for the Cassandra pods. @@ -21956,6 +21960,10 @@ spec: configuration. This is only useful when PerNodeConfigMapRef is set. The default is "mikefarah/yq:4". type: string + podPriorityClassName: + description: PodPriorityClassName defines the priority class name + for the Cassandra pods. + type: string podSecurityContext: description: PodSecurityContext defines the security context for the Cassandra pods. diff --git a/pkg/cassandra/datacenter.go b/pkg/cassandra/datacenter.go index 78d24dd6b..74cf72d4a 100644 --- a/pkg/cassandra/datacenter.go +++ b/pkg/cassandra/datacenter.go @@ -374,6 +374,7 @@ func Coalesce(clusterName string, clusterTemplate *api.CassandraClusterTemplate, dcConfig.DseWorkloads = mergedOptions.DseWorkloads dcConfig.ManagementApiAuth = mergedOptions.ManagementApiAuth dcConfig.PodTemplateSpec.Spec.SecurityContext = mergedOptions.PodSecurityContext + dcConfig.PodTemplateSpec.Spec.PriorityClassName = mergedOptions.PodPriorityClassName dcConfig.PerNodeInitContainerImage = mergedOptions.PerNodeConfigInitContainerImage dcConfig.ServiceAccount = mergedOptions.ServiceAccount dcConfig.ReadOnlyRootFilesystem = mergedOptions.ReadOnlyRootFilesystem diff --git a/pkg/cassandra/datacenter_test.go b/pkg/cassandra/datacenter_test.go index 3dea22812..2cdf18be3 100644 --- a/pkg/cassandra/datacenter_test.go +++ b/pkg/cassandra/datacenter_test.go @@ -1281,6 +1281,46 @@ func TestCoalesce(t *testing.T) { }, }, }, + { + name: "Set priority class name at cluster level", + clusterTemplate: &api.CassandraClusterTemplate{ + DatacenterOptions: api.DatacenterOptions{ + PodPriorityClassName: "mock-priority", + }, + }, + dcTemplate: &api.CassandraDatacenterTemplate{}, + want: &DatacenterConfig{ + McacEnabled: true, + PodTemplateSpec: corev1.PodTemplateSpec{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{Name: "cassandra"}}, + PriorityClassName: "mock-priority", + }, + }, + }, + }, + { + name: "Override priority class name", + clusterTemplate: &api.CassandraClusterTemplate{ + DatacenterOptions: api.DatacenterOptions{ + PodPriorityClassName: "ignored-priority", + }, + }, + dcTemplate: &api.CassandraDatacenterTemplate{ + DatacenterOptions: api.DatacenterOptions{ + PodPriorityClassName: "mock-priority", + }, + }, + want: &DatacenterConfig{ + McacEnabled: true, + PodTemplateSpec: corev1.PodTemplateSpec{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{Name: "cassandra"}}, + PriorityClassName: "mock-priority", + }, + }, + }, + }, } for _, tc := range tests { @@ -1376,6 +1416,17 @@ func TestNewDatacenter_ServiceAccount(t *testing.T) { assert.Equal(t, template.ServiceAccount, dc.Spec.ServiceAccountName) } +func TestNewDatacenter_PodPriorityClassName(t *testing.T) { + template := GetDatacenterConfig() + template.PodTemplateSpec.Spec.PriorityClassName = "mock-priority" + dc, err := NewDatacenter( + types.NamespacedName{Name: "testdc", Namespace: "test-namespace"}, + &template, + ) + assert.NoError(t, err) + assert.Equal(t, "mock-priority", dc.Spec.PodTemplateSpec.Spec.PriorityClassName) +} + // TestValidateCoalesced_Fail_NoStorageConfig tests that NewDatacenter fails when no storage config is provided. func TestValidateDatacenterConfig_Fail_NoStorageConfig(t *testing.T) { template := GetDatacenterConfig()