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

'prestart/poststart' hooks are done in the 'create' operation #1710

Closed
liangchenye opened this issue Feb 2, 2018 · 2 comments · Fixed by #2229
Closed

'prestart/poststart' hooks are done in the 'create' operation #1710

liangchenye opened this issue Feb 2, 2018 · 2 comments · Fixed by #2229
Milestone

Comments

@liangchenye
Copy link
Member

We are working on the lifecycle test and found 'runc' calls 'prestart/poststart' hooks in the 'create' phase.

It is not compliant with the spec:
https://github.com/opencontainers/runtime-spec/blob/master/config.md#prestart
https://github.com/opencontainers/runtime-spec/blob/master/config.md#poststart

There are similar OLD issues #1574 and #1135.

@liangchenye
Copy link
Member Author

Another issue found in opencontainers/runtime-tools#569.
If the poststart hook fails, 'runc' fails in 'create a container', but it should just record a warning and continue to work according to the spec.

@liangchenye
Copy link
Member Author

New issue found in opencontainers/runtime-tools#569.
If we have more than one hooks in poststart and one of them fails, the rest hooks should continue to run. But it is not now.

wking added a commit to wking/runc that referenced this issue Feb 25, 2018
Finish off the work started in a344b2d (sync up `HookState` with OCI
spec `State`, 2016-12-19, opencontainers#1201).

And drop HookState, since there's no need for a local alias for
specs.State.  And add len guards to avoid computing the state when
.Hooks is non-nil but the particular phase we're looking at is empty.

Also set c.initProcess in newInitProcess to support OCIState calls
from within initProcess.start().  I think the cyclic references
between linuxContainer and initProcess is unfortunate, but didn't want
to address that here.

I've also left the timing of the Prestart hooks alone, although the
spec calls for them to happen before start (not as part of creation)
[1,2].  Once the timing gets fixed we can drop the
initProcessStartTime hacks which initProcess.start currently needs.

I'm not sure why we trigger the prestart hooks in response to both
procReady and procHooks.  But we've had two prestart rounds in
initProcess.start since 2f27649 (Move pre-start hooks after container
mounts, 2016-02-17, opencontainers#568).  I've left that alone two.

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#prestart
[2]: opencontainers#1710

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/runc that referenced this issue Feb 25, 2018
Finish off the work started in a344b2d (sync up `HookState` with OCI
spec `State`, 2016-12-19, opencontainers#1201).

And drop HookState, since there's no need for a local alias for
specs.State.  And add len guards to avoid computing the state when
.Hooks is non-nil but the particular phase we're looking at is empty.

Also set c.initProcess in newInitProcess to support OCIState calls
from within initProcess.start().  I think the cyclic references
between linuxContainer and initProcess are unfortunate, but didn't
want to address that here.

I've also left the timing of the Prestart hooks alone, although the
spec calls for them to happen before start (not as part of creation)
[1,2].  Once the timing gets fixed we can drop the
initProcessStartTime hacks which initProcess.start currently needs.

I'm not sure why we trigger the prestart hooks in response to both
procReady and procHooks.  But we've had two prestart rounds in
initProcess.start since 2f27649 (Move pre-start hooks after container
mounts, 2016-02-17, opencontainers#568).  I've left that alone too.

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#prestart
[2]: opencontainers#1710

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/runc that referenced this issue Feb 25, 2018
Finish off the work started in a344b2d (sync up `HookState` with OCI
spec `State`, 2016-12-19, opencontainers#1201).

And drop HookState, since there's no need for a local alias for
specs.State.  And add len guards to avoid computing the state when
.Hooks is non-nil but the particular phase we're looking at is empty.

Also set c.initProcess in newInitProcess to support OCIState calls
from within initProcess.start().  I think the cyclic references
between linuxContainer and initProcess are unfortunate, but didn't
want to address that here.

I've also left the timing of the Prestart hooks alone, although the
spec calls for them to happen before start (not as part of creation)
[1,2].  Once the timing gets fixed we can drop the
initProcessStartTime hacks which initProcess.start currently needs.

I'm not sure why we trigger the prestart hooks in response to both
procReady and procHooks.  But we've had two prestart rounds in
initProcess.start since 2f27649 (Move pre-start hooks after container
mounts, 2016-02-17, opencontainers#568).  I've left that alone too.

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#prestart
[2]: opencontainers#1710

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/runc that referenced this issue Feb 25, 2018
Finish off the work started in a344b2d (sync up `HookState` with OCI
spec `State`, 2016-12-19, opencontainers#1201).

And drop HookState, since there's no need for a local alias for
specs.State.  And add len guards to avoid computing the state when
.Hooks is non-nil but the particular phase we're looking at is empty.

Also set c.initProcess in newInitProcess to support OCIState calls
from within initProcess.start().  I think the cyclic references
between linuxContainer and initProcess are unfortunate, but didn't
want to address that here.

I've also left the timing of the Prestart hooks alone, although the
spec calls for them to happen before start (not as part of creation)
[1,2].  Once the timing gets fixed we can drop the
initProcessStartTime hacks which initProcess.start currently needs.

I'm not sure why we trigger the prestart hooks in response to both
procReady and procHooks.  But we've had two prestart rounds in
initProcess.start since 2f27649 (Move pre-start hooks after container
mounts, 2016-02-17, opencontainers#568).  I've left that alone too.

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#prestart
[2]: opencontainers#1710

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/runc that referenced this issue Feb 26, 2018
Finish off the work started in a344b2d (sync up `HookState` with OCI
spec `State`, 2016-12-19, opencontainers#1201).

And drop HookState, since there's no need for a local alias for
specs.State.  And add len guards to avoid computing the state when
.Hooks is non-nil but the particular phase we're looking at is empty.

Also set c.initProcess in newInitProcess to support OCIState calls
from within initProcess.start().  I think the cyclic references
between linuxContainer and initProcess are unfortunate, but didn't
want to address that here.

I've also left the timing of the Prestart hooks alone, although the
spec calls for them to happen before start (not as part of creation)
[1,2].  Once the timing gets fixed we can drop the
initProcessStartTime hacks which initProcess.start currently needs.

I'm not sure why we trigger the prestart hooks in response to both
procReady and procHooks.  But we've had two prestart rounds in
initProcess.start since 2f27649 (Move pre-start hooks after container
mounts, 2016-02-17, opencontainers#568).  I've left that alone too.

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#prestart
[2]: opencontainers#1710

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/runc that referenced this issue Feb 27, 2018
Finish off the work started in a344b2d (sync up `HookState` with OCI
spec `State`, 2016-12-19, opencontainers#1201).

And drop HookState, since there's no need for a local alias for
specs.State.  And add len guards to avoid computing the state when
.Hooks is non-nil but the particular phase we're looking at is empty.

Also set c.initProcess in newInitProcess to support OCIState calls
from within initProcess.start().  I think the cyclic references
between linuxContainer and initProcess are unfortunate, but didn't
want to address that here.

I've also left the timing of the Prestart hooks alone, although the
spec calls for them to happen before start (not as part of creation)
[1,2].  Once the timing gets fixed we can drop the
initProcessStartTime hacks which initProcess.start currently needs.

I'm not sure why we trigger the prestart hooks in response to both
procReady and procHooks.  But we've had two prestart rounds in
initProcess.start since 2f27649 (Move pre-start hooks after container
mounts, 2016-02-17, opencontainers#568).  I've left that alone too.

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#prestart
[2]: opencontainers#1710

Signed-off-by: W. Trevor King <wking@tremily.us>
dongsupark pushed a commit to kinvolk/runc that referenced this issue May 29, 2018
Finish off the work started in a344b2d (sync up `HookState` with OCI
spec `State`, 2016-12-19, opencontainers#1201).

And drop HookState, since there's no need for a local alias for
specs.State.  And add len guards to avoid computing the state when
.Hooks is non-nil but the particular phase we're looking at is empty.

Also set c.initProcess in newInitProcess to support OCIState calls
from within initProcess.start().  I think the cyclic references
between linuxContainer and initProcess are unfortunate, but didn't
want to address that here.

I've also left the timing of the Prestart hooks alone, although the
spec calls for them to happen before start (not as part of creation)
[1,2].  Once the timing gets fixed we can drop the
initProcessStartTime hacks which initProcess.start currently needs.

I'm not sure why we trigger the prestart hooks in response to both
procReady and procHooks.  But we've had two prestart rounds in
initProcess.start since 2f27649 (Move pre-start hooks after container
mounts, 2016-02-17, opencontainers#568).  I've left that alone too.

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#prestart
[2]: opencontainers#1710

Signed-off-by: W. Trevor King <wking@tremily.us>
dongsupark pushed a commit to kinvolk/runc that referenced this issue May 30, 2018
Finish off the work started in a344b2d (sync up `HookState` with OCI
spec `State`, 2016-12-19, opencontainers#1201).

And drop HookState, since there's no need for a local alias for
specs.State.  And add len guards to avoid computing the state when
.Hooks is non-nil but the particular phase we're looking at is empty.

Also set c.initProcess in newInitProcess to support OCIState calls
from within initProcess.start().  I think the cyclic references
between linuxContainer and initProcess are unfortunate, but didn't
want to address that here.

I've also left the timing of the Prestart hooks alone, although the
spec calls for them to happen before start (not as part of creation)
[1,2].  Once the timing gets fixed we can drop the
initProcessStartTime hacks which initProcess.start currently needs.

I'm not sure why we trigger the prestart hooks in response to both
procReady and procHooks.  But we've had two prestart rounds in
initProcess.start since 2f27649 (Move pre-start hooks after container
mounts, 2016-02-17, opencontainers#568).  I've left that alone too.

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#prestart
[2]: opencontainers#1710

Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Dongsu Park <dongsu@kinvolk.io>
dongsupark pushed a commit to kinvolk/runc that referenced this issue May 30, 2018
So far Prestart, Poststart hooks have been called from the context
of create, which does not satisfy the runtime spec. That's why the
runtime-tools validation tests like `hooks_stdin.t` have failed.
Let's move call sites of Prestart, Poststart to correct places.

Unfortunately as for the Poststart hook, it's not possible to tell
whether a specific call site is from create context or run context.
That's why we needed to allow Create and Run methods to accept
another parameter `action` (of type `CtAct`). Doing that, it's possible
to set a variable `initProcess.IsCreate` that allows us distinguish
Create from Run.

It depends on a pending PR opencontainers#1741.
See also opencontainers#1710.

Signed-off-by: Dongsu Park <dongsu@kinvolk.io>
dongsupark pushed a commit to kinvolk/runc that referenced this issue May 31, 2018
Finish off the work started in a344b2d (sync up `HookState` with OCI
spec `State`, 2016-12-19, opencontainers#1201).

And drop HookState, since there's no need for a local alias for
specs.State.  And add len guards to avoid computing the state when
.Hooks is non-nil but the particular phase we're looking at is empty.

Also set c.initProcess in newInitProcess to support OCIState calls
from within initProcess.start().  I think the cyclic references
between linuxContainer and initProcess are unfortunate, but didn't
want to address that here.

I've also left the timing of the Prestart hooks alone, although the
spec calls for them to happen before start (not as part of creation)
[1,2].  Once the timing gets fixed we can drop the
initProcessStartTime hacks which initProcess.start currently needs.

I'm not sure why we trigger the prestart hooks in response to both
procReady and procHooks.  But we've had two prestart rounds in
initProcess.start since 2f27649 (Move pre-start hooks after container
mounts, 2016-02-17, opencontainers#568).  I've left that alone too.

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#prestart
[2]: opencontainers#1710

Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Dongsu Park <dongsu@kinvolk.io>
dongsupark pushed a commit to kinvolk/runc that referenced this issue May 31, 2018
So far Prestart, Poststart hooks have been called from the context
of create, which does not satisfy the runtime spec. That's why the
runtime-tools validation tests like `hooks_stdin.t` have failed.
Let's move call sites of Prestart, Poststart to correct places.

Unfortunately as for the Poststart hook, it's not possible to tell
whether a specific call site is from create context or run context.
That's why we needed to allow Create and Run methods to accept
another parameter `action` (of type `CtAct`). Doing that, it's possible
to set a variable `initProcess.IsCreate` that allows us distinguish
Create from Run.

It depends on a pending PR opencontainers#1741.
See also opencontainers#1710.

Signed-off-by: Dongsu Park <dongsu@kinvolk.io>
dongsupark pushed a commit to kinvolk/runc that referenced this issue May 31, 2018
So far Prestart, Poststart hooks have been called from the context
of create, which does not satisfy the runtime spec. That's why the
runtime-tools validation tests like `hooks_stdin.t` have failed.
Let's move call sites of Prestart, Poststart to correct places.

Unfortunately as for the Poststart hook, it's not possible to tell
whether a specific call site is from create context or run context.
That's why we needed to allow Create and Run methods to accept
another parameter `action` (of type `CtAct`). Doing that, it's possible
to set a variable `initProcess.IsCreate` that allows us distinguish
Create from Run.

It depends on a pending PR opencontainers#1741.
See also opencontainers#1710.

Signed-off-by: Dongsu Park <dongsu@kinvolk.io>
dongsupark pushed a commit to kinvolk/runc that referenced this issue Jun 4, 2018
Finish off the work started in a344b2d (sync up `HookState` with OCI
spec `State`, 2016-12-19, opencontainers#1201).

And drop HookState, since there's no need for a local alias for
specs.State.  And add len guards to avoid computing the state when
.Hooks is non-nil but the particular phase we're looking at is empty.

Also set c.initProcess in newInitProcess to support OCIState calls
from within initProcess.start().  I think the cyclic references
between linuxContainer and initProcess are unfortunate, but didn't
want to address that here.

I've also left the timing of the Prestart hooks alone, although the
spec calls for them to happen before start (not as part of creation)
[1,2].  Once the timing gets fixed we can drop the
initProcessStartTime hacks which initProcess.start currently needs.

I'm not sure why we trigger the prestart hooks in response to both
procReady and procHooks.  But we've had two prestart rounds in
initProcess.start since 2f27649 (Move pre-start hooks after container
mounts, 2016-02-17, opencontainers#568).  I've left that alone too.

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#prestart
[2]: opencontainers#1710

Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Dongsu Park <dongsu@kinvolk.io>
dongsupark pushed a commit to kinvolk/runc that referenced this issue Jun 4, 2018
So far Prestart, Poststart hooks have been called from the context
of create, which does not satisfy the runtime spec. That's why the
runtime-tools validation tests like `hooks_stdin.t` have failed.
Let's move call sites of Prestart, Poststart to correct places.

Unfortunately as for the Poststart hook, it's not possible to tell
whether a specific call site is from create context or run context.
That's why we needed to allow Create and Run methods to accept
another parameter `action` (of type `CtAct`). Doing that, it's possible
to set a variable `initProcess.IsCreate` that allows us distinguish
Create from Run.

It depends on a pending PR opencontainers#1741.
See also opencontainers#1710.

Signed-off-by: Dongsu Park <dongsu@kinvolk.io>
cyphar pushed a commit to kinvolk/runc that referenced this issue Nov 13, 2018
Finish off the work started in a344b2d (sync up `HookState` with OCI
spec `State`, 2016-12-19, opencontainers#1201).

And drop HookState, since there's no need for a local alias for
specs.State.  And add len guards to avoid computing the state when
.Hooks is non-nil but the particular phase we're looking at is empty.

Also set c.initProcess in newInitProcess to support OCIState calls
from within initProcess.start().  I think the cyclic references
between linuxContainer and initProcess are unfortunate, but didn't
want to address that here.

I've also left the timing of the Prestart hooks alone, although the
spec calls for them to happen before start (not as part of creation)
[1,2].  Once the timing gets fixed we can drop the
initProcessStartTime hacks which initProcess.start currently needs.

I'm not sure why we trigger the prestart hooks in response to both
procReady and procHooks.  But we've had two prestart rounds in
initProcess.start since 2f27649 (Move pre-start hooks after container
mounts, 2016-02-17, opencontainers#568).  I've left that alone too.

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#prestart
[2]: opencontainers#1710

Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Dongsu Park <dongsu@kinvolk.io>
cyphar pushed a commit to kinvolk/runc that referenced this issue Nov 13, 2018
So far Prestart, Poststart hooks have been called from the context
of create, which does not satisfy the runtime spec. That's why the
runtime-tools validation tests like `hooks_stdin.t` have failed.
Let's move call sites of Prestart, Poststart to correct places.

Unfortunately as for the Poststart hook, it's not possible to tell
whether a specific call site is from create context or run context.
That's why we needed to allow Create and Run methods to accept
another parameter `action` (of type `CtAct`). Doing that, it's possible
to set a variable `initProcess.IsCreate` that allows us distinguish
Create from Run.

It depends on a pending PR opencontainers#1741.
See also opencontainers#1710.

Signed-off-by: Dongsu Park <dongsu@kinvolk.io>
cyphar pushed a commit to kinvolk/runc that referenced this issue Nov 14, 2018
Finish off the work started in a344b2d (sync up `HookState` with OCI
spec `State`, 2016-12-19, opencontainers#1201).

And drop HookState, since there's no need for a local alias for
specs.State.  And add len guards to avoid computing the state when
.Hooks is non-nil but the particular phase we're looking at is empty.

Also set c.initProcess in newInitProcess to support OCIState calls
from within initProcess.start().  I think the cyclic references
between linuxContainer and initProcess are unfortunate, but didn't
want to address that here.

I've also left the timing of the Prestart hooks alone, although the
spec calls for them to happen before start (not as part of creation)
[1,2].  Once the timing gets fixed we can drop the
initProcessStartTime hacks which initProcess.start currently needs.

I'm not sure why we trigger the prestart hooks in response to both
procReady and procHooks.  But we've had two prestart rounds in
initProcess.start since 2f27649 (Move pre-start hooks after container
mounts, 2016-02-17, opencontainers#568).  I've left that alone too.

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#prestart
[2]: opencontainers#1710

Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Dongsu Park <dongsu@kinvolk.io>
Signed-off-by: Aleksa Sarai <asarai@suse.de>
cyphar pushed a commit to kinvolk/runc that referenced this issue Nov 14, 2018
So far Prestart, Poststart hooks have been called from the context
of create, which does not satisfy the runtime spec. That's why the
runtime-tools validation tests like `hooks_stdin.t` have failed.
Let's move call sites of Prestart, Poststart to correct places.

Unfortunately as for the Poststart hook, it's not possible to tell
whether a specific call site is from create context or run context.
That's why we needed to allow Create and Run methods to accept
another parameter `action` (of type `CtAct`). Doing that, it's possible
to set a variable `initProcess.IsCreate` that allows us distinguish
Create from Run.

It depends on a pending PR opencontainers#1741.
See also opencontainers#1710.

Signed-off-by: Dongsu Park <dongsu@kinvolk.io>
Signed-off-by: Aleksa Sarai <asarai@suse.de>
wking added a commit to wking/runc that referenced this issue Nov 14, 2018
Finish off the work started in a344b2d (sync up `HookState` with OCI
spec `State`, 2016-12-19, opencontainers#1201).

And drop HookState, since there's no need for a local alias for
specs.State.

Also set c.initProcess in newInitProcess to support OCIState calls
from within initProcess.start().  I think the cyclic references
between linuxContainer and initProcess are unfortunate, but didn't
want to address that here.

I've also left the timing of the Prestart hooks alone, although the
spec calls for them to happen before start (not as part of creation)
[1,2].  Once the timing gets fixed we can drop the
initProcessStartTime hacks which initProcess.start currently needs.

I'm not sure why we trigger the prestart hooks in response to both
procReady and procHooks.  But we've had two prestart rounds in
initProcess.start since 2f27649 (Move pre-start hooks after container
mounts, 2016-02-17, opencontainers#568).  I've left that alone too.

I really think we should have len() guards to avoid computing the
state when .Hooks is non-nil but the particular phase we're looking at
is empty.  Aleksa, however, is adamantly against them [3] citing a
risk of sloppy copy/pastes causing the hook slice being len-guarded to
diverge from the hook slice being iterated over within the guard.  I
think that ort of thing is very lo-risk, because:

* We shouldn't be copy/pasting this, right?  DRY for the win :).
* There's only ever a few lines between the guard and the guarded
  loop.  That makes broken copy/pastes easy to catch in review.
* We should have test coverage for these.  Guarding with the wrong
  slice is certainly not the only thing you can break with a sloppy
  copy/paste.

But I'm not a maintainer ;).

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#prestart
[2]: opencontainers#1710
[3]: opencontainers#1741

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/runc that referenced this issue Nov 14, 2018
Finish off the work started in a344b2d (sync up `HookState` with OCI
spec `State`, 2016-12-19, opencontainers#1201).

And drop HookState, since there's no need for a local alias for
specs.State.

Also set c.initProcess in newInitProcess to support OCIState calls
from within initProcess.start().  I think the cyclic references
between linuxContainer and initProcess are unfortunate, but didn't
want to address that here.

I've also left the timing of the Prestart hooks alone, although the
spec calls for them to happen before start (not as part of creation)
[1,2].  Once the timing gets fixed we can drop the
initProcessStartTime hacks which initProcess.start currently needs.

I'm not sure why we trigger the prestart hooks in response to both
procReady and procHooks.  But we've had two prestart rounds in
initProcess.start since 2f27649 (Move pre-start hooks after container
mounts, 2016-02-17, opencontainers#568).  I've left that alone too.

I really think we should have len() guards to avoid computing the
state when .Hooks is non-nil but the particular phase we're looking at
is empty.  Aleksa, however, is adamantly against them [3] citing a
risk of sloppy copy/pastes causing the hook slice being len-guarded to
diverge from the hook slice being iterated over within the guard.  I
think that ort of thing is very lo-risk, because:

* We shouldn't be copy/pasting this, right?  DRY for the win :).
* There's only ever a few lines between the guard and the guarded
  loop.  That makes broken copy/pastes easy to catch in review.
* We should have test coverage for these.  Guarding with the wrong
  slice is certainly not the only thing you can break with a sloppy
  copy/paste.

But I'm not a maintainer ;).

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#prestart
[2]: opencontainers#1710
[3]: opencontainers#1741 (comment)

Signed-off-by: W. Trevor King <wking@tremily.us>
dongsupark pushed a commit to kinvolk/runc that referenced this issue Nov 19, 2018
So far Prestart, Poststart hooks have been called from the context
of create, which does not satisfy the runtime spec. That's why the
runtime-tools validation tests like `hooks_stdin.t` have failed.
Let's move call sites of Prestart, Poststart to correct places.

Unfortunately as for the Poststart hook, it's not possible to tell
whether a specific call site is from create context or run context.
That's why we needed to allow Create and Run methods to accept
another parameter `action` (of type `CtAct`). Doing that, it's possible
to set a variable `initProcess.IsCreate` that allows us distinguish
Create from Run.

See also opencontainers#1710.

Signed-off-by: Dongsu Park <dongsu@kinvolk.io>
wking added a commit to wking/libpod that referenced this issue Nov 19, 2018
There's been a lot of discussion over in [1] about how to support the
NVIDIA folks and others who want to be able to create devices
(possibly after having loaded kernel modules) and bind userspace
libraries into the container.  Currently that's happening in the
middle of runc's create-time mount handling before the container
pivots to its new root directory with runc's incorrectly-timed
prestart hook trigger [2].  With this commit, we extend hooks with a
'precreate' stage to allow trusted parties to manipulate the config
JSON before calling the runtime's 'create'.

I'm recycling the existing Hook schema from pkg/hooks for this,
because we'll want Timeout for reliability and When to avoid the
expense of fork/exec when a given hook does not need to make config
changes [3].

[1]: opencontainers/runc#1811
[2]: opencontainers/runc#1710
[3]: containers#1828 (comment)
wking added a commit to wking/libpod that referenced this issue Nov 19, 2018
There's been a lot of discussion over in [1] about how to support the
NVIDIA folks and others who want to be able to create devices
(possibly after having loaded kernel modules) and bind userspace
libraries into the container.  Currently that's happening in the
middle of runc's create-time mount handling before the container
pivots to its new root directory with runc's incorrectly-timed
prestart hook trigger [2].  With this commit, we extend hooks with a
'precreate' stage to allow trusted parties to manipulate the config
JSON before calling the runtime's 'create'.

I'm recycling the existing Hook schema from pkg/hooks for this,
because we'll want Timeout for reliability and When to avoid the
expense of fork/exec when a given hook does not need to make config
changes [3].

[1]: opencontainers/runc#1811
[2]: opencontainers/runc#1710
[3]: containers#1828 (comment)

Signed-off-by: W. Trevor King <wking@tremily.us>
@cyphar cyphar modified the milestones: 1.0.0-rc6, 1.0.0 Nov 21, 2018
wking added a commit to wking/libpod that referenced this issue Dec 3, 2018
There's been a lot of discussion over in [1] about how to support the
NVIDIA folks and others who want to be able to create devices
(possibly after having loaded kernel modules) and bind userspace
libraries into the container.  Currently that's happening in the
middle of runc's create-time mount handling before the container
pivots to its new root directory with runc's incorrectly-timed
prestart hook trigger [2].  With this commit, we extend hooks with a
'precreate' stage to allow trusted parties to manipulate the config
JSON before calling the runtime's 'create'.

I'm recycling the existing Hook schema from pkg/hooks for this,
because we'll want Timeout for reliability and When to avoid the
expense of fork/exec when a given hook does not need to make config
changes [3].

[1]: opencontainers/runc#1811
[2]: opencontainers/runc#1710
[3]: containers#1828 (comment)

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/libpod that referenced this issue Dec 13, 2018
There's been a lot of discussion over in [1] about how to support the
NVIDIA folks and others who want to be able to create devices
(possibly after having loaded kernel modules) and bind userspace
libraries into the container.  Currently that's happening in the
middle of runc's create-time mount handling before the container
pivots to its new root directory with runc's incorrectly-timed
prestart hook trigger [2].  With this commit, we extend hooks with a
'precreate' stage to allow trusted parties to manipulate the config
JSON before calling the runtime's 'create'.

I'm recycling the existing Hook schema from pkg/hooks for this,
because we'll want Timeout for reliability and When to avoid the
expense of fork/exec when a given hook does not need to make config
changes [3].

[1]: opencontainers/runc#1811
[2]: opencontainers/runc#1710
[3]: containers#1828 (comment)

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/libpod that referenced this issue Dec 13, 2018
There's been a lot of discussion over in [1] about how to support the
NVIDIA folks and others who want to be able to create devices
(possibly after having loaded kernel modules) and bind userspace
libraries into the container.  Currently that's happening in the
middle of runc's create-time mount handling before the container
pivots to its new root directory with runc's incorrectly-timed
prestart hook trigger [2].  With this commit, we extend hooks with a
'precreate' stage to allow trusted parties to manipulate the config
JSON before calling the runtime's 'create'.

I'm recycling the existing Hook schema from pkg/hooks for this,
because we'll want Timeout for reliability and When to avoid the
expense of fork/exec when a given hook does not need to make config
changes [3].

[1]: opencontainers/runc#1811
[2]: opencontainers/runc#1710
[3]: containers#1828 (comment)

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/libpod that referenced this issue Jan 9, 2019
There's been a lot of discussion over in [1] about how to support the
NVIDIA folks and others who want to be able to create devices
(possibly after having loaded kernel modules) and bind userspace
libraries into the container.  Currently that's happening in the
middle of runc's create-time mount handling before the container
pivots to its new root directory with runc's incorrectly-timed
prestart hook trigger [2].  With this commit, we extend hooks with a
'precreate' stage to allow trusted parties to manipulate the config
JSON before calling the runtime's 'create'.

I'm recycling the existing Hook schema from pkg/hooks for this,
because we'll want Timeout for reliability and When to avoid the
expense of fork/exec when a given hook does not need to make config
changes [3].

[1]: opencontainers/runc#1811
[2]: opencontainers/runc#1710
[3]: containers#1828 (comment)

Signed-off-by: W. Trevor King <wking@tremily.us>
dongsupark pushed a commit to dongsupark/runc that referenced this issue Jul 10, 2019
So far Prestart, Poststart hooks have been called from the context
of create, which does not satisfy the runtime spec. That's why the
runtime-tools validation tests like `hooks_stdin.t` have failed.
Let's move call sites of Prestart, Poststart to correct places.

Unfortunately as for the Poststart hook, it's not possible to tell
whether a specific call site is from create context or run context.
That's why we needed to allow Create and Run methods to accept
another parameter `action` (of type `CtAct`). Doing that, it's possible
to set a variable `initProcess.IsCreate` that allows us distinguish
Create from Run.

See also opencontainers#1710.

Signed-off-by: Dongsu Park <dongsu@kinvolk.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants