File 0027-Midumu-docker-fix-to-deal-with-the-image-name-correc.patch of Package resource-agents.8843
From 770109a3f17cc32efc57c069aced5344c27fcc39 Mon Sep 17 00:00:00 2001
From: ytakeshita <y.takeshita0311@gmail.com>
Date: Thu, 16 Mar 2017 16:19:11 +0900
Subject: [PATCH 27/27] Midumu: docker: fix to deal with the image name
correctly. (bsc#1058318)
Fix the following issue.
Now image_exists() can not parse the image names which has port number.
For exsample "xxx.xxx.xxx.xxx:YYYY/IMAGE:latest".
---
heartbeat/docker | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/heartbeat/docker b/heartbeat/docker
index 876d616d..6c6e3b3c 100755
--- a/heartbeat/docker
+++ b/heartbeat/docker
@@ -360,24 +360,31 @@ docker_stop()
image_exists()
{
- # assume that OCF_RESKEY_name have been validated
- local IMAGE_NAME="$(echo ${OCF_RESKEY_image} | awk -F':' '{print $1}')"
-
# if no tag was specified, use default "latest"
local COLON_FOUND=0
+ local SLASH_FOUND=0
+ local SERVER_NAME=""
+ local IMAGE_NAME="${OCF_RESKEY_image}"
local IMAGE_TAG="latest"
- COLON_FOUND="$(echo "${OCF_RESKEY_image}" | grep -o ':' | grep -c .)"
+ SLASH_FOUND="$(echo "${OCF_RESKEY_image}" | grep -o '/' | grep -c .)"
- if [ ${COLON_FOUND} -ne 0 ]; then
- IMAGE_TAG="$(echo ${OCF_RESKEY_image} | awk -F':' '{print $NF}')"
+ if [ ${SLASH_FOUND} -ge 1 ]; then
+ SERVER_NAME="$(echo ${IMAGE_NAME} | cut -d / -f 1-${SLASH_FOUND})"
+ IMAGE_NAME="$(echo ${IMAGE_NAME} | awk -F'/' '{print $NF}')"
+ fi
+
+ COLON_FOUND="$(echo "${IMAGE_NAME}" | grep -o ':' | grep -c .)"
+ if [ ${COLON_FOUND} -ge 1 ]; then
+ IMAGE_TAG="$(echo ${IMAGE_NAME} | awk -F':' '{print $NF}')"
+ IMAGE_NAME="$(echo ${IMAGE_NAME} | cut -d : -f 1-${COLON_FOUND})"
fi
# IMAGE_NAME might be following formats:
# - image
- # - repository/image
+ # - repository:port/image
# - docker.io/image (some distro will display "docker.io/" as prefix)
- docker images | awk '{print $1 ":" $2}' | egrep -q -s "^(docker.io\/)?${IMAGE_NAME}:${IMAGE_TAG}\$"
+ docker images | awk '{print $1 ":" $2}' | egrep -q -s "^(docker.io\/|${SERVER_NAME}\/)?${IMAGE_NAME}:${IMAGE_TAG}\$"
if [ $? -eq 0 ]; then
# image found
return 0
--
2.15.1