executor: make sure hostname is resolvable

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2018-10-02 17:25:33 -07:00
parent ec0e352aae
commit cd451ec063
3 changed files with 22 additions and 1 deletions

View File

@@ -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()

View File

@@ -13,7 +13,7 @@ import (
)
const hostsContent = `
127.0.0.1 localhost
127.0.0.1 localhost buildkitsandbox
::1 localhost ip6-localhost ip6-loopback
`

View File

@@ -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"),