Skip to content

[RFC] libcontainerd/supervisor: use containerd's defaults#43950

Draft
thaJeztah wants to merge 1 commit intomoby:masterfrom
thaJeztah:containerd_defaults
Draft

[RFC] libcontainerd/supervisor: use containerd's defaults#43950
thaJeztah wants to merge 1 commit intomoby:masterfrom
thaJeztah:containerd_defaults

Conversation

@thaJeztah
Copy link
Member

When starting a managed containerd instance, we currently configure the instance
to use alternative runtime and storage locations, and alternative paths for the
socket (for Windows, we used the same named pipes).

The reason for this was that we didn't want to conflict with an already running
containerd service when manually starting dockerd. As we currently only use
containerd as runtime (but not for image management), this works well, as all
(most) information in containerd is considered ephemeral, and we re-create
containers when starting the daemon.

However, with work being in progress on using containerd also for image management,
containerd's storage can no longer be considered ephemeral, and using the
alternative configuration will limit the ability to (temporarily) start
dockerd manually for debugging, i.e.;

systemctr stop containerd docker
dockerd --debug

When using containerd for image storage, the above will now start a containerd
instance with a different storage location as the one that was running as
(systemd) service, and does not contain the images and snapshots that are
expected.

This patch changes the managed containerd configuration to use most of containerd's
default settings, with the exception of the CRI plugin being disabled by default
on the managed instance (which can be enabled using the --cri-containerd flag).

The daemon will still detect if an instance of containerd is already running, so
that in situations where the docker service was stopped, but the containerd
service is still running, the already running containerd service to be used
(assuming it's using the default location).

To be discussed

This patch currently does not contain any migration code, so no content is migrated
from the "old" location to the new; as most (all?) data we add to containerd is
ephemeral (except for manifests we store?) we may not have to do any migration,
but we should look if anything is needed.

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah added this to the v-next milestone Aug 11, 2022
@thaJeztah thaJeztah changed the title libcontainerd/supervisor: use containerd's defaults [RFC] libcontainerd/supervisor: use containerd's defaults Aug 11, 2022
@thaJeztah
Copy link
Member Author

This might explode in CI, as we're spinning up many daemons there 🤔 😂 , so possibly some option is needed to make storage and socket configurable.

@thaJeztah thaJeztah marked this pull request as draft August 11, 2022 20:06
@thaJeztah
Copy link
Member Author

We discussed this in the maintainers meeting, and there's a lot of different angles on this change; this change will have both "pros" and "const", but so does the old configuration. Some of this scenarios can be a big concern, so we need to write down possible scenarios and pros/cons for each of them.

Comment on lines -72 to -74
Root: filepath.Join(rootDir, "daemon"),
State: filepath.Join(stateDir, "daemon"),
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 just noticed that we may have an issue here; it looks like libcontainerd client has these paths effectively hard-coded to be inside /var/run/docker/containerd/; at least, I see no code that checks what containerd's directory is for those.

filepath.Join(daemon.configStore.ExecRoot, "containerd"),

filepath.Join(daemon.configStore.ExecRoot, "containerd"),

func WithBundle(bundleDir string, ociSpec *specs.Spec) containerd.NewContainerOpts {

func (c *client) bundleDir(id string) string {
return filepath.Join(c.stateDir, id)
}

For plugins (linux) it uses /run/docker/plugins;

func getPluginExecRoot(root string) string {
return "/run/docker/plugins"
}

For windows, something under the daemon's "root" directory (which is confusing, as "root" (data) is used as "exec" (runtime) path;

func getPluginExecRoot(root string) string {
return filepath.Join(root, "plugins")
}

Copy link
Member Author

@thaJeztah thaJeztah Aug 12, 2022

Choose a reason for hiding this comment

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

Oh, I guess part of this is addressed in rumpl#40, but we probably still need to look for the "not-containerd as snapshotter" situation with a custom configuration? 🤔

ctr -n moby c ls
CONTAINER                                                           IMAGE                              RUNTIME
88029cbb7fce14c22801513c7fd551fe1a1918719a33dd5f3fbfff3100e3c120    -                                  io.containerd.runc.v2

ls /var/run/docker/containerd
88029cbb7fce14c22801513c7fd551fe1a1918719a33dd5f3fbfff3100e3c120

And creating a container through ctr;

ctr -n moby image pull docker.io/lilbrary/nginx:alpine
ctr -n moby container create docker.io/library/nginx:alpine mycontainer
ctr -n moby task start --detach mycontainer
ctr -n moby container ls
CONTAINER                                                           IMAGE                             RUNTIME
88029cbb7fce14c22801513c7fd551fe1a1918719a33dd5f3fbfff3100e3c120    -                                 io.containerd.runc.v2
mycontainer                                                         docker.io/library/nginx:alpine    io.containerd.runc.v2

So, the container does not end up in /var/run/docker/containerd

But the task does;

ls /var/run/containerd/io.containerd.runtime.v2.task/moby/
88029cbb7fce14c22801513c7fd551fe1a1918719a33dd5f3fbfff3100e3c120  mycontainer

@tianon
Copy link
Member

tianon commented Aug 31, 2022

IMO this is good -- this won't affect most Linux users who should have "proper" systemd dependencies, and for Docker-in-Docker users this is going to be a transition no matter how it works (this just makes that transition more straightforward by having containerd use the expected locations, config, etc no matter how it's started).

When starting a managed containerd instance, we currently configure the instance
to use alternative runtime and storage locations, and alternative paths for the
socket (for Windows, we used the same named pipes).

The reason for this was that we didn't want to conflict with an already running
containerd service when manually starting dockerd. As we currently only use
containerd as runtime (but not for image management), this works well, as all
(most) information in containerd is considered ephemeral, and we re-create
containers when starting the daemon.

However, with work being in progress on using containerd also for image management,
containerd's storage can no longer be considered ephemeral, and using the
alternative configuration will limit the ability to (temporarily) start
dockerd manually for debugging, i.e.;

```bash
systemctr stop containerd docker
dockerd --debug
```

When using containerd for image storage, the above will now start a containerd
instance with a different storage location as the one that was running as
(systemd) service, and does not contain the images and snapshots that are
expected.

This patch changes the managed containerd configuration to use most of containerd's
default settings, with the exception of the CRI plugin being disabled by default
on the managed instance (which can be enabled using the `--cri-containerd` flag).

The daemon will still detect if an instance of containerd is already running, so
that in situations where the `docker` service was stopped, but the `containerd`
service is still running, the already running `containerd` service to be used
(assuming it's using the default location).

To be discussed
-------------------------

This patch currently does not contain any migration code, so no content is migrated
from the "old" location to the new; as most (all?) data we add to containerd is
ephemeral (except for manifests we store?) we may not have to do any migration,
but we should look if anything is needed.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah force-pushed the containerd_defaults branch from 056f405 to 3ad1e71 Compare June 13, 2023 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Needs sorting
Status: In progress

Development

Successfully merging this pull request may close these issues.

3 participants