Skip to content

Conversation

@cpuguy83
Copy link
Member

@cpuguy83 cpuguy83 commented Jul 7, 2020

- What I did

Move all shim config into "runtime" type, and adds 2 new built-in runtimes to allow explicitly switching from runc+shimv1 and runc+shimv2

- How I did it

Add a ShimConfig type to types.Runtime which stores the shim config.
The daemon then uses that instead of having things spread between daemon and libcontainerd, some bool passing, etc.

This option is only exposed internally, i.e. it cannot be set from daemon.json.
This is due to issues being able to support unknown shims which requires knowing types to pass to those shims (e.g. does it need a runc v2 shim config, a runc v1 shim config, or some other entirely different shim).

- How to verify it

Set --default-runtime=com.docker.runtime.runc.v2, run a container (and/or a plugin), check the process tree and see the container was created with /usr/local/bin/containerd-shim-runc-v2

- Description for the changelog

Add support new built-in runtime for using the containerd v2 shim by using the runtime com.docker.runtime.runc.v2

Copy link
Member Author

Choose a reason for hiding this comment

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

Note here I did not carry through with this custom runtime root path either since it doesn't really seem necessary.

@cpuguy83 cpuguy83 added this to the 20.03.0 milestone Jul 7, 2020
Copy link
Member

Choose a reason for hiding this comment

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

Why not just use containerd runtime name?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did this because we provide our own configuration... but maybe it's not needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

FYI this code moved in my last push, but is currently unchanged.

Copy link
Member

Choose a reason for hiding this comment

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

Let's just use containerd names to avoid confusion.

@cpuguy83 cpuguy83 force-pushed the runtime_configure_shim branch from 1f0ef3d to 32065d5 Compare July 8, 2020 00:44
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Member

Choose a reason for hiding this comment

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

You mean: why a script? I recall there was a discussion about that in #37978 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

This is old code, I just moved it out of a huge file to group it with other runtime code.

It's here because containerd does not accept extra arguments passed to the oci runtime.

Copy link
Member

Choose a reason for hiding this comment

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

Unrelated to this PR but we should do a validation of the permissions of this path every time it is used. Otherwise, this looks quite scary.

Copy link
Member

Choose a reason for hiding this comment

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

Should we rename to Default ? (and deprecate the old one?)

Copy link
Member Author

Choose a reason for hiding this comment

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

The variable name?

Copy link
Member

Choose a reason for hiding this comment

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

yes

@cpuguy83 cpuguy83 force-pushed the runtime_configure_shim branch 2 times, most recently from 7354d8c to 794c66d Compare July 9, 2020 17:43
@thaJeztah
Copy link
Member

@AkihiroSuda @tonistiigi PTAL

@cpuguy83 cpuguy83 force-pushed the runtime_configure_shim branch from 794c66d to 481ec2b Compare July 9, 2020 18:14
@cpuguy83
Copy link
Member Author

cpuguy83 commented Jul 9, 2020

Updated this to add deprecation warnings for the v1 runtime.

Re: naming the runtimes

The containerd names are confusing. I'm not sure if it's good to use them or not. Just thinking about it.

@cpuguy83 cpuguy83 force-pushed the runtime_configure_shim branch from 481ec2b to 99ea6b9 Compare July 9, 2020 19:54
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@cpuguy83 cpuguy83 force-pushed the runtime_configure_shim branch 3 times, most recently from d9d5945 to dfb02f4 Compare July 10, 2020 22:26
@cpuguy83
Copy link
Member Author

Tests are all green now, at least.

Copy link
Contributor

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM(nb)

@fuweid
Copy link
Contributor

fuweid commented Jul 13, 2020

The containerd names are confusing. I'm not sure if it's good to use them or not. Just thinking about it.

Legacy shim doesn't have version. Both runc.v1 and runc.v2 are shimv2 lol

@AkihiroSuda
Copy link
Member

My concern is that runc.v1 with the com.docker. prefix is shim API v1...

@cpuguy83
Copy link
Member Author

Yeah, perhaps I should just use the containerd shim names as the runtime name.
This is only included as a fallback for edge cases anyway, and we can document that.

In dockerd we already have a concept of a "runtime", which specifies the
OCI runtime to use (e.g. runc).
This PR extends that config to add containerd shim configuration.
This option is only exposed within the daemon itself (cannot be
configured in daemon.json).
This is due to issues in supporting unknown shims which will require
more design work.

What this change allows us to do is keep all the runtime config in one
place.

So the default "runc" runtime will just have it's already existing shim
config codified within the runtime config alone.
I've also added 2 more "stock" runtimes which are basically runc+shimv1
and runc+shimv2.
These new runtime configurations are:

- io.containerd.runtime.v1.linux - runc + v1 shim using the V1 shim API
- io.containerd.runc.v2 - runc + shim v2

These names coincide with the actual names of the containerd shims.

This allows the user to essentially control what shim is going to be
used by either specifying these as a `--runtime` on container create or
by setting `--default-runtime` on the daemon.

For custom/user-specified runtimes, the default shim config (currently
shim v1) is used.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@cpuguy83 cpuguy83 force-pushed the runtime_configure_shim branch from dfb02f4 to f63f73a Compare July 13, 2020 21:20
@cpuguy83
Copy link
Member Author

I've updated this to use the shim names as our runtime name.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

@tonistiigi PTAL

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

SGTM

@cpuguy83 cpuguy83 merged commit 61b73ee into moby:master Jul 14, 2020
@cpuguy83 cpuguy83 deleted the runtime_configure_shim branch July 14, 2020 21:16
@thaJeztah
Copy link
Member

Looks like this may have introduced a regression (panic when configuring custom runtime); docker/for-linux#1169

if err != nil {
return errors.Wrap(err, "failed to get temp dir to generate runtime scripts")
if hostConfig.Runtime == config.LinuxV1RuntimeName || (hostConfig.Runtime == "" && daemon.configStore.DefaultRuntime == config.LinuxV1RuntimeName) {
warnings = append(warnings, fmt.Sprintf("Configured runtime %q is deprecated and will be removed in the next release.", config.LinuxV1RuntimeName))
Copy link
Member

Choose a reason for hiding this comment

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

We need to add a line to the deprecation log; https://github.com/docker/cli/blob/master/docs/deprecated.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants