Skip to content

Commit

Permalink
Return DcPrefix since it was used for resource names also, some more …
Browse files Browse the repository at this point in the history
…label changes
  • Loading branch information
burmanm committed Nov 27, 2024
1 parent dbd4390 commit 08fc5e1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 24 deletions.
2 changes: 1 addition & 1 deletion controllers/k8ssandra/seeds.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (r *K8ssandraClusterReconciler) findSeeds(ctx context.Context, kc *api.K8ss
list := &corev1.PodList{}
selector := map[string]string{
cassdcapi.ClusterLabel: cassdcapi.CleanLabelValue(cassClusterName),
cassdcapi.DatacenterLabel: dcTemplate.CassDcName(),
cassdcapi.DatacenterLabel: dcTemplate.Meta.Name,
cassdcapi.SeedNodeLabel: "true",
}

Expand Down
5 changes: 1 addition & 4 deletions controllers/medusa/medusabackupjob_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,7 @@ func createDatacenterPods(t *testing.T, f *framework.Framework, ctx context.Cont
ObjectMeta: metav1.ObjectMeta{
Namespace: dc.Namespace,
Name: podName,
Labels: map[string]string{
cassdcapi.ClusterLabel: cassdcapi.CleanLabelValue(dc.Spec.ClusterName),
cassdcapi.DatacenterLabel: dc.Name,
},
Labels: dc.GetDatacenterLabels(),
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
Expand Down
17 changes: 6 additions & 11 deletions controllers/reaper/reaper_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package reaper

import (
"context"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/utils/ptr"
"testing"
"time"

"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/utils/ptr"

cassdcapi "github.com/k8ssandra/cass-operator/apis/cassandra/v1beta1"
k8ssandraapi "github.com/k8ssandra/k8ssandra-operator/apis/k8ssandra/v1alpha1"
reaperapi "github.com/k8ssandra/k8ssandra-operator/apis/reaper/v1alpha1"
Expand Down Expand Up @@ -131,10 +132,7 @@ func beforeTest(t *testing.T, ctx context.Context, k8sClient client.Client, test
ObjectMeta: metav1.ObjectMeta{
Name: "test-cassdc-pod1",
Namespace: testNamespace,
Labels: map[string]string{
cassdcapi.ClusterLabel: cassdcapi.CleanLabelValue(cassandraClusterName),
cassdcapi.DatacenterLabel: cassandraDatacenterName,
},
Labels: cassdc.GetDatacenterLabels(),
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{{
Expand Down Expand Up @@ -162,11 +160,8 @@ func beforeTest(t *testing.T, ctx context.Context, k8sClient client.Client, test
Namespace: testNamespace,
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{{Name: "mgmt-api-http", Port: int32(8080)}},
Selector: map[string]string{
cassdcapi.ClusterLabel: cassdcapi.CleanLabelValue(cassandraClusterName),
cassdcapi.DatacenterLabel: cassandraDatacenterName,
},
Ports: []corev1.ServicePort{{Name: "mgmt-api-http", Port: int32(8080)}},
Selector: cassdc.GetDatacenterLabels(),
},
}
err = k8sClient.Create(ctx, service)
Expand Down
4 changes: 1 addition & 3 deletions pkg/cassandra/management.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ func (r *defaultManagementApiFacade) CreateKeyspaceIfNotExists(

func (r *defaultManagementApiFacade) fetchDatacenterPods() ([]corev1.Pod, error) {
podList := &corev1.PodList{}
labels := client.MatchingLabels{
cassdcapi.DatacenterLabel: cassdcapi.CleanLabelValue(r.dc.Name),
cassdcapi.ClusterLabel: cassdcapi.CleanLabelValue(r.dc.Spec.ClusterName)}
labels := client.MatchingLabels(r.dc.GetDatacenterLabels())
if err := r.k8sClient.List(r.ctx, podList, labels); err != nil {
return nil, err
} else {
Expand Down
5 changes: 1 addition & 4 deletions pkg/medusa/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ 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.ClusterLabel: cassdcapi.CleanLabelValue(cassdc.Spec.ClusterName),
cassdcapi.DatacenterLabel: cassdc.Name,
}
labels := client.MatchingLabels(cassdc.GetDatacenterLabels())
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
2 changes: 1 addition & 1 deletion test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2144,7 +2144,7 @@ func DcPrefix(
cassdc := &cassdcapi.CassandraDatacenter{}
err := f.Get(context.Background(), dcKey, cassdc)
require.NoError(t, err)
return framework.CleanupForKubernetes(fmt.Sprintf("%s-%s", cassdc.Spec.ClusterName, cassdc.Name))
return framework.CleanupForKubernetes(fmt.Sprintf("%s-%s", cassdc.Spec.ClusterName, cassdc.DatacenterName()))
}

func DcClusterName(
Expand Down

0 comments on commit 08fc5e1

Please sign in to comment.