-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- [X] put multiples workers in a single binary ("-tags containerd standalone") - [X] add worker selector to LLB vertex metadata - [ ] allow using multiples workers (requires inter-vertex cache copier, HUGE!) Implementation notes: - A new structure called "metaworker" holds a worker instance and its related stuffs such as the snapshotter - For containerd, we have separate workers for each of the available snapshotters: containerd-overlay, containerd-btrfs, ... - The default worker is "runc-overlay" Signed-off-by: Akihiro Suda <[email protected]>
- Loading branch information
1 parent
d66501e
commit e3e3115
Showing
23 changed files
with
704 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,62 @@ | ||
// +build containerd,!standalone | ||
// +build containerd | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/moby/buildkit/control" | ||
"os" | ||
"strings" | ||
|
||
"github.com/moby/buildkit/metaworker" | ||
"github.com/moby/buildkit/metaworker/containerd" | ||
"github.com/sirupsen/logrus" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
func appendFlags(f []cli.Flag) []cli.Flag { | ||
return append(f, []cli.Flag{ | ||
func init() { | ||
appFlags = append(appFlags, | ||
cli.BoolFlag{ | ||
Name: "disable-containerd", | ||
Usage: "disable containerd workers", | ||
}, | ||
cli.StringFlag{ | ||
Name: "containerd", | ||
Usage: "containerd socket", | ||
Value: "/run/containerd/containerd.sock", | ||
}, | ||
}...) | ||
}) | ||
// 1 is less preferred than 0 (runcCtor) | ||
metaWorkerCtors[1] = containerdCtor | ||
} | ||
|
||
// root must be an absolute path | ||
func newController(c *cli.Context, root string) (*control.Controller, error) { | ||
func containerdCtor(c *cli.Context, root string) ([]*metaworker.MetaWorker, error) { | ||
socket := c.GlobalString("containerd") | ||
if c.GlobalBool("disable-containerd") || skipContainerd(socket) { | ||
return nil, nil | ||
} | ||
opts, err := containerd.NewMetaWorkerOpts(root, socket) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var mws []*metaworker.MetaWorker | ||
for _, opt := range opts { | ||
mw, err := metaworker.NewMetaWorker(opt) | ||
if err != nil { | ||
return mws, err | ||
} | ||
mws = append(mws, mw) | ||
} | ||
return mws, nil | ||
} | ||
|
||
return control.NewContainerd(root, socket) | ||
func skipContainerd(socket string) bool { | ||
if strings.HasPrefix(socket, "tcp://") { | ||
// FIXME(AkihiroSuda): prohibit tcp? | ||
return false | ||
} | ||
socketPath := strings.TrimPrefix(socket, "unix://") | ||
if _, err := os.Stat(socketPath); os.IsNotExist(err) { | ||
// FIXME(AkihiroSuda): add more conditions | ||
logrus.Warnf("skipping containerd, as %q does not exist", socketPath) | ||
return true | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,39 @@ | ||
// +build standalone,!containerd | ||
// +build standalone | ||
|
||
// TODO(AkihiroSuda): s/standalone/runc/g | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/moby/buildkit/control" | ||
"github.com/moby/buildkit/metaworker" | ||
"github.com/moby/buildkit/metaworker/runc" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
func appendFlags(f []cli.Flag) []cli.Flag { | ||
return f | ||
func init() { | ||
appFlags = append(appFlags, | ||
cli.BoolFlag{ | ||
Name: "disable-runc", | ||
Usage: "disable runc workers", | ||
}) | ||
metaWorkerCtors[0] = runcCtor | ||
} | ||
|
||
// root must be an absolute path | ||
func newController(c *cli.Context, root string) (*control.Controller, error) { | ||
return control.NewStandalone(root) | ||
func runcCtor(c *cli.Context, root string) ([]*metaworker.MetaWorker, error) { | ||
if c.GlobalBool("disable-runc") { | ||
return nil, nil | ||
} | ||
opts, err := runc.NewMetaWorkerOpts(root) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var mws []*metaworker.MetaWorker | ||
for _, opt := range opts { | ||
mw, err := metaworker.NewMetaWorker(opt) | ||
if err != nil { | ||
return mws, err | ||
} | ||
mws = append(mws, mw) | ||
} | ||
return mws, nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.