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

Use ES single redundancy by default #531

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
2 changes: 1 addition & 1 deletion pkg/strategy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func normalizeElasticsearch(spec *v1.ElasticsearchSpec) {
spec.NodeCount = 1
}
if spec.RedundancyPolicy == "" {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we should be also checking the number of nodes. If it is a single node cluster the redundancy should be zero - https://angristan.xyz/elasticsearch-6-shard-replica-settings-for-single-node-cluster/ otherwise the health of the cluster will be yellow (not green :)).

I will create a separate issue for it.

spec.RedundancyPolicy = esv1.ZeroRedundancy
spec.RedundancyPolicy = esv1.SingleRedundancy
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string option is used to specify replica shards. Instead of exposing an integer ECL decided to expose a human readable string. The number of nodes is taken into the account when calculating the replica shards.

func calculateReplicaShards(policyType esv1.RedundancyPolicyType, dataNodes int) int {
switch policyType {
case esv1.FullRedundancy:
return dataNodes - 1
case esv1.MultipleRedundancy:
return (dataNodes - 1) / 2
case esv1.SingleRedundancy:
return 1
case esv1.ZeroRedundancy:
return 0
default:
return 1
}

This should be defaulting to SingleRedundancy to keep backwards compatibility.

}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/strategy/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func TestNormalizeElasticsearch(t *testing.T) {
expected v1.ElasticsearchSpec
}{
{underTest: v1.ElasticsearchSpec{},
expected: v1.ElasticsearchSpec{NodeCount: 1, RedundancyPolicy: "ZeroRedundancy"}},
expected: v1.ElasticsearchSpec{NodeCount: 1, 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"},
Expand Down