Skip to content

Commit

Permalink
K8OP-303 Use namespaced service name when registering k8ssandra clust…
Browse files Browse the repository at this point in the history
…er to Reaper
  • Loading branch information
rzvoncek committed Jan 17, 2025
1 parent a6352fc commit b357f31
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG/CHANGELOG-1.21.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ When cutting a new release, update the `unreleased` heading to the tag being gen
* [BUGFIX] [#1454](https://github.com/k8ssandra/k8ssandra-operator/issues/1454) Do not try to work out backup status if there are no pods
* [BUGFIX] [#1383](https://github.com/k8ssandra/k8ssandra-operator/issues/1383) Do not create MedusaBackup if MedusaBakupJob did not fully succeed
* [BUGFIX] [#1460](https://github.com/k8ssandra/k8ssandra-operator/issues/1460) Fix podName calculations in medusa's hostmap.go to account for unbalanced racks also
* [BUGFIX] [#1466](https://github.com/k8ssandra/k8ssandra-operator/issues/1466) Do not overwrite existing status fields or forget to write the changes. Also, add new ContextName for the Datacenter to know where it used to be.
* [BUGFIX] [#1466](https://github.com/k8ssandra/k8ssandra-operator/issues/1466) Do not overwrite existing status fields or forget to write the changes. Also, add new ContextName for the Datacenter to know where it used to be.
* [BUGFIX] [#1471](https://github.com/k8ssandra/k8ssandra-operator/issues/1471) Use namespaced service name when registering k8ssandra cluster to Reaper
3 changes: 2 additions & 1 deletion pkg/reaper/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ func (r *restReaperManager) connect(ctx context.Context, reaperSvc, username, pa
}

func (r *restReaperManager) AddClusterToReaper(ctx context.Context, cassdc *cassdcapi.CassandraDatacenter) error {
return r.reaperClient.AddCluster(ctx, cassdcapi.CleanupForKubernetes(cassdc.Spec.ClusterName), cassdc.GetSeedServiceName())
namespacedServiceName := cassdc.GetSeedServiceName() + "." + cassdc.Namespace
return r.reaperClient.AddCluster(ctx, cassdcapi.CleanupForKubernetes(cassdc.Spec.ClusterName), namespacedServiceName)
}

func (r *restReaperManager) VerifyClusterIsConfigured(ctx context.Context, cassdc *cassdcapi.CassandraDatacenter) (bool, error) {
Expand Down
22 changes: 22 additions & 0 deletions test/e2e/cluster_scope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func multiDcMultiCluster(t *testing.T, ctx context.Context, klusterNamespace str

dc1Namespace := "test-1"
dc2Namespace := "test-2"
reaperNamespace := "k8ssandra-operator"

t.Log("check that the K8ssandraCluster was created")
k8ssandra := &api.K8ssandraCluster{}
Expand Down Expand Up @@ -84,4 +85,25 @@ func multiDcMultiCluster(t *testing.T, ctx context.Context, klusterNamespace str
t.Log("check nodes in dc2 see nodes in dc1")
pod = DcPrefix(t, f, dc2Key) + "-rack1-sts-0"
checkNodeToolStatus(t, f, f.DataPlaneContexts[1], dc2Namespace, pod, count, 0, "-u", username, "-pw", password)

t.Log("check that cluster was registered in Reaper")
reaperKey := framework.ClusterKey{K8sContext: f.ControlPlaneContext, NamespacedName: types.NamespacedName{Namespace: reaperNamespace, Name: "reaper1"}}
dcKey := framework.ClusterKey{K8sContext: f.DataPlaneContexts[0], NamespacedName: types.NamespacedName{Namespace: dc1Namespace, Name: "dc1"}}
dcPrefix := DcPrefix(t, f, dcKey)
checkReaperReady(t, f, ctx, reaperKey)
checkDatacenterReady(t, ctx, dcKey, f)
createKeyspaceAndTable(t, f, ctx, f.DataPlaneContexts[0], k8ssandra.Namespace, k8ssandra.Name, dcPrefix+"-default-sts-0", "test_ks", "test_table", 2)

t.Log("deploying Reaper ingress routes in context", f.ControlPlaneContext)
reaperRestHostAndPort := ingressConfigs[f.ControlPlaneContext].ReaperRest
f.DeployReaperIngresses(t, f.ControlPlaneContext, k8ssandra.Namespace, "reaper1-service", reaperRestHostAndPort)
defer f.UndeployAllIngresses(t, f.ControlPlaneContext, k8ssandra.Namespace)
checkReaperApiReachable(t, ctx, reaperRestHostAndPort)

t.Run("TestReaperApi[0]", func(t *testing.T) {
t.Log("test Reaper API in context", f.ControlPlaneContext)
secretKey := framework.ClusterKey{K8sContext: f.ControlPlaneContext, NamespacedName: types.NamespacedName{Namespace: k8ssandra.Namespace, Name: "reaper-ui-secret"}}
username, password := retrieveCredentials(t, f, ctx, secretKey)
testReaperApi(t, ctx, f.ControlPlaneContext, DcClusterName(t, f, dcKey), "test_ks", username, password)
})
}
6 changes: 6 additions & 0 deletions test/testdata/fixtures/multi-dc-cluster-scope/k8ssandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,9 @@ spec:
nodeAffinityLabels:
"topology.kubernetes.io/zone": region2-zone2
mgmtAPIHeap: 64Mi
reaper:
reaperRef:
name: reaper1
namespace: k8ssandra-operator
uiUserSecretRef:
name: reaper-ui-secret
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- medusa-config.yaml
- reaper.yaml
- k8ssandra.yaml
31 changes: 31 additions & 0 deletions test/testdata/fixtures/multi-dc-cluster-scope/reaper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: v1
kind: Secret
metadata:
name: reaper-ui-secret
namespace: k8ssandra-opeartor
data:
# username: reaper-jmx (actually)
username: cmVhcGVyLWpteA==
# password: R3ap3r
password: UjNhcDNy
---
apiVersion: reaper.k8ssandra.io/v1alpha1
kind: Reaper
metadata:
name: reaper1
namespace: k8ssandra-opeartor
spec:
storageType: local
storageConfig:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 256Mi
httpManagement:
enabled: true
heapSize: 256Mi
autoScheduling:
enabled: false
uiUserSecretRef:
name: reaper-ui-secret

0 comments on commit b357f31

Please sign in to comment.