Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cluster label to Medusa controllers selectors when listing pods #1133

Merged
merged 5 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/kind_e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG/CHANGELOG-1.11.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion pkg/medusa/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion pkg/medusa/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions test/e2e/medusa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +1 to +17
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to create those secrets because using default secrets seems to create a race condition where they will be deleted upon deletion of the K8ssandraCluster objects before the cassdc objects are deleted, but then cass-operator complains that the secrets are missing and cannot run its finalizers.

---
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- k8ssandra.yaml
Loading