From a8af6d0bafefa389b8810f372180f0ecd6ed7240 Mon Sep 17 00:00:00 2001 From: Michael Burman Date: Wed, 27 Nov 2024 19:33:18 +0200 Subject: [PATCH] Logging --- controllers/k8ssandra/schemas.go | 1 + test/e2e/medusa_test.go | 6 +++--- test/e2e/per_node_config_test.go | 2 +- test/e2e/suite_test.go | 7 ++++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/controllers/k8ssandra/schemas.go b/controllers/k8ssandra/schemas.go index 94cce2088..3c32c8866 100644 --- a/controllers/k8ssandra/schemas.go +++ b/controllers/k8ssandra/schemas.go @@ -266,6 +266,7 @@ func (r *K8ssandraClusterReconciler) checkUserKeyspacesReplicationForDecommissio if err != nil { return result.Error(fmt.Errorf("failed to get replication for keyspace (%s): %v", ks, err)) } + logger.Info("checking keyspace replication", "keyspace", ks, "replication", replication, "decommissioning_dc", decommDc) if _, hasReplicas := replication[decommDc]; hasReplicas { return result.Error(fmt.Errorf("cannot decommission DC %s: keyspace %s still has replicas on it", decommDc, ks)) } diff --git a/test/e2e/medusa_test.go b/test/e2e/medusa_test.go index bc130fe3e..334d7c468 100644 --- a/test/e2e/medusa_test.go +++ b/test/e2e/medusa_test.go @@ -190,7 +190,7 @@ func checkPurgeCronJobExists(t *testing.T, ctx context.Context, namespace string t.Log("Checking that the purge Cron Job exists") // check that the cronjob exists cronJob := &batchv1.CronJob{} - err = f.Get(ctx, framework.NewClusterKey(dcKey.K8sContext, namespace, medusapkg.MedusaPurgeCronJobName(kc.SanitizedName(), dc1.LabelResourceName())), cronJob) + err = f.Get(ctx, framework.NewClusterKey(dcKey.K8sContext, namespace, medusapkg.MedusaPurgeCronJobName(kc.SanitizedName(), dc1.DatacenterName())), cronJob) require.NoErrorf(err, "Error getting the Medusa purge CronJob. ClusterName: %s, DatacenterName: %s", kc.SanitizedName(), dc1.LabelResourceName()) require.Equal("k8ssandra-operator", cronJob.Spec.JobTemplate.Spec.Template.Spec.ServiceAccountName, "Service account name is not correct") // create a Job from the cronjob spec @@ -224,7 +224,7 @@ func checkNoPurgeCronJob(t *testing.T, ctx context.Context, namespace string, dc require.NoError(err, "Error getting the CassandraDatacenter") // ensure the cronjob was not created cronJob := &batchv1.CronJob{} - err = f.Get(ctx, framework.NewClusterKey(dcKey.K8sContext, namespace, medusapkg.MedusaPurgeCronJobName(kc.SanitizedName(), dc1.LabelResourceName())), cronJob) + err = f.Get(ctx, framework.NewClusterKey(dcKey.K8sContext, namespace, medusapkg.MedusaPurgeCronJobName(kc.SanitizedName(), dc1.DatacenterName())), cronJob) require.Error(err, "Cronjob should not exist") } @@ -239,7 +239,7 @@ func checkPurgeCronJobDeleted(t *testing.T, ctx context.Context, namespace strin require.Eventually(func() bool { // ensure the cronjob was deleted cronJob := &batchv1.CronJob{} - err = f.Get(ctx, framework.NewClusterKey(dcKey.K8sContext, namespace, medusapkg.MedusaPurgeCronJobName(kc.SanitizedName(), dc1.LabelResourceName())), cronJob) + err = f.Get(ctx, framework.NewClusterKey(dcKey.K8sContext, namespace, medusapkg.MedusaPurgeCronJobName(kc.SanitizedName(), dc1.DatacenterName())), cronJob) return errors.IsNotFound(err) }, polling.medusaBackupDone.timeout, polling.medusaBackupDone.interval, "Medusa purge CronJob wasn't deleted within timeout") } diff --git a/test/e2e/per_node_config_test.go b/test/e2e/per_node_config_test.go index ebf0628b7..81c544b61 100644 --- a/test/e2e/per_node_config_test.go +++ b/test/e2e/per_node_config_test.go @@ -32,7 +32,7 @@ func multiDcInitialTokens(t *testing.T, ctx context.Context, namespace string, f checkDatacenterReady(t, ctx, dc2Key, f) assertCassandraDatacenterK8cStatusReady(ctx, t, f, kcKey, dc2Key.Name) - dc2Prefix := DcPrefixOverride(t, f, dc2Key) + dc2Prefix := DcPrefix(t, f, dc2Key) t.Log("check that the ConfigMaps were created") diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index f60e9b9c0..50703189e 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -803,7 +803,7 @@ func createSingleDatacenterCluster(t *testing.T, ctx context.Context, namespace // Check that the Cassandra cluster name override is passed to the cassdc without being modified checkCassandraClusterName(t, ctx, k8ssandra, dcKey, f) assertCassandraDatacenterK8cStatusReady(ctx, t, f, kcKey, dcKey.Name) - dcPrefix := DcPrefix(t, f, dcKey) + dcPrefix := DcPrefixOverride(t, f, dcKey) require.NoError(checkMetricsFiltersAbsence(t, ctx, f, dcKey)) require.NoError(checkInjectedContainersPresence(t, ctx, f, dcKey)) require.NoError(checkInjectedVolumePresence(t, ctx, f, dcKey, 4)) @@ -1493,7 +1493,7 @@ func removeDcFromCluster(t *testing.T, ctx context.Context, namespace string, f err = f.Client.Get(ctx, kcKey, kc) require.NoError(err, "failed to get K8ssandraCluster %s", kcKey) return kc.Status.Error != "None" && strings.Contains(kc.Status.Error, fmt.Sprintf("cannot decommission DC %s", dc2Name)) - }, 5*time.Minute, 5*time.Second, "timed out waiting for an error on dc2 removal") + }, 5*time.Minute, 1*time.Second, "timed out waiting for an error on dc2 removal") t.Log("alter keyspaces to remove replicas from DC2") _, err = f.ExecuteCql(ctx, f.DataPlaneContexts[0], namespace, kc.SanitizedName(), DcPrefix(t, f, dc1Key)+"-default-sts-0", @@ -1626,6 +1626,7 @@ func checkStargateApisWithMultiDcCluster(t *testing.T, ctx context.Context, name }, polling.k8ssandraClusterStatus.timeout, polling.k8ssandraClusterStatus.interval) dc2Prefix := DcPrefixOverride(t, f, dc2Key) + dc2PodPrefix := DcPrefix(t, f, dc2Key) stargateKey = framework.ClusterKey{K8sContext: f.DataPlaneContexts[1], NamespacedName: types.NamespacedName{Namespace: namespace, Name: dc2Prefix + "-stargate"}} checkStargateReady(t, f, ctx, stargateKey) @@ -1667,7 +1668,7 @@ func checkStargateApisWithMultiDcCluster(t *testing.T, ctx context.Context, name assert.NoError(t, err, "timed out waiting for nodetool status check against "+pod) t.Log("check nodes in dc2 see nodes in dc1") - pod = dc2Prefix + "-rack1-sts-0" + pod = dc2PodPrefix + "-rack1-sts-0" checkNodeToolStatus(t, f, f.DataPlaneContexts[1], namespace, pod, count, 0, "-u", username, "-pw", password) assert.NoError(t, err, "timed out waiting for nodetool status check against "+pod)