mirror of
https://github.com/moby/buildkit.git
synced 2026-08-07 08:10:44 +00:00
executor: make sure hostname is resolvable
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
@@ -80,6 +80,7 @@ func TestClientIntegration(t *testing.T) {
|
||||
testFrontendMetadataReturn,
|
||||
testSSHMount,
|
||||
testStdinClosed,
|
||||
testHostnameLookup,
|
||||
},
|
||||
integration.WithMirroredImages(integration.OfficialImages("busybox:latest", "alpine:latest")),
|
||||
)
|
||||
@@ -89,6 +90,25 @@ func newContainerd(cdAddress string) (*containerd.Client, error) {
|
||||
return containerd.New(cdAddress, containerd.WithTimeout(60*time.Second))
|
||||
}
|
||||
|
||||
func testHostnameLookup(t *testing.T, sb integration.Sandbox) {
|
||||
if sb.Rootless() {
|
||||
t.SkipNow()
|
||||
}
|
||||
t.Parallel()
|
||||
|
||||
c, err := New(context.TODO(), sb.Address())
|
||||
require.NoError(t, err)
|
||||
defer c.Close()
|
||||
|
||||
st := llb.Image("busybox:latest").Run(llb.Shlex(`sh -c "ping -c 1 $(hostname)"`))
|
||||
|
||||
def, err := st.Marshal()
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = c.Solve(context.TODO(), def, SolveOpt{}, nil)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
// moby/buildkit#614
|
||||
func testStdinClosed(t *testing.T, sb integration.Sandbox) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
const hostsContent = `
|
||||
127.0.0.1 localhost
|
||||
127.0.0.1 localhost buildkitsandbox
|
||||
::1 localhost ip6-localhost ip6-loopback
|
||||
`
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ func GenerateSpec(ctx context.Context, meta executor.Meta, mounts []executor.Mou
|
||||
s.Process.Args = meta.Args
|
||||
s.Process.Env = meta.Env
|
||||
s.Process.Cwd = meta.Cwd
|
||||
s.Hostname = "buildkitsandbox"
|
||||
|
||||
s.Mounts = GetMounts(ctx,
|
||||
withROBind(resolvConf, "/etc/resolv.conf"),
|
||||
|
||||
Reference in New Issue
Block a user