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

container, hooks: Proposal and support for running createContainer hooks before setting up mounts #827

Closed

Conversation

flouthoc
Copy link
Collaborator

There are use cases of createContainer hooks which can perform
operation on mounts before libcrun_set_mounts for a container

Example creating a nfs mount or a fresh source for bind mount which
was supplied to container.

Also typical use-case from runtime-spec gives example of running
mount fix-ups as hook when we do createContainer

Ref: https://github.com/opencontainers/runtime-spec/blob/main/config.md#example-2

However it will not be possible if we do libcrun_set_mounts before
running createContainer hooks following PR proposes and fixes that.

A use-case is being discussed here: containers/podman#12650

…oks before setting up mounts

There are use cases of `createContainer` hooks which can perform
operation on mounts before `libcrun_set_mounts` for a container

Example creating a `nfs mount` or a fresh source for `bind` mount which
was supplied to container.

Typical use-case example from `runtime-spec` gives example of running
`mount` fix-ups as `hook` when we do `createContainer`

Ref: https://github.com/opencontainers/runtime-spec/blob/main/config.md#example-2

However it will not be possible if we do `libcrun_set_mounts` before
running `createContainer` hooks following PR proposes and fixes that.

Signed-off-by: Aditya Rajan <[email protected]>
@flouthoc
Copy link
Collaborator Author

@giuseppe PTAL.

@flouthoc
Copy link
Collaborator Author

Marking this PR as draft till I can confirm when does runc execute createContainer hooks as we don't want to introduce behavior drift between runc and crun.

@flouthoc flouthoc marked this pull request as draft December 23, 2021 09:25
Comment on lines +1057 to +1065
if (def->hooks && def->hooks->create_container_len)
{
ret = do_hooks (def, 0, container->context->id, false, NULL, "created", (hook **) def->hooks->create_container,
def->hooks->create_container_len, entrypoint_args->hooks_out_fd, entrypoint_args->hooks_err_fd,
err);
if (UNLIKELY (ret != 0))
return ret;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should happen after the mounts are configured but before doing the pivot_root

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree we cannot do createContainer hooks before setMounts as its a behavior change.

@flouthoc
Copy link
Collaborator Author

Marking this PR as draft till I can confirm when does runc execute createContainer hooks as we don't want to introduce behavior drift between runc and crun.

Runc behaves exactly as crun is behaving now. We cannot do behavior changes hence closing this PR

@flouthoc flouthoc closed this Dec 23, 2021
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 this pull request may close these issues.

2 participants