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

rootless: containerd worker: Add fallback when buildkitd cannot access to conainerd #2968

Merged
merged 1 commit into from Jul 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions cmd/buildkitd/main_containerd_worker.go
Expand Up @@ -228,7 +228,7 @@ func containerdWorkerInitializer(c *cli.Context, common workerInitializerOpt) ([

cfg := common.config.Workers.Containerd

if (cfg.Enabled == nil && !validContainerdSocket(cfg.Address)) || (cfg.Enabled != nil && !*cfg.Enabled) {
if (cfg.Enabled == nil && !validContainerdSocket(cfg)) || (cfg.Enabled != nil && !*cfg.Enabled) {
return nil, nil
}

Expand Down Expand Up @@ -281,7 +281,8 @@ func containerdWorkerInitializer(c *cli.Context, common workerInitializerOpt) ([
return []worker.Worker{w}, nil
}

func validContainerdSocket(socket string) bool {
func validContainerdSocket(cfg config.ContainerdConfig) bool {
socket := cfg.Address
if strings.HasPrefix(socket, "tcp://") {
// FIXME(AkihiroSuda): prohibit tcp?
return true
Expand All @@ -292,6 +293,14 @@ func validContainerdSocket(socket string) bool {
logrus.Warnf("skipping containerd worker, as %q does not exist", socketPath)
return false
}
// TODO: actually dial and call introspection API
c, err := ctd.New(socketPath, ctd.WithDefaultNamespace(cfg.Namespace))
if err != nil {
logrus.Warnf("skipping containerd worker, as failed to connect client to %q: %v", socketPath, err)
return false
}
if _, err := c.Server(context.Background()); err != nil {
logrus.Warnf("skipping containerd worker, as failed to call introspection API on %q: %v", socketPath, err)
return false
}
return true
}