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] - Migration of system/package module to flatbuffers #34817
Conversation
Pinging @elastic/security-external-integrations (Team:Security-External Integrations) |
This pull request doesn't have a |
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
@efd6 addressed all the issues, added support for errors in the package flatbuff and also added a pool poison test. |
Updated the PR with the recommended changes @efd6 |
summary:string; | ||
url:string; | ||
type:string; | ||
error:string; |
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 persisted error needed for?
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 tracked this down. When a package is removed the same data that was original detected (including the errors) are transmitted in the removal event.
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.
Correction... so the error
field is not exported. And to quote the encoding/gob
docs, "Structs encode and decode only exported fields."
error error |
This means that the error
is not serialized by encoding/gob and the value is not persisted. So this will have a slightly different behavior than we had before. But originally this was designed to persist the error, and there were some issues with serialization (see #18536) so it was changed. Given that the original design was to include the error let's keep it in the flatbuffer schema.
@andrewkroh reworked the bucket migration process to have it migrate to a new bucket during metricset init |
|
||
// Initialize the Bolt DB. | ||
if ds.db == nil { | ||
var err 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.
This code is repeated a lot. How about adding a boltDatastore.init() error
method.
summary:string; | ||
url:string; | ||
type:string; | ||
error:string; |
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.
Correction... so the error
field is not exported. And to quote the encoding/gob
docs, "Structs encode and decode only exported fields."
error error |
This means that the error
is not serialized by encoding/gob and the value is not persisted. So this will have a slightly different behavior than we had before. But originally this was designed to persist the error, and there were some issues with serialization (see #18536) so it was changed. Given that the original design was to include the error let's keep it in the flatbuffer schema.
While I was reviewing I was making changes in my local copy to test some ideas. I’m going to push to push that commit into your branch so you can see it. I think it better expresses some of the thoughts I had in my review. You don’t have to keep the commit (we can rebase to remove it). |
Use a bolt write transaction to perform the entire schema migration such that failures result in a full rollback. The transaction also prevents any accidently concurrent migration issues. I added a test case for the migration that works on a boltdb file that contains package.v1 data from homebrew. Any test cases involving encoding/gob encoding were removed. We only care that we can continue to decode the old gob data. I also addressed all golangci-lint warnings.
@andrewkroh I went through the changes you made and they look really good, and the migration occurring inside of a bolt transaction solves the multiple instance issue. I think we can move ahead with your suggested changes. |
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
* initial working commit * flatbuffers migration now working with tests * updated changelog * removed comments * resolved PR suggetions and updated license * updated notice * updated tests, added benchmarks, renamed files * updated tests & added error storage in schema * license issue fixed * updated according to PR suggestions * refactored package migration based on bucket version and is now done during metric set initialization * Perform migration inside of a bolt transaction, fix linter warnings Use a bolt write transaction to perform the entire schema migration such that failures result in a full rollback. The transaction also prevents any accidently concurrent migration issues. I added a test case for the migration that works on a boltdb file that contains package.v1 data from homebrew. Any test cases involving encoding/gob encoding were removed. We only care that we can continue to decode the old gob data. I also addressed all golangci-lint warnings. --------- Co-authored-by: Andrew Kroh <andrew.kroh@elastic.co>
Type of change
What does this PR do?
This PR is responsible for migrating the storage encoding of packages in auditbeat system/package module from traditional
gob encoding to flatbuffers encoding. This change also makes sure that existing gob encoded packages for users are seamlessly migrated to flatbuffer encoding without loss of any data.
Why is it important?
This migration greatly improves the performance of the system/package module and brings it upto modern standards.
Benchmark tests will soon be added to record performance.
Checklist
- [] I have made corresponding changes to the documentation- [] I have made corresponding change to the default configuration filesCHANGELOG.next.asciidoc
.Related issues