Skip to content

Commit

Permalink
Add support for multi-region recover subcommand with DNS
Browse files Browse the repository at this point in the history
  • Loading branch information
johscheuer committed Dec 5, 2024
1 parent 43800d4 commit 2879faa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
3 changes: 1 addition & 2 deletions e2e/test_operator_plugin/operator_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 20 additions & 3 deletions kubectl-fdb/cmd/recover_multi_region_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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(&currentPod, 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())
Expand Down

0 comments on commit 2879faa

Please sign in to comment.