@@ -19,6 +19,22 @@ set -o errexit
1919set -o nounset
2020set -o pipefail
2121
22+ if [[ " $( python -V 2>&1 ) " =~ " Python 2" ]]; then
23+ # found python2, just use that
24+ PYTHON=" python"
25+ elif [[ -f " /usr/bin/python2.7" ]]; then
26+ # System python not defaulted to python 2 but using 2.7 during migration
27+ PYTHON=" /usr/bin/python2.7"
28+ else
29+ # No python2 either by default, let's see if we can find python3
30+ PYTHON=" python3"
31+ if ! command -v ${PYTHON} > /dev/null 2>&1 ; then
32+ echo " ERROR Python not found. Aborting."
33+ exit 2
34+ fi
35+ fi
36+ echo " Version : " $( ${PYTHON} -V 2>&1 )
37+
2238# CONTAINERD_HOME is the directory for containerd.
2339CONTAINERD_HOME=" /home/containerd"
2440cd " ${CONTAINERD_HOME} "
@@ -53,9 +69,13 @@ fetch_env() {
5369 fi
5470 echo " ${tmp_env_content} " > " ${tmp_env_file} "
5571 # Convert the yaml format file into a shell-style file.
56- eval $( python -c ' ' '
72+ eval $( ${PYTHON} -c ' ' '
5773import pipes,sys,yaml
58- for k,v in yaml.load(sys.stdin).iteritems():
74+ if sys.version_info[0] < 3:
75+ items = yaml.load(sys.stdin).iteritems()
76+ else:
77+ items = yaml.load(sys.stdin, Loader=yaml.BaseLoader).items()
78+ for k,v in items:
5979 print("readonly {var}={value}".format(var = k, value = pipes.quote(str(v))))
6080' ' ' < " ${tmp_env_file} " > " ${CONTAINERD_HOME} /${env_file_name} " )
6181 rm -f " ${tmp_env_file} "
@@ -163,10 +183,8 @@ version = 2
163183required_plugins = ["io.containerd.grpc.v1.cri"]
164184# Kubernetes doesn't use containerd restart manager.
165185disabled_plugins = ["io.containerd.internal.v1.restart"]
166-
167186[debug]
168187 level = "${log_level} "
169-
170188[plugins."io.containerd.grpc.v1.cri"]
171189 stream_server_address = "127.0.0.1"
172190 stream_server_port = "0"
@@ -192,7 +210,6 @@ if [[ -n "${containerd_extra_runtime_handler}" ]]; then
192210 cat >> ${config_path} << EOF
193211[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.${containerd_extra_runtime_handler} ]
194212 runtime_type = "${CONTAINERD_EXTRA_RUNTIME_TYPE:- io.containerd.runc.v1} "
195-
196213[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.${containerd_extra_runtime_handler} .options]
197214${CONTAINERD_EXTRA_RUNTIME_OPTIONS:- }
198215EOF
0 commit comments