-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Filebeat: Makes registry_file_permission configurable #6455
Filebeat: Makes registry_file_permission configurable #6455
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
filebeat/registrar/registrar.go
Outdated
@@ -38,9 +39,10 @@ var ( | |||
registryWrites = monitoring.NewInt(nil, "registrar.writes") | |||
) | |||
|
|||
func New(registryFile string, flushTimeout time.Duration, out successLogger) (*Registrar, error) { | |||
func New(registryFile string, registryFilePermission os.FileMode, flushTimeout time.Duration, out successLogger) (*Registrar, error) { |
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.
exported function New should have comment or be unexported
FYI, yet to update docs, configuration reference, etc,.. |
f5122c6
to
4662bc2
Compare
filebeat/registrar/registrar.go
Outdated
@@ -85,6 +87,12 @@ func (r *Registrar) Init() error { | |||
return fmt.Errorf("Registry file path is not a regular file: %s", r.registryFile) | |||
} | |||
|
|||
// Update registry file permissions | |||
err = os.Chmod(r.registryFile, r.registryFilePermission) |
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.
Not sure if we really should update the file permission here. I would rather suggest to change in on line 262 so we already write it with the correct permission.
4662bc2
to
797748a
Compare
Grep for
|
325cf09
to
8d97d0f
Compare
@jaipradeesh Not sure what part you want to update in all these files? I think it's important to the permission settings in the reference file and the docs. |
f628649
to
7e1e969
Compare
No problem @ruflin. I've updated the docs. Please do a review :-) . I've also added some verification steps below. Permission config test
|
3ea5697
to
74e8e0e
Compare
@@ -15,7 +15,7 @@ filebeat: | |||
spool_size: 4096 | |||
idle_timeout: 5s | |||
registry_file: registry | |||
|
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 just triggered an idea on my end. It would be really great to have a system test that checks if the permission of the registry file is actually changed in case this is set differently. Can you add one?
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.
Alright.
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.
Will add tests for 0644, 0600 and 0664. IMO, that should suffice.
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.
Great to hear. Please ping us when you pushed a new commit. This will also show if it causes any problems on windows.
@urso @andrewkroh Do you see any issue adding this feature? |
One issue is that we use a plural (permissions) in naming the option for other areas. I think the name should be changed. |
74e8e0e
to
2cc740e
Compare
Could this please be merged and shipped with the next release? Much needed here too :) Thanks! |
66bd66a
to
168ac88
Compare
|
jenkins, test it |
max_timeout=1) | ||
|
||
# Wait a momemt to make sure registry is completely written | ||
time.sleep(1) |
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.
Normally this can become flaky on slow tests machines. But we can still fix it if the build starts to break.
@jaipradeesh Thanks, LGTM. Can you revert the Makefile change, just to be sure. Afterwards we should be good to go in case Jenkins agrees :-) |
9ad0fc8
to
cf7895c
Compare
Makefile, reverted. |
jenkins, test it |
cf7895c
to
63a3ee8
Compare
Weirdly, update config test is passing locally (Fedora 27) - https://dpaste.de/qGTb/#L127 but failing in travis (both OS X and Ubuntu Trusty) - https://travis-ci.org/elastic/beats/jobs/352789249#L352 Checking why. Any pointers appreciated. |
Could it be a timing issue related to the 1s? Travis is pretty slow. |
@jaipradeesh I assume you deleted the comment about pep8 and discovered |
@ruflin Used https://pypi.python.org/pypi/flake8 // |
57d4474
to
492a5d3
Compare
@@ -1293,7 +1440,8 @@ def test_ignore_older_state_clean_inactive(self): | |||
|
|||
# Make sure state is written | |||
self.wait_until( | |||
lambda: self.log_contains("Registry file updated. 0 states written."), | |||
lambda: self.log_contains( |
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.
Seems like you used a different pep setting then what we have in make fmt
for the line length. It's not a big deal but in general would be nice to only have the changes related to the PR in.
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.
Noted. From next 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.
Modified PEP8 config as per beats' requirements.
jenkins, test it |
PR LGTM. Now waiting on Jenkins to go green. |
max_timeout=1) | ||
|
||
# Wait a momemt to make sure registry is completely written | ||
time.sleep(5) |
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.
It would be nice if you could do a follow up PR that does not use time.Sleep
but for example watches the registry file for the file permission changes. Otherwise this increases our CI time by at least 5 seconds. If we have this in many tests this is not nice.
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 should be able to work on another filebeat bug over the weekend. Will push it along with that.
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.
Great, but please make it 2 different PR's to sepearate concerns.
Build fails on windows. Looks like Windows ACL have to be modified. Two ways to it.
|
For the first version I suggest we not support it on Windows but states this very clearly in the docs. Can you update the docs and tests accordingly, please also add a note to the reference config file. There are some other system tests which are skipped on windows, you can copy the checks from there. @andrewkroh WDYT? |
Currently we don't do any Windows ACL management anywhere in the project. So I would just say this option isn't supported on Windows. |
492a5d3
to
81106de
Compare
This supports use-cases where the registry file is read by some other external service/component. Signed-off-by: Jaipradeesh <jaipradeesh@gmail.com>
Signed-off-by: Jaipradeesh <jaipradeesh@gmail.com>
81106de
to
fd14e3a
Compare
jenkins, test it |
@jaipradeesh Merged. Thanks a lot for following through with this. |
This supports use-cases where the registry file is read
by some other external service/component.
Signed-off-by: Jaipradeesh jaipradeesh@gmail.com