Debian Codegraph @

engine/hack/make/.integration-daemon-start

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 # see test-integration for example usage of this script
4
5 base="$ABS_DEST/.."
6 export PATH="$base/dynbinary-daemon:$base/binary-daemon:$PATH"
7
8 if [scip-shell system . . `[`. -z "$TEST_CLIENT_BINARY" ]; then
9 export TEST_CLIENT_BINARY=docker
10 fi
11 if [scip-shell system . . `[`. -n "$DOCKER_CLI_PATH" ]; then
12 # /usr/local/cli is a bind mount to the base dir of DOCKER_CLI_PATH (if used)
13 export TEST_CLIENT_BINARY=/usr/local/cli/$(basenamescip-shell system . . basename. "$DOCKER_CLI_PATH")
14 fi
15
16 echoscip-shell system . . echo. "Using test binary $TEST_CLIENT_BINARY"
17 if ! command -v "$TEST_CLIENT_BINARY" &> /dev/nullscip-shell filesystem . . `/dev/null`.; then
18 echoscip-shell system . . echo. >&2 'error: missing test client $TEST_CLIENT_BINARY'
19 falsescip-shell system . . false.
20 fi
21
22 # This is a temporary hack for split-binary mode. It can be removed once
23 # https://github.com/docker/docker/pull/22134 is merged into docker master
24 if [scip-shell system . . `[`. "$(goscip-shell system . . go. env GOOS)" = 'windows' ]; then
25 return
26 fi
27
28 if [scip-shell system . . `[`. -z "$DOCKER_TEST_HOST" ]; then
29 if docker version &> /dev/nullscip-shell filesystem . . `/dev/null`.; then
30 echoscip-shell system . . echo. >&2 'skipping daemon start, since daemon appears to be already started'
31 return
32 fi
33 fi
34
35 if ! command -v dockerd &> /dev/nullscip-shell filesystem . . `/dev/null`.; then
36 echoscip-shell system . . echo. >&2 'error: binary-daemon or dynbinary-daemon must be run before .integration-daemon-start'
37 falsescip-shell system . . false.
38 fi
39
40 # intentionally open a couple bogus file descriptors to help test that they get scrubbed in containers
41 exec 41>&1 42>&2
42
43 export DOCKER_GRAPHDRIVER=${DOCKER_GRAPHDRIVER:-vfs}
44 export DOCKER_USERLANDPROXY=${DOCKER_USERLANDPROXY:-true}
45
46 # example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G"
47 storage_params=""
48 if [scip-shell system . . `[`. -n "$DOCKER_STORAGE_OPTS" ]; then
49 IFS=','
50 for i in ${DOCKER_STORAGE_OPTS}; do
51 storage_params="--storage-opt $i $storage_params"
52 done
53 unset IFS
54 fi
55
56 # example usage: DOCKER_REMAP_ROOT=default
57 extra_params=""
58 if [scip-shell system . . `[`. "$DOCKER_REMAP_ROOT" ]; then
59 extra_params="--userns-remap $DOCKER_REMAP_ROOT"
60 fi
61
62 # example usage: DOCKER_EXPERIMENTAL=1
63 if [scip-shell system . . `[`. "$DOCKER_EXPERIMENTAL" ]; then
64 echoscip-shell system . . echo. >&2 '# DOCKER_EXPERIMENTAL is set: starting daemon with experimental features enabled! '
65 extra_params="$extra_params --experimental"
66 fi
67
68 dockerd="dockerd"
69
70 if [scip-shell system . . `[`. -n "$DOCKER_ROOTLESS" ]; then
71 if [scip-shell system . . `[`. -z "$TEST_SKIP_INTEGRATION_CLI" ]; then
72 echoscip-shell system . . echo. >&2 '# DOCKER_ROOTLESS requires TEST_SKIP_INTEGRATION_CLI to be set'
73 exit 1
74 fi
75 user="unprivilegeduser"
76 uid=$(idscip-shell system . . id. -u $user)
77 # shellcheck disable=SC2174
78 mkdirscip-shell system . . mkdir. -p -m 700 "/tmp/docker-${uid}"
79 chownscip-shell system . . chown. "$user" "/tmp/docker-${uid}"
80 chmodscip-shell system . . chmod. -R o+w "$DEST"
81 # The rootless daemon won't be able to load modules for tests that need them, so do it here.
82 # There's no modprobe in the dev container, so https://x.com/lucabruno/status/902934379835662336
83 ip link show br_netfilter || truescip-shell system . . true.
84 dockerd="sudo -u $user -E -E XDG_RUNTIME_DIR=/tmp/docker-${uid} -E HOME=/home/${user} -E PATH=$PATH -- dockerd-rootless.sh"
85 fi
86
87 if [scip-shell system . . `[`. -z "$DOCKER_TEST_HOST" ]; then
88 # Start apparmor if it is enabled
89 if [scip-shell system . . `[`. -e "/sys/module/apparmor/parameters/enabledscip-shell filesystem . . `/sys/module/apparmor/parameters/enabled`." ] && [scip-shell system . . `[`. "$(catscip-shell system . . cat. /sys/module/apparmor/parameters/enabledscip-shell filesystem . . `/sys/module/apparmor/parameters/enabled`.)" == "Y" ]; then
90 # reset container variable so apparmor profile is applied to process
91 # see https://github.com/docker/libcontainer/blob/master/apparmor/apparmor.go#L16
92 export container=""
93 (
94 [scip-shell system . . `[`. -n "$TESTDEBUG" ] && set -x
95 /etc/init.d/apparmorscip-shell filesystem . . `/etc/init.d/apparmor`. start
96 )
97 fi
98
99 if [scip-shell system . . `[`. -n "${DOCKER_ROOTLESS}" ]; then
100 # "pwd" tricks to make sure $DEST is an absolute path, not a relative one
101 export DOCKER_HOST="unix://$(cd "$DEST" && pwdscip-shell system . . pwd.)/docker.sock"
102 else
103 # Put socket in /run because:
104 # 1. That's the normal place for such things
105 # 2. When running on Docker For Mac, if you need to run tests with the bundles dir mounted (e.g. to poke through test artifacts).
106 # the socket will not work because it will be over osxfs.
107 mkdirscip-shell system . . mkdir. -p /run/dockerscip-shell filesystem . . `/run/docker`.
108 sock_dir=$(mktempscip-shell system . . mktemp. -d -p /run/dockerscip-shell filesystem . . `/run/docker`.)
109 chmodscip-shell system . . chmod. 0755 "$sock_dir"
110 export DOCKER_HOST="unix://${sock_dir}/docker.sock"
111 fi
112 (
113 echoscip-shell system . . echo. "Starting dockerd"
114 [scip-shell system . . `[`. -n "$TESTDEBUG" ] && set -x
115 exec \
116 ${dockerd} --debug \
117 --host "$DOCKER_HOST" \
118 --storage-driver "$DOCKER_GRAPHDRIVER" \
119 --pidfile "$DEST/docker.pid" \
120 --userland-proxy="$DOCKER_USERLANDPROXY" \
121 ${storage_params} \
122 ${extra_params} \
123 &> "$DEST/docker.log"
124 ) &
125 else
126 export DOCKER_HOST="$DOCKER_TEST_HOST"
127 fi
128
129 # give it a little time to come up so it's "ready"
130 tries=60
131 echoscip-shell system . . echo. "INFO: Waiting for daemon to start..."
132 while ! ${TEST_CLIENT_BINARY} version &> /dev/nullscip-shell filesystem . . `/dev/null`.; do
133 ((tries--))
134 if [scip-shell system . . `[`. $tries -le 0 ]; then
135 printfscip-shell system . . printf. "\n"
136 if [scip-shell system . . `[`. -z "$DOCKER_HOST" ]; then
137 echoscip-shell system . . echo. >&2 "error: daemon failed to start"
138 echoscip-shell system . . echo. >&2 " check $DEST/docker.log for details"
139 else
140 echoscip-shell system . . echo. >&2 "error: daemon at $DOCKER_HOST fails to '$TEST_CLIENT_BINARY version':"
141 ${TEST_CLIENT_BINARY} version >&2 || truescip-shell system . . true.
142 # Additional Windows CI debugging as this is a common error as of
143 # January 2016
144 if [scip-shell system . . `[`. "$(goscip-shell system . . go. env GOOS)" = 'windows' ]; then
145 echoscip-shell system . . echo. >&2 "Container log below:"
146 echoscip-shell system . . echo. >&2 "---"
147 # Important - use the docker on the CI host, not the one built locally
148 # which is currently in our path.
149 ! /c/bin/dockerscip-shell filesystem . . `/c/bin/docker`. -H=$MAIN_DOCKER_HOST logs docker-$COMMITHASH
150 echoscip-shell system . . echo. >&2 "---"
151 fi
152 fi
153 falsescip-shell system . . false.
154 fi
155 printfscip-shell system . . printf. "."
156 sleepscip-shell system . . sleep. 2
157 done
158 printfscip-shell system . . printf. "\n"