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

Add deprecation warning for negative index.unassigned.node_left.delayed_timeout #26832

Merged

Conversation

DaveCTurner
Copy link
Contributor

cf #26828.

There are also usages in o.e.c.routing.allocation.AllocationService and o.e.gateway.ReplicaShardAllocator. Do these also want warnings?

@@ -366,6 +370,9 @@ public AllocationStatus getLastAllocationStatus() {
*/
public long getRemainingDelay(final long nanoTimeNow, final Settings indexSettings) {
long delayTimeoutNanos = INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.get(indexSettings).nanos();
if (delayTimeoutNanos < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of baking it here, I would put in the setting parser. This means you'll catch all the places where the setting is used in one place.

@DaveCTurner
Copy link
Contributor Author

Thanks @bleskes - here's another attempt. Wasn't sure whether to put the check here in Settings or put it in TimeValue instead, and also how much to reuse the existing code vs copy it.

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

I left some comments.

@@ -1089,6 +1094,16 @@ private static String arrayToParsableString(String[] array) {
return timeSetting(key, defaultValue, TimeValue.timeValueMillis(0), properties);
}

public static Setting<TimeValue> timeSettingWithNegativeValuesDeprecated(String key, TimeValue defaultValue, Property... properties) {
Copy link
Member

Choose a reason for hiding this comment

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

I prefer not adding abstractions with exactly one use case. Especially since when we turn around and remove the deprecation logging for this setting (and turn it into a hard failure with Setting#positiveTimeSetting), the abstraction might end up left behind.

This one is also dangerous because it adds a static logger to a class that is touched very early. If we are not careful, we start initializing logging before we have configured it which we actively try to detect and fail startup if it occurs.

I think that you can get by with manually defining the logic for this setting at the definition site.

@DaveCTurner
Copy link
Contributor Author

Thanks @jasontedor - still fumbling towards the right answer here. I inlined the one-use method, and @bleskes showed me how deprecation of an entire setting happens, using a lazily-initialised logger. That logger was package-accessible so I had to make it public to use it here, which makes me uncomfortable. Any better ideas?

@jasontedor
Copy link
Member

Let’s not do that. It’s not the setting that is deprecated here, only support for certain values. So we shouldn’t hit the settings deprecation logger, instead I think a deprecation logger specific to this setting is fine.

@DaveCTurner
Copy link
Contributor Author

Ok @jasontedor, is this what you meant? Or does this need to be lazy too?

@jasontedor
Copy link
Member

No, laziness should not be needed here. The reason we need laziness in Settings is because settings class gets initialized before we’ve configured logging and we do not want the deprecation logger to be initialized when the class initializer for Settings runs (note the Javadoc on the holder in the Settings class for more details).

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

Getting close.

@@ -47,11 +49,20 @@
*/
public final class UnassignedInfo implements ToXContentFragment, Writeable {

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(Setting.class));
Copy link
Member

Choose a reason for hiding this comment

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

Again, this doesn't need to be tied to the Setting logger, we are not deprecating a setting here, only support for certain values. Therefore, I think this should be the logger for UnassignedInfo.class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Darn it. Fixed.

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

Can we have a test that exercises this and asserts the warning that we expect happens?

@DaveCTurner
Copy link
Contributor Author

@jasontedor @bleskes Felt like quite an adventure to get those three lines of test, so I hope they're close to what you wanted.

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

LGTM.

@DaveCTurner DaveCTurner merged commit 0ba3afe into elastic:6.x Oct 9, 2017
@DaveCTurner DaveCTurner deleted the negative_delayed_timeout_deprecation branch October 9, 2017 18:47
@DaveCTurner DaveCTurner restored the negative_delayed_timeout_deprecation branch November 22, 2017 15:43
@lcawl lcawl added :Search/Search Search-related issues that do not fall into other categories and removed :Allocation labels Feb 13, 2018
@clintongormley clintongormley added :Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. and removed :Search/Search Search-related issues that do not fall into other categories labels Feb 13, 2018
@DaveCTurner DaveCTurner deleted the negative_delayed_timeout_deprecation branch October 5, 2018 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>deprecation :Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. v6.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants