Bug 1330622

Summary: enhance condition judgement in /usr/bin/docker script
Product: Red Hat Enterprise Linux 7 Reporter: Alex Jia <ajia>
Component: dockerAssignee: Lokesh Mandvekar <lsm5>
Status: CLOSED ERRATA QA Contact: atomic-bugs <atomic-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 7.2CC: lsm5, lsu
Target Milestone: rcKeywords: Extras, ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: docker-1.9.1-37.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-05-12 15:18:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Alex Jia 2016-04-26 15:14:46 UTC
Description of problem:
The valid value only is /usr/bin/docker-current or /usr/bin/docker-latest for the argument DOCKERBINARY in /etc/sysconfig/docker, but we haven't any limitation for value of argument in /usr/bin/docker, a kind of bad case is user set DOCKERBINARY=/usr/bin/docker in /etc/sysconfig/docker then restart docker service, and restart command will hang forever. 

Version-Release number of selected component (if applicable):
# rpm -q docker docker-common
docker-1.9.1-33.el7.x86_64
docker-common-1.9.1-33.el7.x86_64


How reproducible:
always

Steps to Reproduce:
1. echo DOCKERBINARY=/usr/bin/docker >> /etc/sysconfig/docker
2. systemctl restart docker

Actual results:
# systemctl is-active docker
inactive

# systemctl is-active docker-latest
inactive

# systemctl restart docker

NOTE: hang forever.


Expected results:


Additional info:

Comment 1 Daniel Walsh 2016-04-26 16:03:35 UTC
We should catch this situation, but I would not say this is a blocker bug.

Comment 2 Lokesh Mandvekar 2016-04-26 16:34:52 UTC
While I'm still pushing fixes in, I could put something like: 

if [ ! -f ${DOCKERBINARY} ]; then
echo "Please set $DOCKERBINARY to /usr/bin/docker-current or /usr/bin/docker-latest"
else
exec ${DOCKERBINARY} $@
fi


wdyt?

Comment 3 Lokesh Mandvekar 2016-04-26 16:35:48 UTC
ugh ... that doesn't catch /usr/bin/docker

Comment 4 Lokesh Mandvekar 2016-04-26 16:37:23 UTC
if [ ${DOCKERBINARY} == "/usr/bin/docker ]; then
echo "Please set $DOCKERBINARY to /usr/bin/docker-current or /usr/bin/docker-latest"
else
exec ${DOCKERBINARY} $@
fi

Comment 5 Daniel Walsh 2016-04-26 17:10:32 UTC
Lokesh, where can I see the script?  Without having a RHEL system to install?

Comment 7 Daniel Walsh 2016-04-26 17:59:03 UTC
After looking at the script and at the packaging, only problem I have is we should not rename any of the plugins, they should work (eventually) with docker-latest or regular docker, (Once plugins are supported).

Comment 8 Lokesh Mandvekar 2016-04-27 02:26:50 UTC
Plugins are now docker-novolume-plugin, docker-rhel-push-plugin, docker-lvm-plugin. Those are docker-latest.

/usr/bin/docker now looks like this:

#!/bin/sh
. /etc/sysconfig/docker
[ -e "${DOCKERBINARY}" ] || DOCKERBINARY=/usr/bin/docker-current
if [ ! -f /usr/bin/docker-current ]; then
    DOCKERBINARY=/usr/bin/docker-latest
fi
if [[ ${DOCKERBINARY} != "/usr/bin/docker-current" && ${DOCKERBINARY} != /usr/bin/docker-latest ]]; then
    echo "DOCKERBINARY has been set to an invalid value:" $DOCKERBINARY
    echo ""
    echo "Please set DOCKERBINARY to /usr/bin/docker-current or /usr/bin/docker-latest
by editing /etc/sysconfig/docker"
else
    exec ${DOCKERBINARY} "$@"
fi


1. If _only_ docker-latest is installed, /usr/bin/docker calls /usr/bin/docker-latest
2. If docker is installed, /usr/bin/docker calls /usr/bin/docker-current unless set otherwise in /etc/sysconfig/docker
3. If DOCKERBINARY is set to anything other than /usr/bin/docker-current or /usr/bin/docker-latest, it'll prompt the user about invalid values and ask to set them to -current or -latest.

Fixed in upcoming build

Comment 10 Luwen Su 2016-05-01 03:40:47 UTC
In docker-1.9.1-38.el7.x86_64, works fine.

# echo DOCKERBINARY=/usr/bin/docker >> /etc/sysconfig/docker
# systemctl restart docker
# systemctl is-active docker
active

Comment 12 errata-xmlrpc 2016-05-12 15:18:28 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2016-1034.html