-
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
Fix relative paths in prospectors definitions #5443
Conversation
ccbe636
to
374b14b
Compare
filebeat/prospector/log/config.go
Outdated
@@ -189,3 +192,17 @@ func (c *config) resolvePaths() error { | |||
c.Paths = paths | |||
return nil | |||
} | |||
|
|||
// makeGlobsAbsolute calls `filepath.Abs` on all the globs from config | |||
func (c *config) makeGlobsAbsolute() 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.
normalizeGlobPatterns
.
return nil, fmt.Errorf("Failed to resolve recursive globs in config: %+v", err) | ||
} | ||
if err := p.config.makeGlobsAbsolute(); err != nil { | ||
return nil, fmt.Errorf("Failed to make globs absolute: %+v", err) |
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.
msg: 'Failed to normalize glob patterns: ' ?
374b14b
to
18a4929
Compare
18a4929
to
0a7efae
Compare
If a relative path was used in a prospector definition, it could happen that when loading the state from the registry, the path didn't match the pattern, which made it ignore the saved state. Fixes elastic#5442. Additionally, this PR cleans up some code related to the `recursive_glob` setting. The docs used to claim that the feature is disabled by default, but that wasn't the case and it was impossible to disable it. This change leaves it enabled by default, but makes it possible to disable it.
0a7efae
to
3c36792
Compare
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
Jenkins, test it. |
@@ -115,7 +117,7 @@ func NewProspector( | |||
// It goes through all states coming from the registry. Only the states which match the glob patterns of | |||
// the prospector will be loaded and updated. All other states will not be touched. | |||
func (p *Prospector) loadStates(states []file.State) error { | |||
logp.Debug("prospector", "exclude_files: %s", p.config.ExcludeFiles) | |||
logp.Debug("prospector", "exclude_files: %s. Number of stats: %d", p.config.ExcludeFiles, len(states)) |
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.
s/stats/states/
If a relative path was used in a prospector definition, it could happen
that when loading the state from the registry, the path didn't match the
pattern, which made it ignore the saved state. Fixes #5442.
Additionally, this PR cleans up some code related to the
recursive_glob
setting. The docs used to claim that the feature is disabled by default, but
that wasn't the case and it was impossible to disable it. This change leaves
it enabled by default, but makes it possible to disable it.