Skip to content

Commit 2d4222b

Browse files
authored
Merge pull request moby#3612 from crazy-max/itg-dockerd-flags
integration: set custom flags for dockerd worker
2 parents 0de1541 + 34880cc commit 2d4222b

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

.github/workflows/dockerd.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,6 @@ jobs:
137137
TESTFLAGS: "${{ env.TESTFLAGS }} --run=//worker=${{ matrix.worker }}$"
138138
SKIP_INTEGRATION_TESTS: "${{ matrix.skip-integration-tests }}"
139139
CACHE_FROM: "type=gha,scope=${{ env.CACHE_GHA_SCOPE_IT }} type=gha,scope=${{ env.CACHE_GHA_SCOPE_BINARIES }}"
140+
BUILDKIT_INTEGRATION_DOCKERD_FLAGS: |
141+
--bip=10.66.66.1/24
142+
--default-address-pool=base=10.66.66.0/16,size=24

hack/test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ if ! docker container inspect "$cacheVolume" >/dev/null 2>/dev/null; then
7878
fi
7979

8080
if [ "$TEST_INTEGRATION" == 1 ]; then
81-
cid=$(docker create --rm -v /tmp $coverageVol --volumes-from=$cacheVolume -e GITHUB_REF -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e TEST_DOCKERD -e SKIP_INTEGRATION_TESTS ${BUILDKIT_INTEGRATION_SNAPSHOTTER:+"-eBUILDKIT_INTEGRATION_SNAPSHOTTER"} -e BUILDKIT_REGISTRY_MIRROR_DIR=/root/.cache/registry --privileged $iid go test $coverageFlags ${TESTFLAGS:--v} ${TESTPKGS:-./...})
81+
cid=$(docker create --rm -v /tmp $coverageVol --volumes-from=$cacheVolume -e GITHUB_REF -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e TEST_DOCKERD -e SKIP_INTEGRATION_TESTS ${BUILDKIT_INTEGRATION_SNAPSHOTTER:+"-eBUILDKIT_INTEGRATION_SNAPSHOTTER"} -e BUILDKIT_REGISTRY_MIRROR_DIR=/root/.cache/registry -e BUILDKIT_INTEGRATION_DOCKERD_FLAGS --privileged $iid go test $coverageFlags ${TESTFLAGS:--v} ${TESTPKGS:-./...})
8282
if [ "$TEST_DOCKERD" = "1" ]; then
8383
docker cp "$TEST_DOCKERD_BINARY" $cid:/usr/bin/dockerd
8484
fi
@@ -118,7 +118,7 @@ if [ "$TEST_DOCKERFILE" == 1 ]; then
118118

119119
if [ -s $tarout ]; then
120120
if [ "$release" = "mainline" ] || [ "$release" = "labs" ] || [ -n "$DOCKERFILE_RELEASES_CUSTOM" ] || [ "$GITHUB_ACTIONS" = "true" ]; then
121-
cid=$(docker create -v /tmp $coverageVol --rm --privileged --volumes-from=$cacheVolume -e GITHUB_REF -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e TEST_DOCKERD -e BUILDKIT_REGISTRY_MIRROR_DIR=/root/.cache/registry -e BUILDKIT_WORKER_RANDOM -e FRONTEND_GATEWAY_ONLY=local:/$release.tar -e EXTERNAL_DF_FRONTEND=/dockerfile-frontend $iid go test $coverageFlags --count=1 -tags "$buildtags" ${TESTFLAGS:--v} ./frontend/dockerfile)
121+
cid=$(docker create -v /tmp $coverageVol --rm --privileged --volumes-from=$cacheVolume -e GITHUB_REF -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e TEST_DOCKERD -e BUILDKIT_REGISTRY_MIRROR_DIR=/root/.cache/registry -e BUILDKIT_WORKER_RANDOM -e BUILDKIT_INTEGRATION_DOCKERD_FLAGS -e FRONTEND_GATEWAY_ONLY=local:/$release.tar -e EXTERNAL_DF_FRONTEND=/dockerfile-frontend $iid go test $coverageFlags --count=1 -tags "$buildtags" ${TESTFLAGS:--v} ./frontend/dockerfile)
122122
docker cp $tarout $cid:/$release.tar
123123
if [ "$TEST_DOCKERD" = "1" ]; then
124124
docker cp "$TEST_DOCKERD_BINARY" $cid:/usr/bin/dockerd

util/testutil/dockerd/daemon.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dockerd
22

33
import (
44
"bytes"
5+
"fmt"
56
"io"
67
"os"
78
"os/exec"
@@ -137,6 +138,7 @@ func (d *Daemon) StartWithError(daemonLogs map[string]*bytes.Buffer, providedArg
137138
d.cmd.Stderr = &lockingWriter{Writer: b}
138139
}
139140

141+
fmt.Fprintf(d.cmd.Stderr, "> startCmd %v %+v\n", time.Now(), d.cmd.String())
140142
if err := d.cmd.Start(); err != nil {
141143
return errors.Wrapf(err, "[%s] could not start daemon container", d.id)
142144
}

util/testutil/integration/dockerd.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package integration
22

33
import (
4-
"bytes"
54
"context"
65
"encoding/json"
76
"io"
87
"net"
98
"os"
109
"path/filepath"
10+
"strings"
1111
"time"
1212

1313
"github.com/docker/docker/client"
@@ -125,21 +125,23 @@ func (c moby) New(ctx context.Context, cfg *BackendConfig) (b Backend, cl func()
125125
return nil, nil, err
126126
}
127127

128-
err = d.StartWithError(cfg.Logs,
128+
dockerdFlags := []string{
129129
"--config-file", dockerdConfigFile,
130130
"--userland-proxy=false",
131-
"--bip", "10.66.66.1/24",
132-
"--default-address-pool", "base=10.66.66.0/16,size=24",
133131
"--debug",
134-
)
132+
}
133+
if s := os.Getenv("BUILDKIT_INTEGRATION_DOCKERD_FLAGS"); s != "" {
134+
dockerdFlags = append(dockerdFlags, strings.Split(strings.TrimSpace(s), "\n")...)
135+
}
136+
137+
err = d.StartWithError(cfg.Logs, dockerdFlags...)
135138
if err != nil {
136139
return nil, nil, err
137140
}
138141
deferF.append(d.StopWithError)
139142

140-
logs := map[string]*bytes.Buffer{}
141143
if err := waitUnix(d.Sock(), 5*time.Second); err != nil {
142-
return nil, nil, errors.Errorf("dockerd did not start up: %q, %s", err, formatLogs(logs))
144+
return nil, nil, errors.Errorf("dockerd did not start up: %q, %s", err, formatLogs(cfg.Logs))
143145
}
144146

145147
dockerAPI, err := client.NewClientWithOpts(client.WithHost(d.Sock()))

0 commit comments

Comments
 (0)