@@ -24,38 +24,48 @@ function ensure-node-config() {
24
24
host=" ${host} -node"
25
25
fi
26
26
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"
28
28
29
29
# If the node config has not been generated
30
- if [[ ! -f " ${config_file } " ]]; then
30
+ if [[ ! -f " ${node_config_file } " ]]; then
31
31
local master_config_path=" ${config_path} /master"
32
+ local master_config_file=" ${master_config_path} /admin.kubeconfig"
32
33
33
34
# 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} "
35
36
os::util::wait-for-condition " admin config" " ${condition} " " ${OS_WAIT_FOREVER} "
36
37
37
38
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}' ) "
39
40
40
41
local ip_addr
41
42
ip_addr=" $( ip addr | grep inet | grep eth0 | awk ' {print $2}' | sed -e ' s+/.*++' ) "
42
43
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
54
61
fi
55
62
63
+ # ensure the configuration is readable outside of the container
64
+ chmod -R ga+rX " ${node_config_path} "
65
+
56
66
# Deploy the node config
57
67
mkdir -p " ${deployed_config_path} "
58
- cp -r " ${config_path } " /* " ${deployed_config_path} "
68
+ cp -r " ${node_config_path } " /* " ${deployed_config_path} / "
59
69
}
60
70
61
71
ensure-node-config
0 commit comments