Skip to content

Commit

Permalink
Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
burmanm committed Nov 27, 2024
1 parent fb7cd5b commit a8af6d0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions controllers/k8ssandra/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/medusa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}

Expand All @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/per_node_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
7 changes: 4 additions & 3 deletions test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a8af6d0

Please sign in to comment.