Skip to content

Commit

Permalink
Add e2e test for changing a cluster to use DNS in cluster files
Browse files Browse the repository at this point in the history
  • Loading branch information
johscheuer committed Sep 29, 2023
1 parent 03bcf7c commit 532cb7e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
15 changes: 14 additions & 1 deletion controllers/change_coordinators.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ func (c changeCoordinators) reconcile(ctx context.Context, r *FoundationDBCluste
return nil
}

// TODO move them into separate package?
// selectCandidates is a helper for Reconcile that picks non-excluded, not-being-removed class-matching process groups.
func selectCandidates(cluster *fdbv1beta2.FoundationDBCluster, status *fdbv1beta2.FoundationDBStatus) ([]locality.Info, error) {
candidates := make([]locality.Info, 0, len(status.Cluster.Processes))
Expand All @@ -121,6 +120,19 @@ func selectCandidates(cluster *fdbv1beta2.FoundationDBCluster, status *fdbv1beta
continue
}

// Ignore processes with missing locality, see: https://github.com/FoundationDB/fdb-kubernetes-operator/issues/1254
if len(process.Locality) == 0 {
continue
}

// If the cluster should be using DNS in the cluster file we should make use the locality is set.
if cluster.UseDNSInClusterFile() {
_, ok := process.Locality[fdbv1beta2.FDBLocalityDNSNameKey]
if !ok {
continue
}
}

if cluster.ProcessGroupIsBeingRemoved(fdbv1beta2.ProcessGroupID(process.Locality[fdbv1beta2.FDBLocalityInstanceIDKey])) {
continue
}
Expand Down Expand Up @@ -187,5 +199,6 @@ func getCoordinatorAddress(cluster *fdbv1beta2.FoundationDBCluster, locality loc
Flags: address.Flags,
}
}

return address
}
31 changes: 31 additions & 0 deletions e2e/test_operator/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,37 @@ var _ = Describe("Operator", Label("e2e", "pr"), func() {
})
})

When("migrating a cluster to make use of DNS in the cluster file", func() {
BeforeEach(func() {
cluster := fdbCluster.GetCluster()
parsedVersion, err := fdbv1beta2.ParseFdbVersion(cluster.Status.RunningVersion)
Expect(err).NotTo(HaveOccurred())

// TODO (johscheuer): Change this once https://github.com/FoundationDB/fdb-kubernetes-operator/pull/1820 is merged.
// if parsedVersion.SupportsDNSInClusterFile() {
if !parsedVersion.IsAtLeast(fdbv1beta2.Version{Major: 7, Minor: 0, Patch: 0}) {
Skip(fmt.Sprintf("current FoundationDB version %s doesn't support DNS", parsedVersion.String()))
}

if cluster.UseDNSInClusterFile() {
Skip("cluster already uses DNS")
}

Expect(fdbCluster.SetUseDNSInClusterFile(true)).ToNot(HaveOccurred())
})

It("should migrate the cluster", func() {
cluster := fdbCluster.GetCluster()
Eventually(func() string {
return fdbCluster.GetStatus().Cluster.ConnectionString
}).Should(ContainSubstring(cluster.GetDNSDomain()))
})

AfterEach(func() {
Expect(fdbCluster.SetUseDNSInClusterFile(false)).ToNot(HaveOccurred())
})
})

// This test is pending, as all Pods will be restarted at the same time, which will lead to unavailability without
// using DNS.
PWhen("crash looping the sidecar for all Pods", func() {
Expand Down

0 comments on commit 532cb7e

Please sign in to comment.