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

Add option to specify containerd runtime #4141

Closed

Conversation

slonopotamus
Copy link
Contributor

@slonopotamus slonopotamus commented Aug 13, 2023

Thoughts: it could just be runtime or default runtime, hinting that in the future specific build run can override it.

@slonopotamus slonopotamus mentioned this pull request Aug 13, 2023
4 tasks
cmd/buildkitd/config/config.go Show resolved Hide resolved
cmd/buildkitd/main_containerd_worker.go Outdated Show resolved Hide resolved
@tonistiigi
Copy link
Member

5.865 # github.com/moby/buildkit/cmd/buildkitd
5.865 cmd/buildkitd/main_containerd_worker.go:54:45: undefined: defaults

@slonopotamus
Copy link
Contributor Author

Added missing import.

@slonopotamus
Copy link
Contributor Author

I believe that TestRuncWorkerExec failure on CI is unrelated to this PR: #4146

@@ -112,6 +112,7 @@ type ContainerdConfig struct {
Labels map[string]string `toml:"labels"`
Platforms []string `toml:"platforms"`
Namespace string `toml:"namespace"`
Runtime string `toml:"runtime"`
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this support options for runc binary path, cgroup driver, etc?
I also guess this should be map[string]interface{} to support multiple runtime classes in the future.

i.e., The config structure should be similar to the config structure of containerd/CRI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure how to pass that to containerd. What I just wanted to achieve is to be able to override client.defaultRuntime. Because there are cough, cough platforms where runtime isn't mature enough to be declared The Default.

The lack of such configuration option leaded to FreeBSD runtime being hardcoded in buildkit. I'm in the same boat with macOS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, my idea is: with these changes, one can configure runtime options in containerd config, while using buildkit to select needed runtime. Or, option added here can just be used to specify path path to runtime binary. Exposing the full runtime configuration through buildkit config is too much extending the scope of the task.

Copy link
Member

Choose a reason for hiding this comment

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

Some related work in moby;

I need to refresh my memory (but perhaps the code describes it), but ISTR, we only allowed paths etc to be configured for the legacy bits, and otherwise only allow a (fully qualified?) reference to be specified, or at least from the client side (to prevent a arbitrary paths to be passed that are not in the server's PATH).

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 I missed this originally. We should probably make sure to cover this is in a first pass - I wrote up a possible implementation: jedevc@22d9bb1. @AkihiroSuda @tonistiigi wdyt? (I took inspiration from how CRI does it today). @slonopotamus you happy to pull that change into your branch (or I can force-push)?

Without a way to configure the runtime, I think the feature is quite limited (e.g. I have a use case for wanting to override the runc binary used by the io.containerd.runc.v2 runtime, which is possible by using the binary_name option). Containerd doesn't seem to have any other way to configure this, so we need to allow this configuration in buildkit if we want to allow users this kind of freedom.

Even if we don't take this now, we need to provide a place in config fields to allow this kind of configuration. Previously we had:

[worker.containerd]
runtime = "io.containerd.runc.v2"

I think something like this should work easily:

[worker.containerd.runtime]
name = "io.containerd.runc.v2"
options = { binary_name = "foobar" }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jedevc I'm perfectly fine if you create a separate PR. I just need a way to specify which runtime to use, it isn't really important what lines one would need to write into config file, it is easy to adapt.

Copy link
Member

Choose a reason for hiding this comment

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

Opened in #4279.

Copy link
Collaborator

@ktock ktock left a comment

Choose a reason for hiding this comment

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

LGTM
maybe we'll need to use containerd's WithRuntime if we want to allow users fully configuring the shim behaviour (as commented in #4141 (comment))

https://github.com/containerd/containerd/blob/d015c99b2ec990c914a4b4546ec10d61cd947ab0/container_opts.go#L58

@slonopotamus
Copy link
Contributor Author

User already can fully configure runtime in containerd config. I don't see much value adding a second place with exactly the same settings. And then the third, to allow configuration of all that through Moby config?

@AkihiroSuda
Copy link
Member

User already can fully configure runtime in containerd config. I don't see much value adding a second place with exactly the same settings. And then the third, to allow configuration of all that through Moby config?

The first one only applies to CRI, not to BuildKit and Moby.
It would be nice to have a unified configuration registry, but that may take a time.

@slonopotamus
Copy link
Contributor Author

slonopotamus commented Sep 17, 2023

BTW, Moby already has map[string,Runtime]. So, both containerd and Moby can use different runtimes. It's only buildctl that doesn't have an option to specify which runtime to use.

docs/buildkitd.toml.md Outdated Show resolved Hide resolved
Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
@@ -46,6 +48,14 @@ func init() {
defaultConf.Workers.Containerd.Namespace = defaultContainerdNamespace
}

if defaultConf.Workers.Containerd.Runtime == "" {
if runtime.GOOS == "freebsd" {
defaultConf.Workers.Containerd.Runtime = "wtf.sbk.runj.v1"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a TODO saying it should be removed once containerd/containerd#8964 comes with a containerd release?

@tonistiigi
Copy link
Member

#4279

@tonistiigi tonistiigi closed this Sep 26, 2023
@slonopotamus
Copy link
Contributor Author

@jedevc thanks for pushing this to the end!

@slonopotamus slonopotamus deleted the containerd-runtime-option branch September 27, 2023 19:58
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.

8 participants