-
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
[Agent] Enable post install hooks #17241
[Agent] Enable post install hooks #17241
Conversation
Pinging @elastic/ingest-management (Project:fleet) |
// NOTE(ph): this is a bit of a hack because I want to make sure | ||
// the unpack strategy stay in the struct implementation and yaml | ||
// doesn't have a RawMessage similar to the JSON package, so partial unpack | ||
// is not possible. |
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.
Yeah I this is what I hate the most about the yaml package, there is a way to work around that go-yaml/yaml#13 (comment)
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 think you can remove my name next to NOTE :)
// Execute executes delete file step. | ||
func (r *DeleteFileStep) Execute(rootDir string) error { | ||
path := filepath.Join(rootDir, filepath.FromSlash(r.Path)) | ||
err := os.Remove(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.
We probably want to add some defensive programming here, even if we control the spec, we never know when this will not be the case. I think we should convert the Filepath.Join()
into an absolute path and make sure we are in the "rootdir" and not somewhere else.
I believe this is the case, we want to sandbox every command into a specific directly. I assume all our commands operate in the extracted directory.
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 is something i was thinking about but did not want to sound too paraniod
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.
Better to be paranoid than sorry :)
I think this works, I need to think a bit more in the context of endpoint and the driver/endpoint installation because I assume this will be also a post install hook that will trigger the installation with a custom installation script. Maybe we will need to have different hooks defined per platforms? No need to do it now. but this is something we have in mind. |
Jenkins test this |
@ph i think we can introduce constraints here as well at some later point |
needs update on tests, failures are related to change |
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.
Minors changes, but the looks good to me.
if runtime.GOOS == "windows" { | ||
absRoot = strings.ToLower(absRoot) | ||
absPath = strings.ToLower(absPath) | ||
} |
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 is also true on macOS, by default HFS+ is case insensitive. So the following will work.
mkdir hello
cd HelLO
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 been bitten so many times on weird git issues with case insensitive filesystem, the things is if you turn on the case sensitivity on HFS+ it will make many things fails.
// NOTE(ph): this is a bit of a hack because I want to make sure | ||
// the unpack strategy stay in the struct implementation and yaml | ||
// doesn't have a RawMessage similar to the JSON package, so partial unpack | ||
// is not possible. |
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 think you can remove my name next to NOTE :)
{"/a/b", "/a/b/../c", "\\a\\c", false}, | ||
{"/a/b", "../c", "\\a\\c", 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.
Can we add tests for the case sensitivity on windows/darwin?
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
[Agent] Enable post install hooks (elastic#17241) (cherry picked from commit 5c2eb42)
[Agent] Enable post install hooks (#17241) (cherry picked from commit 5c2eb42) Co-authored-by: Michal Pristas <[email protected]>
What does this PR do?
This PR introduces new collection of steps just like we have with rules.
This collection is part of baked in spec file and is called
post_install
When installation needs to be run it executed Install method of respective installer and after that it runs collection of these hooks.
At the moment two steps were introduced, rename and remove;
Example of the config:
Why is it important?
Metricbeat is collecting system metrics by default and is sending them to default ES index. We want to avoid this default behavior as default behavior is specified by configuration coming from fleet.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Fixes: #17197
Related: elastic/kibana#60319