Skip to content

Commit

Permalink
More label fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
burmanm committed Nov 27, 2024
1 parent e2edce0 commit dbd4390
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion controllers/medusa/medusabackupjob_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func createDatacenterPods(t *testing.T, f *framework.Framework, ctx context.Cont
Name: podName,
Labels: map[string]string{
cassdcapi.ClusterLabel: cassdcapi.CleanLabelValue(dc.Spec.ClusterName),
cassdcapi.DatacenterLabel: dc.DatacenterName(),
cassdcapi.DatacenterLabel: dc.Name,
},
},
Spec: corev1.PodSpec{
Expand Down
7 changes: 4 additions & 3 deletions controllers/medusa/medusarestorejob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/go-logr/logr"
"github.com/k8ssandra/k8ssandra-operator/pkg/shared"
"net"
"time"

"github.com/go-logr/logr"
"github.com/k8ssandra/k8ssandra-operator/pkg/shared"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -237,7 +238,7 @@ func (r *MedusaRestoreJobReconciler) podTemplateSpecUpdateComplete(ctx context.C
// StatefulSets are scaled back up.

statefulsetList := &appsv1.StatefulSetList{}
labels := client.MatchingLabels{cassdcapi.ClusterLabel: cassdcapi.CleanLabelValue(req.Datacenter.Spec.ClusterName), cassdcapi.DatacenterLabel: req.Datacenter.DatacenterName()}
labels := client.MatchingLabels{cassdcapi.ClusterLabel: cassdcapi.CleanLabelValue(req.Datacenter.Spec.ClusterName), cassdcapi.DatacenterLabel: req.Datacenter.Name}

if err := r.List(ctx, statefulsetList, labels); err != nil {
req.Log.Error(err, "Failed to get StatefulSets")
Expand Down
5 changes: 3 additions & 2 deletions pkg/cassandra/management.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package cassandra
import (
"context"
"fmt"
"strconv"

"github.com/k8ssandra/k8ssandra-operator/pkg/errors"
"github.com/k8ssandra/k8ssandra-operator/pkg/utils"
"strconv"

"github.com/go-logr/logr"
cassdcapi "github.com/k8ssandra/cass-operator/apis/cassandra/v1beta1"
Expand Down Expand Up @@ -135,7 +136,7 @@ func (r *defaultManagementApiFacade) CreateKeyspaceIfNotExists(
func (r *defaultManagementApiFacade) fetchDatacenterPods() ([]corev1.Pod, error) {
podList := &corev1.PodList{}
labels := client.MatchingLabels{
cassdcapi.DatacenterLabel: cassdcapi.CleanLabelValue(r.dc.DatacenterName()),
cassdcapi.DatacenterLabel: cassdcapi.CleanLabelValue(r.dc.Name),
cassdcapi.ClusterLabel: cassdcapi.CleanLabelValue(r.dc.Spec.ClusterName)}
if err := r.k8sClient.List(r.ctx, podList, labels); err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/medusa/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func GetCassandraDatacenterPods(ctx context.Context, cassdc *cassdcapi.Cassandra
podList := &corev1.PodList{}
labels := client.MatchingLabels{
cassdcapi.ClusterLabel: cassdcapi.CleanLabelValue(cassdc.Spec.ClusterName),
cassdcapi.DatacenterLabel: cassdc.DatacenterName(),
cassdcapi.DatacenterLabel: cassdc.Name,
}
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())
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 @@ -2239,7 +2239,7 @@ func checkInjectedVolumePresence(t *testing.T, ctx context.Context, f *framework
return fmt.Errorf("cannot find busybox injected container in pod template spec")
}

cassandraPods, err := f.GetCassandraDatacenterPods(t, ctx, dcKey, cassdc.DatacenterName())
cassandraPods, err := f.GetCassandraDatacenterPods(t, ctx, dcKey, cassdc.Name)
require.NoError(t, err, "failed listing Cassandra pods")
cassandraIndex, cassandraFound := findContainerInPod(t, cassandraPods[0], "cassandra")
require.True(t, cassandraFound, "cannot find cassandra container in cassandra pod")
Expand Down

0 comments on commit dbd4390

Please sign in to comment.