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

Deprecate settings in .yml and .json #24059

Merged
merged 9 commits into from May 11, 2017
Merged

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented Apr 12, 2017

This commit adds a deprecation warning when elasticsearch.yml or
elasticsearch.json is read during startup. It also fixes all docs
references, tests, and renames the default file that comes in our packages.

relates #19391

@rjernst rjernst added :Core/Infra/Settings Settings infrastructure and APIs v5.4.0 v6.0.0-alpha1 labels Apr 12, 2017
@rjernst
Copy link
Member Author

rjernst commented Apr 12, 2017

One thing I am unsure about is how to handle packaging correctly with the change in name. I'm thinking we actually need to have something in the packaging scripts, otherwise I think the user will end up with both elasticsearch.yml and elasticsearch.yaml.

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.

It looks great. You covered all the things I thought of. I left a few comments.

@@ -44,6 +47,9 @@

public class InternalSettingsPreparer {

private static Logger logger = ESLoggerFactory.getLogger("settings");
Copy link
Member

Choose a reason for hiding this comment

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

Why name this logger against our convention? It's not even prefixed with "org.elasticsearch" but I think you should only pass InternalSettingsPreparer.class here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was trying to make the context in the log message clearer (that it had to do with settings) vs a user thinking "what is InternalSettingsPreparer". But I changed it as you suggested. If we don't want to allow using getLogger(String), we should remove it.

Copy link
Member

Choose a reason for hiding this comment

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

There are a few legitimate uses for this method, namely the loggers that we provide to Netty, and the naming for the circuit breaker loggers, as well as setting logging levels via the API (all we get there from the user input is the name of the logger, so we have to have a way to look up loggers by name).

@@ -112,6 +118,9 @@ public static Environment prepareEnvironment(Settings input, Terminal terminal,
throw new SettingsException("multiple settings files found with suffixes: "
+ Strings.collectionToDelimitedString(foundSuffixes, ","));
}
if (foundSuffixes.contains(".yml") || foundSuffixes.contains(".json")) {
deprecationLogger.deprecated("elasticsearch.yaml and elasticsearch.json are deprecated. Rename your configuration file to elasticsearch.yaml.");
Copy link
Member

Choose a reason for hiding this comment

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

Three-letter "yml" for the first instance of "yaml" here.

Copy link
Member

Choose a reason for hiding this comment

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

I think we can give a more specific message too: yml -> yaml only if yml, json -> yaml only if json instead of a general message covering both cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, I wrote this before doing find replace. :)

Copy link
Member

Choose a reason for hiding this comment

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

Because we disallow multiple settings files (a few lines up), we are certain here that foundSuffixes contains at most one element. So we can write:

if (foundSuffixes.contains(".yml") || foundSuffixes.contains(".json")) {
    final DeprecationLogger deprecationLogger = new DeprecationLogger(Loggers.getLogger(InternalSettingsPreparer.class));
    deprecationLogger.deprecated(
        "elasticsearch[{}] is deprecated; rename your configuration file to elasticsearch.yaml",
        foundSuffixes.iterator().next());
}

I think this is clean, and let's us scope the logger locally so we can avoid the static fields.

@@ -44,6 +47,9 @@

public class InternalSettingsPreparer {

private static Logger logger = ESLoggerFactory.getLogger("settings");
private static DeprecationLogger deprecationLogger = new DeprecationLogger(logger);
Copy link
Member

Choose a reason for hiding this comment

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

Also I wonder if these loggers should be initialized in the one place they are used?

Copy link
Member

Choose a reason for hiding this comment

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

That is, locally, and not even be a field here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since I split the message into two branches, I left these static.

Copy link
Member

Choose a reason for hiding this comment

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

See my suggestion for how I think that we can avoid this.

@rjernst
Copy link
Member Author

rjernst commented Apr 26, 2017

@jasontedor Maybe we should separate adding the deprecation from changing the shipped file? Then we could only do the default file change in 6.0. Users would then get the deprecation warning in 5.5, and know that they need to rename their file before upgrading to 6.0.

This commit adds a deprecation warning when elasticsearch.yml or
elasticsearch.json is read during startup.

relates elastic#19391
@rjernst
Copy link
Member Author

rjernst commented Apr 27, 2017

@jasontedor I pushed 129bc76 which simplies this commit to be just deprecation. I will cutover the docs and shipped config file in a followup to master only (with removal of support for anything but .yaml and helpful error message on the old names existing).

@rjernst rjernst added v5.5.0 and removed v5.4.1 labels May 2, 2017
@rjernst
Copy link
Member Author

rjernst commented May 2, 2017

@elasticmachine retest this please

@jasontedor ping

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 a comment.

@@ -107,6 +109,11 @@ public static Environment prepareEnvironment(Settings input, Terminal terminal,
throw new SettingsException("multiple settings files found with suffixes: "
+ Strings.collectionToDelimitedString(foundSuffixes, ","));
}
if (foundSuffixes.contains(".yml") || foundSuffixes.contains(".json")) {
final DeprecationLogger deprecationLogger = new DeprecationLogger(Loggers.getLogger(InternalSettingsPreparer.class));
Copy link
Member

Choose a reason for hiding this comment

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

Sadly, the logging here happens before we've fully configured logging. This means that it will appear in the console log with a default format, and before we've configured deprecation logging so it won't end up in the deprecation log on disk.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I pushed 7f796b0 to address this.

@jasontedor
Copy link
Member

retest this please

@rjernst
Copy link
Member Author

rjernst commented May 9, 2017

@elasticmachine retest this please

@dliappis
Copy link
Contributor

dliappis commented May 9, 2017

jenkins test this please

@rjernst
Copy link
Member Author

rjernst commented May 11, 2017

@jasontedor I finally got a clean CI run, can you look again?

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.

@rjernst rjernst merged commit f477a64 into elastic:master May 11, 2017
@rjernst rjernst deleted the deprecate_yml branch May 11, 2017 20:11
rjernst added a commit that referenced this pull request May 11, 2017
This commit adds a deprecation warning when elasticsearch.yml or
elasticsearch.json is read during startup.

relates #19391
@clintongormley clintongormley changed the title Settings: Deprecate settings in .yml and .json Deprecate settings in .yml and .json Jun 6, 2017
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.

None yet

4 participants