-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Implement hooks in libcontainer code base #261
Conversation
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Signed-off-by: Mrunal Patel <mrunalp@gmail.com> Conflicts: libcontainer/integration/exec_test.go
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
👍 (cc @mavenugo) |
|
||
type Hook interface { | ||
// Run executes the hook with the provided state. | ||
Run(*HookState) 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.
HookState
very simple "immutable" struct. Can be passed everywhere by value to avoid confusion.
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.
+1
👍 to the function hooks idea |
config.Hooks = &configs.Hooks{ | ||
Prestart: []configs.Hook{ | ||
configs.NewFunctionHook(func(s *configs.HookState) error { | ||
f, err := os.Create(filepath.Join(rootfs, "test")) |
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.
dont think we should reach out to rootfs from here. We should pass it as hook state as @mrunalp mentioned before.
@crosbymichael I've tried to address the comments in this PR in calavera@00a65a1 Feel free to cherry pick it. Unfortunately, the poststop hook test is not working, I'm sure I'm missing something. |
9a5edce
to
4e20b76
Compare
Signed-off-by: David Calavera <david.calavera@gmail.com> Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
4e20b76
to
0f28592
Compare
go vet failed. |
go vet is a lair! |
Ha ha |
LGTM |
@mrunalp we can update this again when we update the spec, i was just doing both independent so we would not be blocked |
LGTM |
Implement hooks in libcontainer code base
libnetwork waiting on : moby/libnetwork#515 libcontainer waiting on : opencontainers/runc#261 Due to libseccomp challenges, I cherry-picked opencontainers/runc#261 on top of runc v0.0.3 which is seen in my private fork that is vendored-in here Signed-off-by: Madhu Venugopal <madhu@docker.com>
Update Typo in ROADMAP.md
This is a little different implementation from #160 to have function based hooks for consumers of libcontainer directly but still supports our hooks for the spec based commands.