Public bug reported:

The init script in the zookeeperd package is not able to stop the
service once started. This is because do_stop calls the is_running
function, which will return and the remainder of the do_stop function is
not executed (which does crucial start-stop-daemon invocation).

Steps to repro:
------------------------

# Start zookeeper , then query to see it is running
root@2d88cb921d2a:/# /etc/init.d/zookeeper status
 * zookeeper is running

# Ensure that it is running... (snipped for brevity
root@2d88cb921d2a:/# ps aux | grep zookeeper
root       336  0.0  0.0  34048  8524 ?        T    07:43   0:00 zile 
/etc/init.d/zookeeper
zookeep+   357  0.1  0.8 4682800 106684 ?      Sl   07:51   0:01 /usr/bin/java 
-cp /etc/zookeeper/conf:/usr/share/java/jline.jar...

# Now try to stop it
root@2d88cb921d2a:/# /etc/init.d/zookeeper stop
root@2d88cb921d2a:/# echo $?
0

# Check if its still running
root@2d88cb921d2a:/# ps aux | grep zookeeper
root       336  0.0  0.0  34048  8524 ?        T    07:43   0:00 zile 
/etc/init.d/zookeeper
zookeep+   357  0.1  0.8 4682800 106684 ?      Sl   07:51   0:02 /usr/bin/java 
-cp /etc/zookeeper/conf:/usr/share/java/jline.jar...

# Instead invoke the correct start-stop daemon invocation
root@2d88cb921d2a:/# start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 
--pidfile /var/run/zookeeper/zookeeper.pid 
root@2d88cb921d2a:/# ps aux | grep zookeeper
root       452  0.0  0.0  11984   912 ?        S+   08:21   0:00 grep 
--color=auto zookeeper

Possible solution:
----------------------------

A more robust alternative to these functions can be found in the
cassandra package, whose functions are as follows:

is_running()
{
    if [ -f $PIDFILE ]; then
        pid=`cat $PIDFILE`
        grep -Eq "$CMD_PATT" "/proc/$pid/cmdline" 2>/dev/null && return 0
        return 1
    fi
    return 3
}

... and  ...

do_stop()
{
    # Return
    #   0 if daemon has been stopped
    #   1 if daemon was already stopped
    #   2 if daemon could not be stopped
    #   other if a failure occurred
    start-stop-daemon -K -p "$PIDFILE" -R TERM/30/KILL/5 >/dev/null
    RET=$?
    rm -f "$PIDFILE"
    return $RET
}

** Affects: zookeeper (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1433469

Title:
  zookeeper init script fails to stop service

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/zookeeper/+bug/1433469/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to