propagate the dockerd cgroup-parent config to buildkitd
Signed-off-by: Anda Xu <anda.xu@docker.com> (cherry picked from commit d52485c2f901e62e9a26445e230ec3f6662fa276) Upstream-commit: e8620110fcbfca840e91bfb06348da8d9fd53e2e Component: engine
This commit is contained in:
@@ -50,11 +50,11 @@ func init() {
|
||||
|
||||
// Opt is option struct required for creating the builder
|
||||
type Opt struct {
|
||||
SessionManager *session.Manager
|
||||
Root string
|
||||
NetnsRoot string
|
||||
Dist images.DistributionServices
|
||||
NetworkController libnetwork.NetworkController
|
||||
SessionManager *session.Manager
|
||||
Root string
|
||||
Dist images.DistributionServices
|
||||
NetworkController libnetwork.NetworkController
|
||||
DefaultCgroupParent string
|
||||
}
|
||||
|
||||
// Builder can build using BuildKit backend
|
||||
|
||||
@@ -102,7 +102,7 @@ func newController(rt http.RoundTripper, opt Opt) (*control.Controller, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
exec, err := newExecutor(root, opt.NetnsRoot, opt.NetworkController)
|
||||
exec, err := newExecutor(root, opt.DefaultCgroupParent, opt.NetworkController)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -19,15 +19,16 @@ import (
|
||||
|
||||
const networkName = "bridge"
|
||||
|
||||
func newExecutor(root, netnsRoot string, net libnetwork.NetworkController) (executor.Executor, error) {
|
||||
func newExecutor(root, cgroupParent string, net libnetwork.NetworkController) (executor.Executor, error) {
|
||||
networkProviders := map[pb.NetMode]network.Provider{
|
||||
pb.NetMode_UNSET: &bridgeProvider{NetworkController: net, netnsRoot: netnsRoot},
|
||||
pb.NetMode_HOST: network.NewHostProvider(),
|
||||
pb.NetMode_NONE: network.NewNoneProvider(),
|
||||
}
|
||||
return runcexecutor.New(runcexecutor.Opt{
|
||||
Root: filepath.Join(root, "executor"),
|
||||
CommandCandidates: []string{"docker-runc", "runc"},
|
||||
Root: filepath.Join(root, "executor"),
|
||||
CommandCandidates: []string{"docker-runc", "runc"},
|
||||
DefaultCgroupParent: cgroupParent,
|
||||
}, networkProviders)
|
||||
}
|
||||
|
||||
|
||||
@@ -284,12 +284,23 @@ func newRouterOptions(config *config.Config, daemon *daemon.Daemon) (routerOptio
|
||||
if err != nil {
|
||||
return opts, err
|
||||
}
|
||||
cgroupParent := "docker"
|
||||
useSystemd := daemon.UsingSystemd(config)
|
||||
if useSystemd {
|
||||
cgroupParent = "system.slice"
|
||||
}
|
||||
if config.CgroupParent != "" {
|
||||
cgroupParent = config.CgroupParent
|
||||
}
|
||||
if useSystemd {
|
||||
cgroupParent = cgroupParent + ":" + "docker" + ":"
|
||||
}
|
||||
bk, err := buildkit.New(buildkit.Opt{
|
||||
SessionManager: sm,
|
||||
Root: filepath.Join(config.Root, "buildkit"),
|
||||
NetnsRoot: filepath.Join(config.ExecRoot, "netns"),
|
||||
Dist: daemon.DistributionServices(),
|
||||
NetworkController: daemon.NetworkController(),
|
||||
SessionManager: sm,
|
||||
Root: filepath.Join(config.Root, "buildkit"),
|
||||
Dist: daemon.DistributionServices(),
|
||||
NetworkController: daemon.NetworkController(),
|
||||
DefaultCgroupParent: cgroupParent,
|
||||
})
|
||||
if err != nil {
|
||||
return opts, err
|
||||
|
||||
Reference in New Issue
Block a user