-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 Settings#validate_all. #6008
Conversation
Testing that #6004 is fixed: master, fails:
this PR, succeeds:
|
I wanted to do a larger refactor, but my goal was to do a minimal change in time for 5.0.0. This PR brings in some changes already in the feature/java_persistence branch (adds Setting::Bytes, improves WritableDirectory). Bytes wasn't really needed, but was already in the patch I imported, and isn't used yet, so I felt was safe to include in this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM™
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example of failing spec due to nil -> "" change:
65) LogStash::Agent register_pipeline should delegate settings to new pipeline
Failure/Error: expect(arg1).to eq(config_string)
expected: "input { } filter { } output { }"
got: "input { } filter { } output { }## Note: this changelog has been moved to markdown format and is available at https://github.com/elastic/logstash/blob/master/CHANGELOG.md\n## 1.5.5 (Oct 29, 2015)\n### general\n - Update to JRuby 1.7.22\n - Improved default security configuration for SSL/TLS. Default is now TLS1.2 (#3955)\n - Fixed bug in JrJackson v0.3.5 when handing shared strings. This manifested into issues when \n JrJackson was used in json codec and ES output. (#4048, #4055\n - Added beats input in the default plugins list\n\n ## output\n - HTTP: Fixed memory leak in http output with usage of manticore library (#24) \n\n## 2.0.0 (Oct 28, 2015)\nNo additional changes from RC1 release. Please see below for changes in individual\npre-releases.\n\n## 2.0.0-rc1 (October 22, 2015)\n### filter\n
There are many test failures, coming from the changes in this PR, though I'm not sure why.
Also, a minor note, I see some whitespace ended at the end of some of the lines. Before merging it would be nice to remove it :)
@@ -17,9 +17,9 @@ module Environment | |||
|
|||
[ | |||
Setting::String.new("node.name", Socket.gethostname), | |||
Setting::String.new("path.config", nil, false), | |||
Setting::String.new("path.config", "", false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a somewhat big consequence in changing this from nil to "", as now logstash will try to read all files in the local directory, see here
Is this because validate_all
will fail if path.config, when disabled, is set to nil?
def value | ||
super.tap do |path| | ||
if !::File.directory?(path) | ||
# Create the directory if it doesn't exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the use case for this implicit directory creation?
Not sure how strict we should be about this, IMO we should just check if it's there and it's writable, if not, throw an error, and leave the dir creation to the provisioning tools, thoughts?
also, this could prevent "silent" directory creating (I know dir creating action is logged but stillll.....).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two use cases. First, for the PQ that's coming -- the default path si probably going to be {path.data}/queue/...
and it'd be nice not to have to have all these empty directories. Second, for users who just want to specify {path.data}
and that would imply the queue path (or similar) would be relative to {path.data}
and would be nice if they were automatically created if possible. My hope is to avoid having our docs say Run these 7 mkdir commands before running logstash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've ejected the WritableDirectory changes into a new PR, #6023
when ::String | ||
LogStash::Util::ByteValue.parse(value) | ||
else | ||
raise ArgumentError.new("Could not coerce '#{value}' into a bytes value") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest also logging the value's class
Hmm yeah I saw lots of Travis failures last night. I will attend to that On Friday, October 7, 2016, João Duarte notifications@github.com wrote:
|
Switched the empty-default string settings with a newer NullableString. I'm not happy with this as a solution, but I think as a short term minimal fix it is ok. There's still two more failing tests. I will get to these shortly. |
what if we added a |
This allows us to validate all settings after all the settings sources have been processed (logstash.yml, flags, environment variables, etc) NullableString is required for validation to pass on what were previously String settings with nil defaults. WritableDirectory's strict now defaults false to help with a problem where the default path.data might not be writable *and* the user could be specifying --path.data on the command line to compensate. Prior to this, the default value would be validated and cause Logstash to terminate on startup because of the default data directory was validated before the flag override was applied. To make this validate_all feature more useful, Setting#set will only call validate if `strict` is true. Fixes #6004
dcd5486
to
fd780b8
Compare
# Create the directory if it doesn't exist. | ||
begin | ||
# TODO(sissel): Log the fact that we are creating this directory. | ||
::FileUtils.mkdir_p(path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jordansissel can we log (debug?) that we created this dir?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooh just saw your todo. my bad :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be a larger change since Settings doesn't have access to a logger right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but yes, I agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
824d376
to
255c108
Compare
I did some surgery to this PR. Changes:
|
255c108
to
07018fb
Compare
Manual test |
@jsvd can you re-review? |
any thoughts on my suggestion in #6008 (comment)? Otherwise LGTM (test failure is unrelated) |
@jsvd Yeah I think adding |
This allows us to validate all settings after all the settings sources have been processed (logstash.yml, flags, environment variables, etc) NullableString is required for validation to pass on what were previously String settings with nil defaults. WritableDirectory's strict now defaults false to help with a problem where the default path.data might not be writable *and* the user could be specifying --path.data on the command line to compensate. Prior to this, the default value would be validated and cause Logstash to terminate on startup because of the default data directory was validated before the flag override was applied. To make this validate_all feature more useful, Setting#set will only call validate if `strict` is true. Fixes #6004 Fixes #6008
This allows us to validate all settings after all the settings sources have been processed (logstash.yml, flags, environment variables, etc) NullableString is required for validation to pass on what were previously String settings with nil defaults. WritableDirectory's strict now defaults false to help with a problem where the default path.data might not be writable *and* the user could be specifying --path.data on the command line to compensate. Prior to this, the default value would be validated and cause Logstash to terminate on startup because of the default data directory was validated before the flag override was applied. To make this validate_all feature more useful, Setting#set will only call validate if `strict` is true. Fixes #6004 Fixes #6008
All setting validations are now deferred until after setting sources have been processed (flags, logstash.yml, etc)
Deferred validation fixes #6004.