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 swallow exceptions thrown while parsing settings #13039

Merged
merged 1 commit into from Aug 21, 2015
Merged

Do not swallow exceptions thrown while parsing settings #13039

merged 1 commit into from Aug 21, 2015

Conversation

jasontedor
Copy link
Member

This commit fixes an issue that was causing Elasticsearch to silently
ignore settings files that contain garbage. The underlying issue was
swallowing an SettingsException under the assumption that the only
reason that an exception could be throw was due to the settings file
not existing (in this case the IOException would be the cause of the
swallowed SettingsException). This assumption is mistaken as an
IOException could also be thrown due to an access error or a read
error. Additionally, a SettingsException could be thrown exactly
because garbage was found in the settings file. We should instead
explicitly check that the settings file exists, and bomb on an
exception thrown for any reason.

Closes #13028

This commit fixes an issue that was causing Elasticsearch to silently
ignore settings files that contain garbage. The underlying issue was
swallowing an SettingsException under the assumption that the only
reason that an exception could be throw was due to the settings file
not existing (in this case the IOException would be the cause of the
swallowed SettingsException). This assumption is mistaken as an
IOException could also be thrown due to an access error or a read
error. Additionally, a SettingsException could be thrown exactly
because garbage was found in the settings file. We should instead
explicitly check that the settings file exists, and bomb on an
exception thrown for any reason.

Closes #13028
// ignore
Path path = environment.configFile().resolve("elasticsearch" + allowedSuffix);
if (Files.exists(path)) {
settingsBuilder.loadFromPath(path);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we should fail if we find several times the config file with different extensions?

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 think you're right, but I don't know the history of allowing multiple settings formats and whether or not it is used in practice. If we are going to make a breaking change on this, now (pre 2.0) is most definitely the time.

Copy link
Member

Choose a reason for hiding this comment

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

FWIW I've used this in the past for production ES clusters to have a set of common settings (elasticsearch.yml) and node-specific settings (elasticsearch.json) to merge two files with settings.

That said, I still think it's safer/better to remove this feature and fail if more than one config file is found. It reduces the complexity for reasoning where a setting came from.

Copy link
Contributor

Choose a reason for hiding this comment

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

still think it's safer/better to remove this feature and fail if more than one config file is found. It reduces the complexity for reasoning where a setting came from.

+1

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'll open a separate issue for it.

@rmuir
Copy link
Contributor

rmuir commented Aug 21, 2015

+1, I think this is a good step.

jasontedor added a commit that referenced this pull request Aug 21, 2015
Do not swallow exceptions thrown while parsing settings
@jasontedor jasontedor merged commit fcb0c43 into elastic:master Aug 21, 2015
@jasontedor jasontedor deleted the fix/garbage-in-settings branch August 21, 2015 15:07
jasontedor added a commit that referenced this pull request Aug 21, 2015
This commit backports the fix #13039 for #13028 to 2.0 from master.
@jpountz jpountz removed the v2.0.0 label Aug 21, 2015
@jasontedor
Copy link
Member Author

Thanks for helpful review and comments @jpountz, @dakrone and @rmuir. Pushed to master and back ported to 2.0. I've opened a separate issue #13042 to address multiple settings files.

@clintongormley clintongormley added the :Core/Infra/Settings Settings infrastructure and APIs label Aug 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

straight up garbage in elasticsearch.yml does not cause error or even warning.
5 participants