Skip to content

Commit

Permalink
Don't use DC name override when naming resources
Browse files Browse the repository at this point in the history
  • Loading branch information
olim7t committed Mar 15, 2024
1 parent 811b78c commit a43fdab
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion controllers/k8ssandra/cassandra_telemetry_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (r *K8ssandraClusterReconciler) reconcileCassandraDCTelemetry(
cfg := telemetry.PrometheusResourcer{
MonitoringTargetNS: actualDc.Namespace,
MonitoringTargetName: actualDc.Name,
ServiceMonitorName: kc.SanitizedName() + "-" + actualDc.DatacenterName() + "-" + "cass-servicemonitor",
ServiceMonitorName: kc.SanitizedName() + "-" + actualDc.Name + "-" + "cass-servicemonitor",
Logger: logger,
CommonLabels: mustLabels(kc.Name, kc.Namespace, actualDc.DatacenterName(), commonLabels),
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/k8ssandra/datacenters.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (r *K8ssandraClusterReconciler) reconcileDatacenters(ctx context.Context, k
Kluster: kc,
RequeueDelay: r.DefaultDelay,
DcNamespace: desiredDc.Namespace,
DcName: desiredDc.DatacenterName(),
DcName: desiredDc.Name,
}
agentRes := agentCfg.ReconcileTelemetryAgentConfig(desiredDc)
if agentRes.IsRequeue() {
Expand Down
2 changes: 1 addition & 1 deletion controllers/k8ssandra/k8ssandracluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (r *K8ssandraClusterReconciler) afterCassandraReconciled(ctx context.Contex
dc := dcs[i]
dcKey := utils.GetKey(dc)
logger := logger.WithValues("CassandraDatacenter", dcKey)
logger.Info("Reconciling Stargate and Reaper for dc " + dc.DatacenterName())
logger.Info("Reconciling Stargate and Reaper for dc " + dc.Name)
if remoteClient, err := r.ClientCache.GetRemoteClient(dcTemplate.K8sContext); err != nil {
logger.Error(err, "Failed to get remote client")
return result.Error(err)
Expand Down
4 changes: 2 additions & 2 deletions controllers/k8ssandra/reaper.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (r *K8ssandraClusterReconciler) reconcileReaper(
if reaperTemplate != nil {
reaperTemplate.SecretsProvider = kc.Spec.SecretsProvider

logger.Info("Reaper present for DC " + actualDc.DatacenterName())
logger.Info("Reaper present for DC " + actualDc.Name)

desiredReaper, err := reaper.NewReaper(reaperKey, kc, actualDc, reaperTemplate, logger)

Expand Down Expand Up @@ -155,7 +155,7 @@ func (r *K8ssandraClusterReconciler) reconcileReaper(

} else {

logger.Info("Reaper not present for DC " + actualDc.DatacenterName())
logger.Info("Reaper not present for DC " + actualDc.Name)

// Test if Reaper was removed
if err := remoteClient.Get(ctx, reaperKey, actualReaper); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion controllers/reaper/vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (r *ReaperReconciler) reconcileVectorConfigMap(
namespace := reaper.Namespace
configMapKey := client.ObjectKey{
Namespace: namespace,
Name: reaperpkg.VectorAgentConfigMapName(actualDc.Spec.ClusterName, actualDc.DatacenterName()),
Name: reaperpkg.VectorAgentConfigMapName(actualDc.Spec.ClusterName, actualDc.Name),
}
if reaper.Spec.Telemetry.IsVectorEnabled() {
// Create the vector toml config content
Expand Down
2 changes: 1 addition & 1 deletion controllers/stargate/stargate_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ func (r *StargateReconciler) reconcileStargateConfigMap(

configMapKey := client.ObjectKey{
Namespace: namespace,
Name: stargate.GeneratedConfigMapName(dc.Spec.ClusterName, dc.DatacenterName()),
Name: stargate.GeneratedConfigMapName(dc.Spec.ClusterName, dc.Name),
}

logger = logger.WithValues("StargateConfigMap", configMapKey)
Expand Down
2 changes: 1 addition & 1 deletion controllers/stargate/vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (r *StargateReconciler) reconcileVectorConfigMap(
namespace := stargate.Namespace
configMapKey := client.ObjectKey{
Namespace: namespace,
Name: stargatepkg.VectorAgentConfigMapName(actualDc.Spec.ClusterName, actualDc.DatacenterName()),
Name: stargatepkg.VectorAgentConfigMapName(actualDc.Spec.ClusterName, actualDc.Name),
}
if stargate.Spec.Telemetry.IsVectorEnabled() {
// Create the vector toml config content
Expand Down
2 changes: 1 addition & 1 deletion pkg/medusa/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func GetCassandraDatacenterPods(ctx context.Context, cassdc *cassdcapi.Cassandra
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())
logger.Error(err, "failed to get pods for cassandradatacenter", "CassandraDatacenter", cassdc.Name)
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/reaper/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
// DefaultResourceName generates a name for a new Reaper resource that is derived from the Cassandra cluster and DC
// names.
func DefaultResourceName(dc *cassdcapi.CassandraDatacenter) string {
return cassdcapi.CleanupForKubernetes(dc.Spec.ClusterName + "-" + dc.DatacenterName() + "-reaper")
return cassdcapi.CleanupForKubernetes(dc.Spec.ClusterName + "-" + dc.Name + "-reaper")
}

func NewReaper(
Expand Down
4 changes: 2 additions & 2 deletions pkg/reaper/vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func VectorAgentConfigMapName(clusterName, dcName string) string {
func CreateVectorConfigMap(namespace, vectorToml string, dc cassdcapi.CassandraDatacenter) *corev1.ConfigMap {
return &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: VectorAgentConfigMapName(dc.Spec.ClusterName, dc.DatacenterName()),
Name: VectorAgentConfigMapName(dc.Spec.ClusterName, dc.Name),
Namespace: namespace,
Labels: utils.MergeMap(
map[string]string{
Expand Down Expand Up @@ -78,7 +78,7 @@ func configureVector(reaper *api.Reaper, deployment *appsv1.Deployment, dc *cass
Name: "reaper-vector-config",
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{Name: VectorAgentConfigMapName(dc.Spec.ClusterName, dc.DatacenterName())},
LocalObjectReference: corev1.LocalObjectReference{Name: VectorAgentConfigMapName(dc.Spec.ClusterName, dc.Name)},
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/stargate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func FilterConfig(config map[string]interface{}, retainedSettings []string) map[
func CreateStargateConfigMap(namespace, cassandraYaml, stargateCqlYaml string, dc cassdcapi.CassandraDatacenter) *corev1.ConfigMap {
return &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: GeneratedConfigMapName(dc.Spec.ClusterName, dc.DatacenterName()),
Name: GeneratedConfigMapName(dc.Spec.ClusterName, dc.Name),
Namespace: namespace,
Labels: utils.MergeMap(
map[string]string{
Expand Down
2 changes: 1 addition & 1 deletion pkg/stargate/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func computeVolumes(template *api.StargateTemplate, dc *cassdcapi.CassandraDatac
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: GeneratedConfigMapName(dc.Spec.ClusterName, dc.DatacenterName()),
Name: GeneratedConfigMapName(dc.Spec.ClusterName, dc.Name),
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/stargate/stargate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import (
)

func ResourceName(dc *cassdcapi.CassandraDatacenter) string {
return cassdcapi.CleanupForKubernetes(dc.Spec.ClusterName + "-" + dc.DatacenterName() + "-stargate")
return cassdcapi.CleanupForKubernetes(dc.Spec.ClusterName + "-" + dc.Name + "-stargate")
}

func ServiceName(dc *cassdcapi.CassandraDatacenter) string {
return cassdcapi.CleanupForKubernetes(dc.Spec.ClusterName + "-" + dc.DatacenterName() + "-stargate-service")
return cassdcapi.CleanupForKubernetes(dc.Spec.ClusterName + "-" + dc.Name + "-stargate-service")
}

func DeploymentName(dc *cassdcapi.CassandraDatacenter, rack *cassdcapi.Rack) string {
return cassdcapi.CleanupForKubernetes(dc.Spec.ClusterName + "-" + dc.DatacenterName() + "-" + rack.Name + "-stargate-deployment")
return cassdcapi.CleanupForKubernetes(dc.Spec.ClusterName + "-" + dc.Name + "-" + rack.Name + "-stargate-deployment")
}

func NewStargate(
Expand Down
4 changes: 2 additions & 2 deletions pkg/stargate/vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func VectorAgentConfigMapName(clusterName, dcName string) string {
func CreateVectorConfigMap(namespace, vectorToml string, dc cassdcapi.CassandraDatacenter) *corev1.ConfigMap {
return &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: VectorAgentConfigMapName(dc.Spec.ClusterName, dc.DatacenterName()),
Name: VectorAgentConfigMapName(dc.Spec.ClusterName, dc.Name),
Namespace: namespace,
Labels: utils.MergeMap(
map[string]string{
Expand Down Expand Up @@ -78,7 +78,7 @@ func configureVector(stargate *api.Stargate, deployment *appsv1.Deployment, dc *
Name: "stargate-vector-config",
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{Name: VectorAgentConfigMapName(dc.Spec.ClusterName, dc.DatacenterName())},
LocalObjectReference: corev1.LocalObjectReference{Name: VectorAgentConfigMapName(dc.Spec.ClusterName, dc.Name)},
},
},
}
Expand Down

0 comments on commit a43fdab

Please sign in to comment.