From c58884aa9d99ba03c76d8b6f86bb183db08419e1 Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Thu, 18 Jul 2019 11:03:14 +0200 Subject: [PATCH 1/2] Use zero redundancy when number of ES nodes is 1 Signed-off-by: Pavol Loffay --- pkg/strategy/controller.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/strategy/controller.go b/pkg/strategy/controller.go index aa6497965..4c3882a4e 100644 --- a/pkg/strategy/controller.go +++ b/pkg/strategy/controller.go @@ -133,7 +133,11 @@ func normalizeElasticsearch(spec *v1.ElasticsearchSpec) { spec.NodeCount = 1 } if spec.RedundancyPolicy == "" { - spec.RedundancyPolicy = esv1.SingleRedundancy + if spec.NodeCount == 1 { + spec.RedundancyPolicy = esv1.ZeroRedundancy + } else { + spec.RedundancyPolicy = esv1.SingleRedundancy + } } } From fef9bd38a35595cb849f41a52278312318eff8fb Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Thu, 18 Jul 2019 11:19:30 +0200 Subject: [PATCH 2/2] Add test Signed-off-by: Pavol Loffay --- pkg/strategy/controller_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/strategy/controller_test.go b/pkg/strategy/controller_test.go index 1ceb31ef0..26b32459a 100644 --- a/pkg/strategy/controller_test.go +++ b/pkg/strategy/controller_test.go @@ -240,7 +240,9 @@ func TestNormalizeElasticsearch(t *testing.T) { expected v1.ElasticsearchSpec }{ {underTest: v1.ElasticsearchSpec{}, - expected: v1.ElasticsearchSpec{NodeCount: 1, RedundancyPolicy: "SingleRedundancy"}}, + expected: v1.ElasticsearchSpec{NodeCount: 1, RedundancyPolicy: "ZeroRedundancy"}}, + {underTest: v1.ElasticsearchSpec{NodeCount: 3}, + expected: v1.ElasticsearchSpec{NodeCount: 3, RedundancyPolicy: "SingleRedundancy"}}, {underTest: v1.ElasticsearchSpec{NodeCount: 3, RedundancyPolicy: "FullRedundancy"}, expected: v1.ElasticsearchSpec{NodeCount: 3, RedundancyPolicy: "FullRedundancy"}}, {underTest: v1.ElasticsearchSpec{Image: "bla", NodeCount: 150, RedundancyPolicy: "ZeroRedundancy"},