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 host instructions to gateway exec for debugging into container #266

Merged
merged 1 commit into from
Aug 3, 2021
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
2 changes: 1 addition & 1 deletion codegen/builtin_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ func (s Host) Call(ctx context.Context, cln *client.Client, ret Register, opts O
return err
}

return ret.Set(append(retOpts, llb.AddExtraHost(host, address)))
return ret.Set(append(retOpts, llbutil.WithExtraHost(host, address)))
}

type SSH struct{}
Expand Down
10 changes: 9 additions & 1 deletion codegen/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ func ExecWithFS(ctx context.Context, cln *client.Client, fs Filesystem, r io.Rea
var (
securityMode pb.SecurityMode
netMode pb.NetMode
extraHosts []*pb.HostIP
secrets []llbutil.SecretOption
ssh []llbutil.SSHOption
)
Expand Down Expand Up @@ -598,6 +599,11 @@ func ExecWithFS(ctx context.Context, cln *client.Client, fs Filesystem, r io.Rea
securityMode = o.SecurityMode
case llbutil.NetworkOption:
netMode = o.NetMode
case llbutil.HostOption:
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's also add the equivalent to ExecWithSolveErr. It looks like ExtraHosts is exposed under Meta in ExecOp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch, forgot about that one. Fixed.

extraHosts = append(extraHosts, &pb.HostIP{
Host: o.Host,
IP: o.IP.String(),
})
case llbutil.SecretOption:
secrets = append(secrets, o)
case llbutil.SSHOption:
Expand Down Expand Up @@ -636,7 +642,8 @@ func ExecWithFS(ctx context.Context, cln *client.Client, fs Filesystem, r io.Rea

return solver.Build(ctx, cln, s, pw, func(ctx context.Context, c gateway.Client) (res *gateway.Result, err error) {
ctrReq := gateway.NewContainerRequest{
NetMode: netMode,
NetMode: netMode,
ExtraHosts: extraHosts,
}
for _, mount := range mounts {
gatewayMount := gateway.Mount{
Expand Down Expand Up @@ -811,6 +818,7 @@ func ExecWithSolveErr(ctx context.Context, c gateway.Client, se *solvererrdefs.S
ctr, err := c.NewContainer(ctx, gateway.NewContainerRequest{
Mounts: mounts,
NetMode: exec.Network,
ExtraHosts: exec.Meta.ExtraHosts,
Platform: op.Platform,
Constraints: op.Constraints,
})
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ go 1.16
require (
github.com/alecthomas/participle v1.0.0-alpha2
github.com/containerd/console v1.0.2
github.com/containerd/containerd v1.5.2
github.com/containerd/containerd v1.5.5
github.com/creachadair/jrpc2 v0.19.0
github.com/docker/buildx v0.5.1
github.com/docker/cli v20.10.7+incompatible
github.com/docker/distribution v2.7.1+incompatible
github.com/docker/libnetwork v0.8.0-dev.2.0.20210525090646-64b7a4574d14 // indirect
github.com/fvbommel/sortorder v1.0.2 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/lithammer/dedent v1.1.0
github.com/logrusorgru/aurora v0.0.0-20191116043053-66b7ad493a23
github.com/mattn/go-isatty v0.0.12
github.com/mitchellh/go-homedir v1.1.0
github.com/moby/buildkit v0.8.2-0.20210629085500-bb6f11c28d55
github.com/moby/buildkit v0.9.0
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.1
github.com/openllb/doxygen-parser v0.0.0-20201031162929-e0b5cceb2d0c
Expand All @@ -29,16 +30,15 @@ require (
github.com/xlab/treeprint v1.0.0
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57
golang.org/x/sys v0.0.0-20210426230700-d19ff857e887
google.golang.org/grpc v1.38.0
)

// includes the changes in github.com/slushie/fsutil v0.0.0-20200508061958-7d16a3dcbd1d
replace github.com/tonistiigi/fsutil => github.com/aaronlehmann/fsutil v0.0.0-20210601195957-d9292d6d3583

replace github.com/hashicorp/go-immutable-radix => github.com/tonistiigi/go-immutable-radix v0.0.0-20170803185627-826af9ccf0fe

replace github.com/docker/docker => github.com/docker/docker v20.10.7+incompatible

// necessary for langserver with vscode
replace github.com/sourcegraph/go-lsp => github.com/radeksimko/go-lsp v0.0.0-20200223162147-9f2c54f29c9f

// remove after https://github.com/moby/buildkit/pull/2294 is merged
replace github.com/moby/buildkit => github.com/coryb/buildkit v0.6.2-0.20210803153907-396b36f0bbbb
Loading