From fbb4c9fd03b5216e69e2dda9bdb1ec9dffb40df1 Mon Sep 17 00:00:00 2001 From: Simen Lilleeng Date: Mon, 6 Nov 2023 14:06:49 +0100 Subject: [PATCH] Three data hall fault domain storage check bug fix (#1869) * Change minimum fault domains from 4 to 3 for three_data_hall redundancy --- .../foundationdb_database_configuration.go | 4 +- controllers/remove_process_groups_test.go | 58 ++++++++++++++++++- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/api/v1beta2/foundationdb_database_configuration.go b/api/v1beta2/foundationdb_database_configuration.go index e3fb247da..a40dd1d82 100644 --- a/api/v1beta2/foundationdb_database_configuration.go +++ b/api/v1beta2/foundationdb_database_configuration.go @@ -718,10 +718,8 @@ func MinimumFaultDomains(redundancyMode RedundancyMode) int { return 1 case RedundancyModeDouble, RedundancyModeUnset: return 2 - case RedundancyModeTriple: + case RedundancyModeTriple, RedundancyModeThreeDataHall: return 3 - case RedundancyModeThreeDataHall: - return 4 default: return 1 } diff --git a/controllers/remove_process_groups_test.go b/controllers/remove_process_groups_test.go index 314b356c5..e501b7411 100644 --- a/controllers/remove_process_groups_test.go +++ b/controllers/remove_process_groups_test.go @@ -117,7 +117,7 @@ var _ = Describe("remove_process_groups", func() { }) }) - When("the cluster has degraded stroage fault tolerance", func() { + When("the cluster has degraded storage fault tolerance", func() { BeforeEach(func() { adminClient, err := mock.NewMockAdminClientUncast(cluster, k8sClient) Expect(err).NotTo(HaveOccurred()) @@ -192,6 +192,62 @@ var _ = Describe("remove_process_groups", func() { }) }) + When("the cluster has three_data_hall redundancy", func() { + BeforeEach(func() { + adminClient, err := mock.NewMockAdminClientUncast(cluster, k8sClient) + Expect(err).NotTo(HaveOccurred()) + adminClient.DatabaseConfiguration.RedundancyMode = fdbv1beta2.RedundancyModeThreeDataHall + + }) + When("storage have 3 replicas", func() { + BeforeEach(func() { + adminClient, err := mock.NewMockAdminClientUncast(cluster, k8sClient) + Expect(err).NotTo(HaveOccurred()) + adminClient.TeamTracker = []fdbv1beta2.FoundationDBStatusTeamTracker{ + { + Primary: true, + State: fdbv1beta2.FoundationDBStatusDataState{ + Healthy: true, + MinReplicasRemaining: 3, + }, + }, + } + }) + It("should successfully remove that process group", func() { + Expect(result).To(BeNil()) + // Ensure resources are deleted + removed, include, err := confirmRemoval(context.Background(), globalControllerLogger, clusterReconciler, cluster, removedProcessGroup) + Expect(err).To(BeNil()) + Expect(removed).To(BeTrue()) + Expect(include).To(BeTrue()) + }) + }) + When("storage have 2 replicas", func() { + BeforeEach(func() { + adminClient, err := mock.NewMockAdminClientUncast(cluster, k8sClient) + Expect(err).NotTo(HaveOccurred()) + adminClient.TeamTracker = []fdbv1beta2.FoundationDBStatusTeamTracker{ + { + Primary: true, + State: fdbv1beta2.FoundationDBStatusDataState{ + Healthy: true, + MinReplicasRemaining: 2, + }, + }, + } + }) + It("should not remove the process group and should not exclude processes", func() { + Expect(result).NotTo(BeNil()) + Expect(result.message).To(Equal("Removals cannot proceed because cluster has degraded fault tolerance")) + // Ensure resources are not deleted + removed, include, err := confirmRemoval(context.Background(), globalControllerLogger, clusterReconciler, cluster, removedProcessGroup) + Expect(err).To(BeNil()) + Expect(removed).To(BeFalse()) + Expect(include).To(BeFalse()) + }) + }) + }) + When("removing multiple process groups", func() { var initialCnt int var secondRemovedProcessGroup *fdbv1beta2.ProcessGroupStatus