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

Set default redundancy policy to zero #501

Merged
merged 2 commits into from
Jul 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions pkg/strategy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/jaegertracing/jaeger-operator/pkg/apis/jaegertracing/v1"
"github.com/jaegertracing/jaeger-operator/pkg/cronjob"
"github.com/jaegertracing/jaeger-operator/pkg/storage"
esv1 "github.com/jaegertracing/jaeger-operator/pkg/storage/elasticsearch/v1"
)

const (
Expand Down Expand Up @@ -143,6 +144,9 @@ func normalizeElasticsearch(spec *v1.ElasticsearchSpec) {
if spec.NodeCount == 0 {
spec.NodeCount = 1
}
if spec.RedundancyPolicy == "" && spec.NodeCount == 1 {
spec.RedundancyPolicy = esv1.ZeroRedundancy
Copy link
Member

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.

}
}

func normalizeRollover(spec *v1.JaegerEsRolloverSpec) {
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 @@ -243,7 +243,7 @@ func TestNormalizeElasticsearch(t *testing.T) {
expected v1.ElasticsearchSpec
}{
{underTest: v1.ElasticsearchSpec{},
expected: v1.ElasticsearchSpec{NodeCount: 1}},
expected: v1.ElasticsearchSpec{NodeCount: 1, RedundancyPolicy: "ZeroRedundancy"}},
{underTest: v1.ElasticsearchSpec{Image: "bla", NodeCount: 150},
expected: v1.ElasticsearchSpec{Image: "bla", NodeCount: 150}},
}
Expand Down