Skip to content

Commit

Permalink
Fix configmap name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Miles-Garnsey committed Jan 27, 2023
1 parent ea102ac commit e910a8a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions controllers/k8ssandra/cassandra_metrics_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ func createSingleDcClusterWithMetricsAgent(t *testing.T, ctx context.Context, f
}

// check that we have the right ConfigMap
agentCmKey := types.NamespacedName{Name: "test" + "metrics-agent-config", Namespace: namespace}
agentCmKey := types.NamespacedName{Name: "test" + "-metrics-agent-config", Namespace: namespace}
agentCm := corev1.ConfigMap{}
if err := f.Client.Get(ctx, agentCmKey, &agentCm); err != nil {
assert.Fail(t, "could not find expected metrics-agent-config configmap")
}

// Test cluster deletion
// Test cluster deletion, ensuring configmap deleted too.
t.Log("deleting K8ssandraCluster")
err = f.DeleteK8ssandraCluster(ctx, client.ObjectKey{Namespace: namespace, Name: kc.Name}, timeout, interval)
require.NoError(err, "failed to delete K8ssandraCluster")
Expand Down
4 changes: 2 additions & 2 deletions pkg/telemetry/cassandra_agent/cassandra_agent_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (c Configurator) GetTelemetryAgentConfigMap() (*corev1.ConfigMap, error) {
cm := corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: c.Kluster.Namespace,
Name: c.Kluster.Name + "metrics-agent-config",
Name: c.Kluster.Name + "-metrics-agent-config",
},
Data: map[string]string{filepath.Base(agentConfigLocation): string(yamlData)},
}
Expand All @@ -53,7 +53,7 @@ func (c Configurator) ReconcileTelemetryAgentConfig(dc *cassdcapi.CassandraDatac
if err != nil {
return result.Error(err)
}
cmObjectKey := types.NamespacedName{Name: c.Kluster.Name + "metrics-agent-config",
cmObjectKey := types.NamespacedName{Name: c.Kluster.Name + "-metrics-agent-config",
Namespace: c.Kluster.Namespace}
annotations.AddHashAnnotation(desiredCm)
labels.SetManagedBy(desiredCm, cmObjectKey)
Expand Down
8 changes: 4 additions & 4 deletions pkg/telemetry/cassandra_agent/cassandra_agent_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func getExpectedConfigMap() corev1.ConfigMap {
expectedCm := corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: Cfg.Kluster.Namespace,
Name: Cfg.Kluster.Name + "metrics-agent-config",
Name: Cfg.Kluster.Name + "-metrics-agent-config",
},
Data: map[string]string{filepath.Base(agentConfigLocation): expectedYaml},
}
Expand Down Expand Up @@ -115,7 +115,7 @@ func Test_ReconcileTelemetryAgentConfig_CMCreateSuccess(t *testing.T) {
recRes := Cfg.ReconcileTelemetryAgentConfig(&dc)
assert.True(t, recRes.IsRequeue())
actualCm := &corev1.ConfigMap{}
err := Cfg.RemoteClient.Get(Cfg.Ctx, types.NamespacedName{Name: Cfg.Kluster.Name + "metrics-agent-config", Namespace: Cfg.Kluster.Namespace}, actualCm)
err := Cfg.RemoteClient.Get(Cfg.Ctx, types.NamespacedName{Name: Cfg.Kluster.Name + "-metrics-agent-config", Namespace: Cfg.Kluster.Namespace}, actualCm)
assert.NoError(t, err)
}
func Test_ReconcileTelemetryAgentConfig_CMCreateFailed(t *testing.T) {
Expand Down Expand Up @@ -146,7 +146,7 @@ func Test_ReconcileTelemetryAgentConfig_CMUpdateSuccess(t *testing.T) {
// After the update we should see the expected ConfigMap
afterUpdateCM := &corev1.ConfigMap{}
err = Cfg.RemoteClient.Get(Cfg.Ctx,
types.NamespacedName{Name: Cfg.Kluster.Name + "metrics-agent-config", Namespace: Cfg.Kluster.Namespace},
types.NamespacedName{Name: Cfg.Kluster.Name + "-metrics-agent-config", Namespace: Cfg.Kluster.Namespace},
afterUpdateCM)
assert.NoError(t, err)

Expand All @@ -166,7 +166,7 @@ func Test_ReconcileTelemetryAgentConfig_CMUpdateDone(t *testing.T) {
// After the update we should see the expected ConfigMap
afterUpdateCM := &corev1.ConfigMap{}
err := Cfg.RemoteClient.Get(Cfg.Ctx,
types.NamespacedName{Name: Cfg.Kluster.Name + "metrics-agent-config", Namespace: Cfg.Kluster.Namespace},
types.NamespacedName{Name: Cfg.Kluster.Name + "-metrics-agent-config", Namespace: Cfg.Kluster.Namespace},
afterUpdateCM)
assert.NoError(t, err)
// If we reconcile again, we should move into the Done state.
Expand Down

0 comments on commit e910a8a

Please sign in to comment.