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

[Auditbeat] Log error when Homebrew not installed #11667

Merged
merged 9 commits into from
Apr 26, 2019

Conversation

cwurm
Copy link
Contributor

@cwurm cwurm commented Apr 5, 2019

At the moment, if Auditbeat is run with the default configuration (where the package dataset is enabled) on a Mac where Homebrew is not installed it will fail to start.

This changes the behavior to only logging an error message:

2019-04-05T15:03:01.250+0100 ERROR [package] package/package.go:218 Failed to start package dataset on macOS. Error looking up /usr/local/Cellar - is Homebrew installed? Error: stat /usr/local/Cellar: no such file or directory

@cwurm cwurm added review needs_backport PR is waiting to be backported to other branches. Auditbeat SecOps labels Apr 5, 2019
@cwurm cwurm requested review from a team as code owners April 5, 2019 14:13
@elasticmachine
Copy link
Collaborator

Pinging @elastic/secops

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

This is changing the expectations for the MetricSetFactory interface. Up until now all implementations must return either a MetricSet or an error. This change allows a MetricSetFactory to return both values as nil. I'd rather not allow this since I have the expectation from a factory that it will either produce the value I'm asking for or I will get an error.

metricbeat/mb/builders.go Outdated Show resolved Hide resolved
x-pack/auditbeat/module/system/package/package.go Outdated Show resolved Hide resolved
CHANGELOG.next.asciidoc Outdated Show resolved Hide resolved
@cwurm
Copy link
Contributor Author

cwurm commented Apr 10, 2019

Ok, makes sense. I've changed to keeping the dataset running even if Homebrew is not installed. It will log an ERROR first, then write only DEBUG outputs on every Fetch.

@andrewkroh Let me know what you think.

@cwurm cwurm requested review from andrewkroh and removed request for a team April 10, 2019 14:13
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

I think we should have some more unit tests for this metricset. For testing purposes if we can control the "homebrewCellarPath" then we can test the behavior when the path doesn't exist and we can test parsing by putting some fake homebrew data into a testdata/ directory for the package.

@cwurm
Copy link
Contributor Author

cwurm commented Apr 17, 2019

I've added a package_homebrew_test.go file with two tests for Homebrew. One of them tests what happens when the Homebrew cellar is not present, the other uses x-pack/auditbeat/tests/files/homebrew as the cellar containing one test-package.

@andrewkroh Let me know what you think.

@cwurm cwurm requested a review from andrewkroh April 17, 2019 13:20
defer func() {
homebrewCellarPath = oldPath
}()
homebrewCellarPath = "../../../tests/files/homebrew/"
Copy link
Member

Choose a reason for hiding this comment

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

The conventional directory for this in Go would be testdata within this package’s directory. testdata is ignored by Go (I think this is documented in go help test).

Copy link
Contributor Author

@cwurm cwurm Apr 18, 2019

Choose a reason for hiding this comment

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

Hm, so tests/files/ already contains some other test files as well. Should they all move to a testdata?

Copy link
Member

Choose a reason for hiding this comment

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

If they are used by the Go tests then I would move them into a testdata dir next to the tests that use them. It's not a hard rule, but it's a pretty common practice with this sort of data as also with golden-file tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, makes sense. For now - in this PR - I've moved the new homebrew directory. We should move the others later.

@cwurm cwurm merged commit bbe4991 into elastic:master Apr 26, 2019
@cwurm cwurm deleted the package_no_homebrew branch April 26, 2019 14:13
cwurm pushed a commit to cwurm/beats that referenced this pull request Apr 26, 2019
Change `package` dataset on macOS to logging an error when Homebrew is not installed instead of failing to start altogether. It will keep checking and start sending events as usual in case Homebrew is installed later.

(cherry picked from commit bbe4991)
@cwurm cwurm added v7.0.1 and removed needs_backport PR is waiting to be backported to other branches. labels Apr 26, 2019
cwurm pushed a commit to cwurm/beats that referenced this pull request Apr 26, 2019
Change `package` dataset on macOS to logging an error when Homebrew is not installed instead of failing to start altogether. It will keep checking and start sending events as usual in case Homebrew is installed later.

(cherry picked from commit bbe4991)
@cwurm cwurm added the v6.7.2 label Apr 26, 2019
cwurm pushed a commit that referenced this pull request Apr 30, 2019
Change `package` dataset on macOS to logging an error when Homebrew is not installed instead of failing to start altogether. It will keep checking and start sending events as usual in case Homebrew is installed later.

(cherry picked from commit bbe4991)
@cwurm cwurm added v6.8.0 and removed v6.7.2 labels May 3, 2019
cwurm pushed a commit that referenced this pull request May 3, 2019
…stalled (#11949)

* [Auditbeat] Log error when Homebrew not installed (#11667)

Change `package` dataset on macOS to logging an error when Homebrew is not installed instead of failing to start altogether. It will keep checking and start sending events as usual in case Homebrew is installed later.

(cherry picked from commit bbe4991)
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.

3 participants