From 2879faaef95e290bb1c28f2e6b6dbf8714689abb Mon Sep 17 00:00:00 2001 From: "Johannes M. Scheuermann" Date: Thu, 5 Dec 2024 16:57:52 +0100 Subject: [PATCH] Add support for multi-region recover subcommand with DNS --- .../operator_plugin_test.go | 3 +-- .../cmd/recover_multi_region_cluster.go | 23 ++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/e2e/test_operator_plugin/operator_plugin_test.go b/e2e/test_operator_plugin/operator_plugin_test.go index 81881607..4181bb5a 100644 --- a/e2e/test_operator_plugin/operator_plugin_test.go +++ b/e2e/test_operator_plugin/operator_plugin_test.go @@ -162,8 +162,7 @@ var _ = Describe("Operator Plugin", Label("e2e", "pr"), func() { }) }) - // TODO(johscheuer): Enable once https://github.com/FoundationDB/fdb-kubernetes-operator/issues/2153 is fixed. - PWhen("all Pods in the primary and satellites are down with", func() { + When("all Pods in the primary and satellites are down with", func() { BeforeEach(func() { runningVersion := fdbCluster.GetPrimary().GetCluster().GetRunningVersion() parsedVersion, err := fdbv1beta2.ParseFdbVersion(runningVersion) diff --git a/kubectl-fdb/cmd/recover_multi_region_cluster.go b/kubectl-fdb/cmd/recover_multi_region_cluster.go index 7aca2f8a..72f884b0 100644 --- a/kubectl-fdb/cmd/recover_multi_region_cluster.go +++ b/kubectl-fdb/cmd/recover_multi_region_cluster.go @@ -28,6 +28,8 @@ import ( "strings" "time" + "github.com/go-logr/logr" + fdbv1beta2 "github.com/FoundationDB/fdb-kubernetes-operator/api/v1beta2" "github.com/FoundationDB/fdb-kubernetes-operator/internal" kubeHelper "github.com/FoundationDB/fdb-kubernetes-operator/internal/kubernetes" @@ -145,6 +147,7 @@ func recoverMultiRegionCluster(cmd *cobra.Command, opts recoverMultiRegionCluste cmd.Println("current connection string", lastConnectionString) + usesDNSInClusterFile := cluster.UseDNSInClusterFile() var useTLS bool coordinators := map[string]fdbv1beta2.ProcessAddress{} for _, addr := range addresses { @@ -177,9 +180,23 @@ func recoverMultiRegionCluster(cmd *cobra.Command, opts recoverMultiRegionCluste // Find a running coordinator to copy the coordinator files from. var runningCoordinator *corev1.Pod for _, pod := range pods.Items { - addr, parseErr := fdbv1beta2.ParseProcessAddress(pod.Status.PodIP) - if parseErr != nil { - return parseErr + var addr fdbv1beta2.ProcessAddress + if usesDNSInClusterFile { + dnsName := internal.GetPodDNSName(cluster, pod.GetName()) + addr = fdbv1beta2.ProcessAddress{StringAddress: dnsName} + } else { + currentPod := pod + publicIPs := internal.GetPublicIPsForPod(¤tPod, logr.Discard()) + if len(publicIPs) == 0 { + cmd.Println("Found no public IPs for pod:", pod.Name) + continue + } + + var parseErr error + addr, parseErr = fdbv1beta2.ParseProcessAddress(publicIPs[0]) + if parseErr != nil { + return parseErr + } } cmd.Println("checking pod:", pod.Name, "address:", addr, "pod IPs:", pod.Status.PodIP, "machineAddr:", addr.MachineAddress())