Browse Source

roles: openshift_control_plane: move docker scripts to crictl

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Antonio Murdaca 6 years ago
parent
commit
caaa8925b4

+ 4 - 5
roles/openshift_control_plane/files/scripts/docker/master-exec

@@ -14,13 +14,12 @@ if [[ ! -d /etc/origin/node/pods || -z "$( ls -A /etc/origin/node/pods )" ]]; th
   exec "${@:3}"
 fi
 
-# TODO: move to cri-ctl
-# TODO: short term hack for cri-o
+pod=$(crictl pods -l -q --label "openshift.io/component=${1}" --label "io.kubernetes.container.name=POD" 2>/dev/null)
+uid=$(crictl inspectp ${pod} 2>/dev/null | python -c 'import sys, json; print json.load(sys.stdin)["status"]["labels"]["io.kubernetes.pod.uid"]')
 
-uid=$(docker ps -l -a --filter "label=openshift.io/component=${1}" --filter "label=io.kubernetes.container.name=POD" --format '{{ .Label "io.kubernetes.pod.uid" }}')
 if [[ -z "${uid}" ]]; then
   echo "Component ${1} is stopped or not running" 1>&2
   exit 0
 fi
-container=$(docker ps -l -a -q --filter "label=io.kubernetes.pod.uid=${uid}" --filter "label=io.kubernetes.container.name=${2}")
-exec docker exec "${container}" "${@:3}"
+container=$(crictl ps -l -q --label "io.kubernetes.pod.uid=${uid}" --label "io.kubernetes.container.name=${2}" 2>/dev/null)
+exec crictl exec "${container}" "${@:3}"

+ 4 - 5
roles/openshift_control_plane/files/scripts/docker/master-logs

@@ -17,13 +17,12 @@ for type in "${types[@]}"; do
   fi
 done
 
-# TODO: move to cri-ctl
-# TODO: short term hack for cri-o
+pod=$(crictl pods -l -q --label "openshift.io/component=${1}" --label "io.kubernetes.container.name=POD" 2>/dev/null)
+uid=$(crictl inspectp ${pod} 2>/dev/null | python -c 'import sys, json; print json.load(sys.stdin)["status"]["labels"]["io.kubernetes.pod.uid"]')
 
-uid=$(docker ps -l -a --filter "label=openshift.io/component=${1}" --filter "label=io.kubernetes.container.name=POD" --format '{{ .Label "io.kubernetes.pod.uid" }}')
 if [[ -z "${uid}" ]]; then
   echo "Component ${1} is stopped or not running" 1>&2
   exit 0
 fi
-container=$(docker ps -l -a -q --filter "label=io.kubernetes.pod.uid=${uid}" --filter "label=io.kubernetes.container.name=${2}")
-exec docker logs "${@:3}" "${container}"
+container=$(crictl ps -l -q --label "io.kubernetes.pod.uid=${uid}" --label "io.kubernetes.container.name=${2}" 2>/dev/null)
+exec crictl logs "${@:3}" "${container}"

+ 4 - 16
roles/openshift_control_plane/files/scripts/docker/master-restart

@@ -15,23 +15,11 @@ for type in "${types[@]}"; do
   fi
 done
 
-# TODO: move to cri-ctl
-# TODO: short term hack for cri-o
-
-# Get a child container name to wait for it to stop
-child_container=$(docker ps -l -q --filter "label=io.kubernetes.container.name=${1}")
-
-container=$(docker ps -l -q --filter "label=openshift.io/component=${1}" --filter "label=io.kubernetes.container.name=POD")
-if [[ -z "${container}" ]]; then
+pod=$(crictl pods -l -q --label "openshift.io/component=${1}" --label "io.kubernetes.container.name=POD 2>/dev/null")
+if [[ -z "${pod}" ]]; then
   echo "Component ${1} is already stopped" 1>&2
   exit 0
 fi
 # Stop the pod
-docker stop "${container}" --time 30 >/dev/null
-
-# Wait for child container to change state
-if [[ -z "${child_container}" ]]; then
-  echo "Component ${1} is already stopped" 1>&2
-  exit 0
-fi
-exec timeout 60 docker wait $child_container
+# TODO(runcom): expose timeout in the CRI
+crictl stopp "${pod}" >/dev/null