@@ -19,6 +19,16 @@ set -o nounset
19
19
set -o pipefail
20
20
set -x
21
21
22
+ configure_proxy () {
23
+ # ensure all processes receive the proxy settings by default
24
+ # https://www.freedesktop.org/software/systemd/man/systemd-system.conf.html
25
+ mkdir -p /etc/systemd/system.conf.d/
26
+ cat << EOF >/etc/systemd/system.conf.d/proxy-default-environment.conf
27
+ [Manager]
28
+ DefaultEnvironment="HTTP_PROXY=${HTTP_PROXY:- } " "HTTPS_PROXY=${HTTPS_PROXY:- } " "NO_PROXY=${NO_PROXY:- } "
29
+ EOF
30
+ }
31
+
22
32
update-alternatives () {
23
33
echo " retryable update-alternatives: $* "
24
34
local args=$*
@@ -48,7 +58,7 @@ fix_mount() {
48
58
# This is a workaround to an AUFS bug that might cause `Text file
49
59
# busy` on `mount` command below. See more details in
50
60
# https://github.com/moby/moby/issues/9547
51
- if [[ " $( stat -f -c %T /bin/ mount) " == ' aufs' ]]; then
61
+ if [[ " $( stat -f -c %T " $( which mount) " ) " == ' aufs' ]]; then
52
62
echo ' INFO: detected aufs, calling sync' >&2
53
63
sync
54
64
fi
@@ -174,16 +184,6 @@ fix_kmsg() {
174
184
fi
175
185
}
176
186
177
- configure_proxy () {
178
- # ensure all processes receive the proxy settings by default
179
- # https://www.freedesktop.org/software/systemd/man/systemd-system.conf.html
180
- mkdir -p /etc/systemd/system.conf.d/
181
- cat << EOF >/etc/systemd/system.conf.d/proxy-default-environment.conf
182
- [Manager]
183
- DefaultEnvironment="HTTP_PROXY=${HTTP_PROXY:- } " "HTTPS_PROXY=${HTTPS_PROXY:- } " "NO_PROXY=${NO_PROXY:- } "
184
- EOF
185
- }
186
-
187
187
select_iptables () {
188
188
# based on: https://github.com/kubernetes/kubernetes/blob/ffe93b3979486feb41a0f85191bdd189cbd56ccc/build/debian-iptables/iptables-wrapper
189
189
local mode=nft
@@ -229,7 +229,7 @@ enable_network_magic(){
229
229
sed -e " s/${docker_embedded_dns_ip} /${docker_host_ip} /g" /etc/resolv.conf.original > /etc/resolv.conf
230
230
231
231
# fixup IPs in manifests ...
232
- curr_ipv4=" $( (getent ahostsv4 $( hostname) | head -n1 | cut -d' ' -f1) || true) "
232
+ curr_ipv4=" $( (getent ahostsv4 " $( hostname) " | head -n1 | cut -d' ' -f1) || true) "
233
233
echo " INFO: Detected IPv4 address: ${curr_ipv4} " >&2
234
234
if [ -f /kind/old-ipv4 ]; then
235
235
old_ipv4=$( cat /kind/old-ipv4)
@@ -249,7 +249,7 @@ enable_network_magic(){
249
249
fi
250
250
251
251
# do IPv6
252
- curr_ipv6=" $( (getent ahostsv6 $( hostname) | head -n1 | cut -d' ' -f1) || true) "
252
+ curr_ipv6=" $( (getent ahostsv6 " $( hostname) " | head -n1 | cut -d' ' -f1) || true) "
253
253
echo " INFO: Detected IPv6 address: ${curr_ipv6} " >&2
254
254
if [ -f /kind/old-ipv6 ]; then
255
255
old_ipv6=$( cat /kind/old-ipv6)
@@ -269,15 +269,16 @@ enable_network_magic(){
269
269
}
270
270
271
271
# run pre-init fixups
272
- select_iptables
272
+ # NOTE: it's important that we do configure* first in this order to avoid races
273
+ configure_proxy
273
274
fix_kmsg
274
275
fix_mount
275
276
retryable_fix_cgroup_mounts
276
277
fix_machine_id
277
278
fix_product_name
278
279
fix_product_uuid
279
- configure_proxy
280
+ select_iptables
280
281
enable_network_magic
281
282
282
283
# we want the command (expected to be systemd) to be PID1, so exec to it
283
- exec " $@ "
284
+ exec " $@ "
0 commit comments