Skip to content

Commit 2142bdb

Browse files
author
OpenShift Bot
authored
Merge pull request #11326 from marun/dind-fix-config-perms
Merged by openshift-bot
2 parents 0a022ab + c9fb01c commit 2142bdb

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

images/dind/master/openshift-generate-master-config.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ function ensure-master-config() {
3232
--master="https://${ip_addr}:8443" \
3333
--network-plugin="${OPENSHIFT_NETWORK_PLUGIN}"
3434

35-
# ensure the configuration is readable outside of the container
36-
find "${config_path}" -exec chmod ga+rw {} \;
37-
find "${config_path}" -type d -exec chmod ga+x {} \;
35+
# ensure the configuration can be used outside of the container
36+
chmod -R ga+rX "${master_path}"
37+
chmod ga+w "${master_path}/admin.kubeconfig"
3838
}
3939

4040
ensure-master-config

images/dind/node/openshift-generate-node-config.sh

+26-16
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,48 @@ function ensure-node-config() {
2424
host="${host}-node"
2525
fi
2626
local node_config_path="${config_path}/node-${host}"
27-
local config_file="${node_config_path}/node-config.yaml"
27+
local node_config_file="${node_config_path}/node-config.yaml"
2828

2929
# If the node config has not been generated
30-
if [[ ! -f "${config_file}" ]]; then
30+
if [[ ! -f "${node_config_file}" ]]; then
3131
local master_config_path="${config_path}/master"
32+
local master_config_file="${master_config_path}/admin.kubeconfig"
3233

3334
# Wait for the master to generate its config
34-
local condition="test -f ${master_config_path}/admin.kubeconfig"
35+
local condition="test -f ${master_config_file}"
3536
os::util::wait-for-condition "admin config" "${condition}" "${OS_WAIT_FOREVER}"
3637

3738
local master_host
38-
master_host="$(grep server "${master_config_path}/admin.kubeconfig" | grep -v localhost | awk '{print $2}')"
39+
master_host="$(grep server "${master_config_file}" | grep -v localhost | awk '{print $2}')"
3940

4041
local ip_addr
4142
ip_addr="$(ip addr | grep inet | grep eth0 | awk '{print $2}' | sed -e 's+/.*++')"
4243

43-
/usr/local/bin/openshift admin create-node-config \
44-
--node-dir="${config_path}" \
45-
--node="${host}" \
46-
--master="${master_host}" \
47-
--hostnames="${host},${ip_addr}" \
48-
--network-plugin="${OPENSHIFT_NETWORK_PLUGIN}" \
49-
--node-client-certificate-authority="${master_config_path}/ca.crt" \
50-
--certificate-authority="${master_config_path}/ca.crt" \
51-
--signer-cert="${master_config_path}/ca.crt" \
52-
--signer-key="${master_config_path}/ca.key" \
53-
--signer-serial="${master_config_path}/ca.serial.txt"
44+
# Hold a lock on the shared volume to ensure cert generation is
45+
# performed serially. Cert generation is not compatible with
46+
# concurrent execution since the file passed to --signer-serial
47+
# needs to be incremented by each invocation.
48+
(flock 200;
49+
/usr/local/bin/openshift admin create-node-config \
50+
--node-dir="${node_config_path}" \
51+
--node="${host}" \
52+
--master="${master_host}" \
53+
--hostnames="${host},${ip_addr}" \
54+
--network-plugin="${OPENSHIFT_NETWORK_PLUGIN}" \
55+
--node-client-certificate-authority="${master_config_path}/ca.crt" \
56+
--certificate-authority="${master_config_path}/ca.crt" \
57+
--signer-cert="${master_config_path}/ca.crt" \
58+
--signer-key="${master_config_path}/ca.key" \
59+
--signer-serial="${master_config_path}/ca.serial.txt"
60+
) 200>"${config_path}"/.openshift-generate-node-config.lock
5461
fi
5562

63+
# ensure the configuration is readable outside of the container
64+
chmod -R ga+rX "${node_config_path}"
65+
5666
# Deploy the node config
5767
mkdir -p "${deployed_config_path}"
58-
cp -r "${config_path}"/* "${deployed_config_path}"
68+
cp -r "${node_config_path}"/* "${deployed_config_path}/"
5969
}
6070

6171
ensure-node-config

0 commit comments

Comments
 (0)