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

Do not request ES to clear routing allocation exclude at every reconciliation #2610

Merged
merged 2 commits into from
Mar 2, 2020

Conversation

sebgl
Copy link
Contributor

@sebgl sebgl commented Feb 24, 2020

This commits stores the last updated value of cluster routing allocation
exclude in an annotation of the Elasticsearch resource.
Before doing any call to the ES API for that setting, we check the
existing annotation. If its value is the same as the one we're about to
set, skip the ES API call.
If not, do the call then store the setting value in the annotation.

The annotation can be removed at any time: it will just trigger a call
to the Elasticsearch API with the right expected value, and the
annotation will be set again.

Users can manipulate this setting behind our back, in which case the
operator will only react based on the annotation value. We consider it's
the user responsibility to not mess cluster settings up at this point.

Fixes #1522.

This commits stores the last updated value of cluster routing allocation
exclude in an annotation of the Elasticsearch resource.
Before doing any call to the ES API for that setting, we check the
existing annotation. If its value is the same as the one we're about to
set, skip the ES API call.
If not, do the call then store the setting value in the annotation.

The annotation can be removed at any time: it will just trigger a call
to the Elasticsearch API with the right expected value, and the
annotation will be set again.

Users can manipulate this setting behind our back, in which case the
operator will only react based on the annotation value. We consider it's
the user responsibility to not mess cluster settings up at this point.
@sebgl sebgl added >enhancement Enhancement of existing functionality v1.1.0 labels Feb 24, 2020
@sebgl sebgl changed the title Don't clear shard allocation excludes in every reconciliation Don't request ES to clear routing allocation allocation exclude at every reconciliation Feb 24, 2020
@sebgl sebgl changed the title Don't request ES to clear routing allocation allocation exclude at every reconciliation Don't request ES to clear routing allocation exclude at every reconciliation Feb 24, 2020
Copy link
Collaborator

@pebrc pebrc left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -76,12 +88,45 @@ func IsMigratingData(ctx context.Context, shardLister esclient.ShardLister, podN
return nodeIsMigratingData(podName, shards, excludedNodes), nil
}

// AllocationExcludeAnnotationName returns the allocation exclude value stored in an annotation.
// May be empty if not set.
func allocationExcludeFromAnnotation(es esv1.Elasticsearch) string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment/func mismatch private/public

also not sure if I would have put this map lookup in a function in the first place (that needs a comment) given that it is used exactly once.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought this kind of problem was detected by the linter ?

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like it is disabled by default: golangci/golangci-lint#843

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also not sure if I would have put this map lookup in a function in the first place (that needs a comment) given that it is used exactly once

That's true. I wanted to separate the high-level logic (MigrateData) from the storage mechanism (annotations get/set), but indeed it feels a bit artificial here since getting from a map is pretty simple. No strong opinion, if I have to choose I would keep the current code though.

Copy link
Contributor

@barkbay barkbay left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -8,8 +8,20 @@ import (
"context"
"strings"

logf "sigs.k8s.io/controller-runtime/pkg/log"

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: new line in imports

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is IntelliJ separating the various import repos automatically

@@ -76,12 +88,45 @@ func IsMigratingData(ctx context.Context, shardLister esclient.ShardLister, podN
return nodeIsMigratingData(podName, shards, excludedNodes), nil
}

// AllocationExcludeAnnotationName returns the allocation exclude value stored in an annotation.
// May be empty if not set.
func allocationExcludeFromAnnotation(es esv1.Elasticsearch) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought this kind of problem was detected by the linter ?

@sebgl sebgl merged commit d010f2c into elastic:master Mar 2, 2020
@anyasabo anyasabo changed the title Don't request ES to clear routing allocation exclude at every reconciliation Do not request ES to clear routing allocation exclude at every reconciliation Apr 1, 2020
@pebrc pebrc added >non-issue and removed >enhancement Enhancement of existing functionality labels Apr 21, 2020
@pebrc
Copy link
Collaborator

pebrc commented Apr 21, 2020

Reverted in #2880 (thus >non-issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't clear shard allocation excludes at every reconciliation
4 participants