diff --git a/CHANGELOG/CHANGELOG-1.21.md b/CHANGELOG/CHANGELOG-1.21.md index eb6a04ae1..0f96f253e 100644 --- a/CHANGELOG/CHANGELOG-1.21.md +++ b/CHANGELOG/CHANGELOG-1.21.md @@ -24,3 +24,4 @@ When cutting a new release, update the `unreleased` heading to the tag being gen * [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. * [ENHANCEMENT] [#1455](https://github.com/k8ssandra/k8ssandra-operator/issues/1455) Expose configuration of Medusa's gRPC server port +* [BUGFIX] [#1471](https://github.com/k8ssandra/k8ssandra-operator/issues/1471) Use namespaced service name when registering k8ssandra cluster to Reaper diff --git a/pkg/reaper/manager.go b/pkg/reaper/manager.go index d8287b0fb..d5d9a99c3 100644 --- a/pkg/reaper/manager.go +++ b/pkg/reaper/manager.go @@ -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) { diff --git a/test/e2e/cluster_scope_test.go b/test/e2e/cluster_scope_test.go index 7cdd913e2..e39c9b841 100644 --- a/test/e2e/cluster_scope_test.go +++ b/test/e2e/cluster_scope_test.go @@ -15,6 +15,7 @@ func multiDcMultiCluster(t *testing.T, ctx context.Context, klusterNamespace str dc1Namespace := "test-1" dc2Namespace := "test-2" + reaperNamespace := "test-0" t.Log("check that the K8ssandraCluster was created") k8ssandra := &api.K8ssandraCluster{} @@ -84,4 +85,24 @@ 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) + createKeyspaceAndTable(t, f, ctx, f.DataPlaneContexts[0], dc1Namespace, k8ssandra.Name, dcPrefix+"-rack1-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) + }) } diff --git a/test/testdata/fixtures/multi-dc-cluster-scope/k8ssandra.yaml b/test/testdata/fixtures/multi-dc-cluster-scope/k8ssandra.yaml index f4d545db9..4daeb08c5 100644 --- a/test/testdata/fixtures/multi-dc-cluster-scope/k8ssandra.yaml +++ b/test/testdata/fixtures/multi-dc-cluster-scope/k8ssandra.yaml @@ -37,6 +37,7 @@ spec: concurrent_writes: 2 concurrent_counter_writes: 2 jvmOptions: + cassandra_ring_delay_ms: 0 heapSize: 512Mi heapNewGenSize: 256Mi gc: CMS @@ -69,3 +70,9 @@ spec: nodeAffinityLabels: "topology.kubernetes.io/zone": region2-zone2 mgmtAPIHeap: 64Mi + reaper: + reaperRef: + name: reaper1 + namespace: test-0 + uiUserSecretRef: + name: reaper-ui-secret diff --git a/test/testdata/fixtures/multi-dc-cluster-scope/kustomization.yaml b/test/testdata/fixtures/multi-dc-cluster-scope/kustomization.yaml index 03cca31b9..c38d6b1da 100644 --- a/test/testdata/fixtures/multi-dc-cluster-scope/kustomization.yaml +++ b/test/testdata/fixtures/multi-dc-cluster-scope/kustomization.yaml @@ -2,4 +2,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - medusa-config.yaml + - reaper.yaml - k8ssandra.yaml diff --git a/test/testdata/fixtures/multi-dc-cluster-scope/reaper.yaml b/test/testdata/fixtures/multi-dc-cluster-scope/reaper.yaml new file mode 100644 index 000000000..e97d664e9 --- /dev/null +++ b/test/testdata/fixtures/multi-dc-cluster-scope/reaper.yaml @@ -0,0 +1,29 @@ +apiVersion: v1 +kind: Secret +metadata: + name: reaper-ui-secret +data: + # username: reaper-jmx (actually) + username: cmVhcGVyLWpteA== + # password: R3ap3r + password: UjNhcDNy +--- +apiVersion: reaper.k8ssandra.io/v1alpha1 +kind: Reaper +metadata: + name: reaper1 +spec: + storageType: local + storageConfig: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 256Mi + httpManagement: + enabled: true + heapSize: 256Mi + autoScheduling: + enabled: false + uiUserSecretRef: + name: reaper-ui-secret