Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add e2e test for changing a cluster to use DNS in cluster files #1821

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 sure 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
}
29 changes: 29 additions & 0 deletions e2e/test_operator/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,35 @@ 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())

if !parsedVersion.SupportsDNSInClusterFile() {
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
Loading