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

Low-hanging Windows fruit #1314

Merged
merged 6 commits into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cmd/buildkitd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ func main() {
app.Flags = append(app.Flags, appFlags...)

app.Action = func(c *cli.Context) error {
if os.Geteuid() != 0 {
// TODO: On Windows this always returns -1. The actual "are you admin" check is very Windows-specific.
// See https://github.com/golang/go/issues/28804#issuecomment-505326268 for the "short" version.
if os.Geteuid() > 0 {
return errors.New("rootless mode requires to be executed as the mapped root in a user namespace; you may use RootlessKit for setting up the namespace")
}
ctx, cancel := context.WithCancel(appcontext.Context())
Expand Down Expand Up @@ -495,7 +497,7 @@ func getListener(addr string, uid, gid int, tlsConfig *tls.Config) (net.Listener
proto := addrSlice[0]
listenAddr := addrSlice[1]
switch proto {
case "unix":
case "unix", "npipe":
TBBle marked this conversation as resolved.
Show resolved Hide resolved
if tlsConfig != nil {
logrus.Warnf("TLS is disabled for %s", addr)
}
Expand All @@ -506,7 +508,6 @@ func getListener(addr string, uid, gid int, tlsConfig *tls.Config) (net.Listener
}
return sockets.NewTCPSocket(listenAddr, tlsConfig)
default:
// TODO: support npipe (with TLS?)
return nil, errors.Errorf("addr %s not supported", addr)
}
}
Expand Down
7 changes: 6 additions & 1 deletion executor/containerdexecutor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,12 @@ func (w containerdExecutor) Exec(ctx context.Context, meta executor.Meta, root c
cancel()
}
if status.ExitCode() != 0 {
err := errors.Errorf("process returned non-zero exit code: %d", status.ExitCode())
var err error
if status.ExitCode() == containerd.UnknownExitStatus && status.Error() != nil {
err = errors.Wrap(status.Error(), "failure waiting for process")
} else {
err = errors.Errorf("process returned non-zero exit code: %d", status.ExitCode())
}
select {
case <-ctx.Done():
err = errors.Wrap(ctx.Err(), err.Error())
Expand Down
14 changes: 11 additions & 3 deletions util/appdefaults/appdefaults_windows.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package appdefaults

import (
"os"
"path/filepath"
)

const (
Address = "npipe:////./pipe/buildkitd"
Root = ".buildstate"
ConfigDir = ""
Address = "npipe:////./pipe/buildkitd"
)

var (
Root = filepath.Join(os.Getenv("ProgramData"), "buildkitd", ".buildstate")
ConfigDir = filepath.Join(os.Getenv("ProgramData"), "buildkitd")
)

func UserAddress() string {
Expand Down
4 changes: 2 additions & 2 deletions worker/containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ func newContainerd(root string, client *containerd.Client, snapshotterName, ns s

cs := containerdsnapshot.NewContentStore(client.ContentStore(), ns)

resp, err := client.IntrospectionService().Plugins(context.TODO(), &introspection.PluginsRequest{Filters: []string{"type==io.containerd.runtime.v1"}})
resp, err := client.IntrospectionService().Plugins(context.TODO(), &introspection.PluginsRequest{Filters: []string{"type==io.containerd.runtime.v1", "type==io.containerd.runtime.v2"}})
if err != nil {
return base.WorkerOpt{}, errors.Wrap(err, "failed to list runtime plugin")
}
if len(resp.Plugins) == 0 {
return base.WorkerOpt{}, errors.Wrap(err, "failed to get runtime plugin")
return base.WorkerOpt{}, errors.New("failed to find any runtime plugins")
}

var platforms []specs.Platform
Expand Down