diff --git a/.github/workflows/kind_e2e_tests.yaml b/.github/workflows/kind_e2e_tests.yaml index 4b48a886a..6905d6645 100644 --- a/.github/workflows/kind_e2e_tests.yaml +++ b/.github/workflows/kind_e2e_tests.yaml @@ -83,6 +83,7 @@ jobs: - CreateSingleReaperWStargateAndHTTP - CreateReaperAndDatacenter - CreateSingleMedusaJob + - CreateMultiDcSingleMedusaJob - CreateSingleDseMedusaJob - ConfigControllerRestarts # TODO: these e2e tests started breaking after new client certificates were added. Needs fixing. diff --git a/CHANGELOG/CHANGELOG-1.11.md b/CHANGELOG/CHANGELOG-1.11.md index 9bea56599..cad56e512 100644 --- a/CHANGELOG/CHANGELOG-1.11.md +++ b/CHANGELOG/CHANGELOG-1.11.md @@ -19,4 +19,5 @@ When cutting a new release, update the `unreleased` heading to the tag being gen * [FEATURE] [#659](https://github.com/thelastpickle/cassandra-medusa/issues/659) Add support for DSE search * [ENHANCEMENT] [#1125](https://github.com/k8ssandra/k8ssandra-operator/issues/1125) Support Stargate with DSE and upgrade Stargate to 1.0.77 * [ENHANCEMENT] [#1122](https://github.com/k8ssandra/k8ssandra-operator/issues/1122) Expose backup size in MedusaBackup CRD -* [BUGFIX] [#1145](https://github.com/k8ssandra/k8ssandra-operator/issues/1145) Add missing MutatingWebhook configuration to the Helm chart +* [BUGFIX] [#1145](https://github.com/k8ssandra/k8ssandra-operator/issues/1145) Add missing MutatingWebhook configuration to the Helm chart +* [BUGFIX] [#1132](https://github.com/k8ssandra/k8ssandra-operator/issues/1132) Fix mismatch between Cassandra pods from different cluster when running backup ops diff --git a/pkg/medusa/reconcile.go b/pkg/medusa/reconcile.go index ab0c891ce..819de19a3 100644 --- a/pkg/medusa/reconcile.go +++ b/pkg/medusa/reconcile.go @@ -24,7 +24,6 @@ import ( const ( DefaultMedusaImageRepository = "k8ssandra" DefaultMedusaImageName = "medusa" - // DefaultMedusaVersion pins to an unreleased version to be compatible. will revert back to a release version once we have it DefaultMedusaVersion = "0.17.0" DefaultMedusaPort = 50051 DefaultProbeInitialDelay = 10 diff --git a/pkg/medusa/utils.go b/pkg/medusa/utils.go index 420d13120..cc04907a2 100644 --- a/pkg/medusa/utils.go +++ b/pkg/medusa/utils.go @@ -12,7 +12,10 @@ import ( func GetCassandraDatacenterPods(ctx context.Context, cassdc *cassdcapi.CassandraDatacenter, r client.Reader, logger logr.Logger) ([]corev1.Pod, error) { podList := &corev1.PodList{} - labels := client.MatchingLabels{cassdcapi.DatacenterLabel: cassdc.DatacenterName()} + labels := client.MatchingLabels{ + cassdcapi.ClusterLabel: cassdcapi.CleanLabelValue(cassdc.Spec.ClusterName), + cassdcapi.DatacenterLabel: cassdc.DatacenterName(), + } if err := r.List(ctx, podList, labels, client.InNamespace(cassdc.Namespace)); err != nil { logger.Error(err, "failed to get pods for cassandradatacenter", "CassandraDatacenter", cassdc.DatacenterName()) return nil, err diff --git a/test/e2e/medusa_test.go b/test/e2e/medusa_test.go index d50f28b79..9f4403462 100644 --- a/test/e2e/medusa_test.go +++ b/test/e2e/medusa_test.go @@ -91,6 +91,22 @@ func createMultiMedusaJob(t *testing.T, ctx context.Context, namespace string, f } } +func createMultiDcSingleMedusaJob(t *testing.T, ctx context.Context, namespace string, f *framework.E2eFramework) { + require := require.New(t) + cluster2Name := "cluster2" + kc2Key := framework.ClusterKey{K8sContext: "kind-k8ssandra-0", NamespacedName: types.NamespacedName{Namespace: namespace, Name: cluster2Name}} + kc := &api.K8ssandraCluster{} + err := f.Get(ctx, kc2Key, kc) + require.NoError(err, "Error getting the K8ssandraCluster") + dcKey := framework.ClusterKey{K8sContext: "kind-k8ssandra-0", NamespacedName: types.NamespacedName{Namespace: namespace, Name: "cluster2-dc1"}} + backupKey := types.NamespacedName{Namespace: namespace, Name: backupName} + + checkDatacenterReady(t, ctx, dcKey, f) + checkMedusaContainersExist(t, ctx, namespace, dcKey, f, kc) + createBackupJob(t, ctx, namespace, f, dcKey) + verifyBackupJobFinished(t, ctx, f, dcKey, backupKey) +} + func checkMedusaContainersExist(t *testing.T, ctx context.Context, namespace string, dcKey framework.ClusterKey, f *framework.E2eFramework, kc *api.K8ssandraCluster) { require := require.New(t) // Get the Cassandra pod diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index 7db9e5761..5141893e2 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -285,6 +285,13 @@ func TestOperator(t *testing.T) { doCassandraDatacenterCleanup: false, installMinio: true, })) + t.Run("CreateMultiDcSingleMedusaJob", e2eTest(ctx, &e2eTestOpts{ + testFunc: createMultiDcSingleMedusaJob, + fixture: framework.NewTestFixture("single-dc-multi-cluster-medusa", controlPlane), + skipK8ssandraClusterCleanup: false, + doCassandraDatacenterCleanup: false, + installMinio: true, + })) t.Run("CreateSingleDseMedusaJob", e2eTest(ctx, &e2eTestOpts{ testFunc: createSingleMedusaJob, fixture: framework.NewTestFixture("single-dc-dse-medusa", controlPlane), diff --git a/test/testdata/fixtures/single-dc-multi-cluster-medusa/k8ssandra.yaml b/test/testdata/fixtures/single-dc-multi-cluster-medusa/k8ssandra.yaml new file mode 100644 index 000000000..6d80d2f5d --- /dev/null +++ b/test/testdata/fixtures/single-dc-multi-cluster-medusa/k8ssandra.yaml @@ -0,0 +1,81 @@ +apiVersion: v1 +kind: Secret +metadata: + name: cluster2-medusa +data: + password: MjdrdU5adHQ3Q1YxYjJCWlZuN2c= + username: Y2x1c3RlcjItbWVkdXNh +type: Opaque +--- +apiVersion: v1 +kind: Secret +metadata: + name: cluster2-superuser +data: + password: dGVzdGVycw== + username: dGVzdDJAdGVzdC5jb20= +type: Opaque +--- +apiVersion: k8ssandra.io/v1alpha1 +kind: K8ssandraCluster +metadata: + name: cluster1 +spec: + cassandra: + serverVersion: 4.0.11 + datacenters: + - metadata: + name: cluster1-dc1 + datacenterName: dc1 + k8sContext: kind-k8ssandra-0 + size: 2 + storageConfig: + cassandraDataVolumeClaimSpec: + storageClassName: standard + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi + config: + jvmOptions: + heapSize: 512Mi +--- +apiVersion: k8ssandra.io/v1alpha1 +kind: K8ssandraCluster +metadata: + name: cluster2 +spec: + cassandra: + serverVersion: 4.0.11 + superuserSecretRef: + name: cluster2-superuser + datacenters: + - metadata: + name: cluster2-dc1 + datacenterName: dc1 + k8sContext: kind-k8ssandra-0 + size: 2 + storageConfig: + cassandraDataVolumeClaimSpec: + storageClassName: standard + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi + config: + jvmOptions: + heapSize: 512Mi + medusa: + cassandraUserSecretRef: + name: cluster2-medusa + storageProperties: + storageProvider: s3_compatible + bucketName: k8ssandra-medusa + prefix: test + storageSecretRef: + name: medusa-bucket-key + host: minio-service.minio.svc.cluster.local + port: 9000 + secure: false diff --git a/test/testdata/fixtures/single-dc-multi-cluster-medusa/kustomization.yaml b/test/testdata/fixtures/single-dc-multi-cluster-medusa/kustomization.yaml new file mode 100644 index 000000000..2ac1a3634 --- /dev/null +++ b/test/testdata/fixtures/single-dc-multi-cluster-medusa/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - k8ssandra.yaml