Uh oh!
There was an error while loading. Please reload this page.
hooks: start with pre-start and post-stop hooks. - #34
Conversation
There was a problem hiding this comment.
Should this be an array for the args?
There was a problem hiding this comment.
As per the discussion in #20, have stuck with not using arguments but passing over a fd like stdin.
There was a problem hiding this comment.
Now I think that args might be useful. You can have one binary for multiple hooks.
There was a problem hiding this comment.
How about allowing arguments to be anything that the hooks want but still pass state over a fd?
eyakubovich
commented
Jun 30, 2015
If containers are launched under some daemon that also handles coordination, I would rather let it take care of all the lifecycle related hooks. For example, if running under systemd, why not let it invoke the pre-start and post-exit events with its Granted, my examples might be "orchestration events" rather than container life-cycle events but is there a compelling reason to explicitly add hooks for just the container life-cycle. Finally, if these hooks are being declared in the container manifest, why can't the container just have a script such as this as the entry point: Just want to push back to make sure these are truly needed. |
mrunalp
commented
Jun 30, 2015
@eyakubovich perhaps the In case of user namespaces, this allows a hook to customize the network namespace (as an examplle) before the container process is exec'ed. The counter argument to this is that why can't one just create a network namespace outside and then setns to it. However, that doesn't quite work, as each namespace has an owning user namespace and only the root user in that user namespace has all the privileges to make modifications to that namespace. Also, setns itself isn't allowed to a namespace belonging to parent user namespace or a sibling user namespace. So, such a The flow is that container One more thing of use that could be done during @LK4D4 please correct or amend as necessary. I will add this to the document. |
There was a problem hiding this comment.
We should consider the lessons learned from the docker plugins and make this more abstract names instead of absolute paths: moby/moby#13514 (comment) and moby/moby#13859
There was a problem hiding this comment.
@philips I don't mind doing that. We would be prescribing standard locations to load the hooks from then, right? Also, that doesn't gel quite well with allowing arbitrary arguments, IMO (which isn't necessarily bad but we need to define useful arguments).
LK4D4
commented
Jul 1, 2015
@mrunalp Yeah, so |
mrunalp
commented
Jul 1, 2015
Pushed update to specify directories for hooks. Still need to resolve whether we need any arguments at all? The case that @LK4D4 mentioned could be solved by symlinks or copying the hooks with different names. |
There was a problem hiding this comment.
This should be an array so that you can specify multiple binaries for a single hook.
"pre-start": [
["ps", "aux"],
["ip", "a"]
]f5c8a45 to
11b92e4CompareThere was a problem hiding this comment.
Do we need a specific directory to store the hooks in? Why can a hook not be any file on the filesystem?
There was a problem hiding this comment.
@crosbymichael That is up for debate. I am leaning towards any file. @philips do you have any arguments against?
mrunalp
commented
Jul 7, 2015
Any more thoughts for these hooks? |
wking
commented
Jul 8, 2015
On Wed, Jul 01, 2015 at 01:55:54PM -0700, Mrunal Patel wrote:
I'd rather not specify well-known directories for hooks, since that To make it easy to distribute hooks, I'd rather have relative hook In any case, I feel like allowing absolute-paths for hooks makes sense |
jonboulle
commented
Jul 8, 2015
On Wed, Jul 8, 2015 at 4:14 AM, W. Trevor King notifications@github.com
+1, location of hooks should be at implementation's discretion |
mrunalp
commented
Jul 8, 2015
Updated to take out the hooks directory paragraph. |
wking
commented
Jul 8, 2015
On Wed, Jul 08, 2015 at 09:47:38AM -0700, Mrunal Patel wrote:
Hmm. Will runc take an argument or a RUNC_HOOK_PATH environment Since this all seems complicated, I went back and reread $ cat rootfs/bin/wrap.sh You could: runc wrap.sh docker --daemonor some such to get full control over your setup/teardown without any
|
mrunalp
commented
Jul 8, 2015
@wking The hooks won't be run in the container's namespaces. They will be run from the host and they would get the state data including the container pid, so they could join the namespaces that they want to. I will clarify this in the doc if there is no objection. |
mrunalp
commented
Jul 8, 2015
Pushed update with clarification about where the hooks will be executed from. |
mrunalp
commented
Jul 8, 2015
Fixed. |
mrunalp
commented
Jul 8, 2015
For post-stop I think it makes sense to log errors and continue executing the remaining hooks. Updated to reflect that in the document and moved the previous generic section to pre-start section. |
wking
commented
Jul 8, 2015
On Wed, Jul 08, 2015 at 11:45:09AM -0700, Mrunal Patel wrote:
It looks better to me now :). My main concern with host-PATH lookups that don't include the root "hooks" : { I think it makes more sense to include the root container-bundle $ PATH=".:$PATH" runc is easy enough ;). Another thing to consider here is whether the hook-block should be |
LK4D4
commented
Jul 29, 2015
@crosbymichael Maybe I missing something. So, I need to run |
crosbymichael
commented
Jul 29, 2015
@LK4D4 if argv0 is an abs path then just set it as the path. |
LK4D4
commented
Jul 29, 2015
@crosbymichael Okay, but I still think that Args+Path more understandable, then "if first element is abs path, then argv[0] is actually argv[1]" |
mrunalp
commented
Aug 3, 2015
@crosbymichael WDYT? Need to decide one way or the other :) |
crosbymichael
commented
Aug 3, 2015
mrunalp
commented
Aug 3, 2015
@crosbymichael No problem ;) I think it makes sense to add Path, too. Updated. |
LK4D4
commented
Aug 3, 2015
LGTM |
There was a problem hiding this comment.
I would change this to after the container's namespaces are created and not say started because it's confusing with the hooks name as prestart
There was a problem hiding this comment.
How about
The pre-start hooks are called after the container process is spawned, but before the user supplied command is executed.
They are called after the container namespaces are created on Linux, so they provide an opportunity to customize the container.
In Linux, for e.g., the network namespace could be configured in this hook.
Signed-off-by: Mrunal Patel <mrunalp@gmail.com> Add hooks to the spec Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
mrunalp
commented
Aug 3, 2015
@crosbymichael updated |
crosbymichael
commented
Aug 3, 2015
LGTM |
hooks: start with pre-start and post-stop hooks.
Leaning on Go's docs [1]:
> Args holds command line arguments, including the command as
> Args[0]. If the Args field is empty or nil, Run uses {Path}.
for the fallback wording.
This restores the ability to explicitly set args[0] independent of the
path, which was requested in opencontainers#34 [2] and ack-ed by Micheal [3] and
Mrunal [4], but didn't match the examples that landed with opencontainers#34.
[1]: http://golang.org/pkg/os/exec/#Cmd
[2]: opencontainers#34 (comment)
[3]: opencontainers#34 (comment)
[4]: opencontainers#34 (comment)
Signed-off-by: W. Trevor King <wking@tremily.us>This follows Python's API, which has 'args' and 'executable' (our PATH) for Popen [1]). That allows most users (who don't need to distinguish between args[0] and the executable path) to just use args, while still providing a means to make that distinction (set 'path') for folks who do need it. This restores the ability to explicitly set args[0] independent of the path, which was requested in opencontainers#34 [2] and ack-ed by Micheal [3] and Mrunal [4], but didn't match the examples that landed with opencontainers#34. [1]: https://docs.python.org/3/library/subprocess.html#subprocess.Popen [2]: opencontainers#34 (comment) [3]: opencontainers#34 (comment) [4]: opencontainers#34 (comment) Signed-off-by: W. Trevor King <wking@tremily.us>
This follows Python's API, which has 'args' and 'executable' (our PATH) for Popen [1]). That allows most users (who don't need to distinguish between args[0] and the executable path) to just use args, while still providing a means to make that distinction (set 'path') for folks who do need it. This restores the ability to explicitly set args[0] independent of the path, which was requested in opencontainers#34 [2] and ack-ed by Micheal [3] and Mrunal [4], but didn't match the examples that landed with opencontainers#34. [1]: https://docs.python.org/3/library/subprocess.html#subprocess.Popen [2]: opencontainers#34 (comment) [3]: opencontainers#34 (comment) [4]: opencontainers#34 (comment) Signed-off-by: W. Trevor King <wking@tremily.us>
The language from 15dee2e (runtime: Add prestart/poststop hooks, 2015-08-03, opencontainers#34) landed well before we had glossary entries for the runtime and container namespaces (from 5dad125, config-linux: Specify host mount namespace for namespace paths, 2015-12-18, opencontainers#275). Now that we do have language to cover that concept, it's better to explicitly say that hooks run in the runtime namespace instead of leaving it to the reader to extrapolate from the filesystem requirement. With the new namespace wording, the "host's filesystem" wording is somewhat redundant. I've left it in though, because I think it helps to have a more gradual transition from hook paths to namespaces. Signed-off-by: W. Trevor King <wking@tremily.us>
The language from 15dee2e (runtime: Add prestart/poststop hooks, 2015-08-03, opencontainers#34) landed well before we had glossary entries for the runtime and container namespaces (from 5dad125, config-linux: Specify host mount namespace for namespace paths, 2015-12-18, opencontainers#275). Now that we do have language to cover that concept, it's better to explicitly say that hooks run in the runtime namespace instead of leaving it to the reader to extrapolate from the filesystem requirement. With the new namespace wording, the "host's filesystem" wording is somewhat redundant. I've left it in though, because I think it helps to have a more gradual transition from hook paths to namespaces. Signed-off-by: W. Trevor King <wking@tremily.us>
See #20
Starting with pre-start and post-stop and then will add more specific hooks tied to namespaces in Linux.
Signed-off-by: Mrunal Patel mrunalp@gmail.com