Skip to content

add delete cluster setting and throw exception when validation fails#5019

Closed
kzwang wants to merge 2 commits intoelastic:masterfrom
kzwang:feature/update_setting
Closed

add delete cluster setting and throw exception when validation fails#5019
kzwang wants to merge 2 commits intoelastic:masterfrom
kzwang:feature/update_setting

Conversation

@kzwang
Copy link
Copy Markdown
Contributor

@kzwang kzwang commented Feb 5, 2014

Added DELETE, POST and modified PUT method for "/_cluster/settings"

DELETE request will delete transient and persistent settings, there are two parameters delete_transient and delete_persistent to control delete transient and persistent settings, they are all default to true. It will return the deleted settings

POST will add the settings in request to the cluster settings (same as previous PUT)

PUT will clear the existing settings and add the settings in the request

Also will throw exception when validation for settings fail

cloeses #3670 and #5018

@jippi
Copy link
Copy Markdown

jippi commented Feb 6, 2014

👍

@s1monw
Copy link
Copy Markdown
Contributor

s1monw commented Apr 10, 2014

hey @kzwang I can't tell you how much I'd love to get this in - I wanted to use it for our test but it's a bit more tricky I think than it looks like. It's not enough to delete the setting we really need to reset to what it's default was. for instance look at ConcurrentRebalanceAllocatinDecider.java

 class ApplySettings implements NodeSettingsService.Listener {
        @Override
        public void onRefreshSettings(Settings settings) {
            int clusterConcurrentRebalance = settings.getAsInt(CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE, ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance);
            if (clusterConcurrentRebalance != ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance) {
                logger.info("updating [cluster.routing.allocation.cluster_concurrent_rebalance] from [{}], to [{}]", ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance, clusterConcurrentRebalance);
                ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance = clusterConcurrentRebalance;
            }
        }
    }

once the setting was applied it sticks to where it is used and will be reused even if we delete it here is the relevant line:

int clusterConcurrentRebalance = settings.getAsInt(CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE, ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance);

so we need to find a way to reset it to the default but I don't have a really good answer how to do that...

@kzwang
Copy link
Copy Markdown
Contributor Author

kzwang commented Apr 10, 2014

Hi @s1monw,
For those classes, the default value is set in the constructor, such as this.clusterConcurrentRebalance = settings.getAsInt(CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE, 2);
why can't we just reset the setting to that value? It looks like every time the onRefreshSettings is called, full settings will be passed, so it the setting is null we should use the default value instead of previous value?

@s1monw
Copy link
Copy Markdown
Contributor

s1monw commented Apr 10, 2014

so I think this can work but it's tricky. What we need to do is this

this.clusterConcurrentRebalance = this.defaultClusterConcurrentRebalance = settings.getAsInt(CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE, 2);

//... and then

int clusterConcurrentRebalance = settings.getAsInt(CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE, ConcurrentRebalanceAllocationDecider.this.defaultClusterConcurrentRebalance);

since the constant might not be the default that comes from the node setting. I personally think a prerequsite for this is a way to fetch the current value that is used for each of the settings so we can actually test the update / deletes. does this make sense?

@s1monw
Copy link
Copy Markdown
Contributor

s1monw commented Apr 10, 2014

one way of doing this could be adding something like this:

class ApplySettings implements NodeSettingsService.Listener {

        public void currentSettings(ImmutableSettings.Builder builder) {
            builder.put(CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE, ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance);
        }
        @Override
        public void onRefreshSettings(Settings settings) {
            int clusterConcurrentRebalance = settings.getAsInt(CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE, ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance);
            if (clusterConcurrentRebalance != ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance) {
                logger.info("updating [cluster.routing.allocation.cluster_concurrent_rebalance] from [{}], to [{}]", ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance, clusterConcurrentRebalance);
                ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance = clusterConcurrentRebalance;
            }
        }
    }

where we can pull the current settings from?

@kzwang
Copy link
Copy Markdown
Contributor Author

kzwang commented Apr 10, 2014

what I'm thinking is the default value in code is just a static field that should never changed, and we'll pass all settings (cluster wide, node setting from config file etc.) to onRefreshSettings, so if the setting is null it means user doesn't config that anywhere, so we should use the default static one.

@s1monw
Copy link
Copy Markdown
Contributor

s1monw commented Apr 10, 2014

well that is not true - the values might be configured on a node level in the elasticsearch.yaml which is what should be used. The default is only if it has never been configured.

@kzwang
Copy link
Copy Markdown
Contributor Author

kzwang commented Apr 10, 2014

private static final int defaultClusterConcurrentRebalance = 2;

// in constructor
int clusterConcurrentRebalance = settings.getAsInt(CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE, ConcurrentRebalanceAllocationDecider.this.defaultClusterConcurrentRebalance);

// adn change this method to read both cluster setting and node setting
@Override
        public void onRefreshSettings(Settings settings, Settings nodeSettings) {
            int clusterConcurrentRebalance = settings.getAsInt(CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE, nodeSettings.getAsInt(CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE, ConcurrentRebalanceAllocationDecider.this.defaultClusterConcurrentRebalance));
//...
        }

when construct the class, it will read node setting, when setting updated, it will read cluster setting first, if not found, try node setting, if still not found, use the static default one

@s1monw
Copy link
Copy Markdown
Contributor

s1monw commented Apr 10, 2014

oh yeah that is a great idea - I like it. If we can pair it with getting the effective value via a GET call that would be awesome!

@s1monw
Copy link
Copy Markdown
Contributor

s1monw commented Apr 16, 2014

@kzwang would you be willing to work on this further? If you don't have time we can find somebody to take it from here?

@kzwang
Copy link
Copy Markdown
Contributor Author

kzwang commented Apr 16, 2014

@s1monw I'll work on it within next couple of days

@s1monw
Copy link
Copy Markdown
Contributor

s1monw commented Apr 16, 2014

awesome! thanks so much!

@reedbj
Copy link
Copy Markdown

reedbj commented Apr 16, 2014

I am sure glad to see this is being looked at, a much needed feature - especially with deprecated settings in the mix!

@clintongormley
Copy link
Copy Markdown
Contributor

Closed in favour of #6732

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants