You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by "Clark Updike (JIRA)" <ji...@apache.org> on 2014/10/01 17:11:46 UTC
[jira] [Created] (AMBARI-7591) ambari-server init script returns
wrong exit status code when service is not running
Clark Updike created AMBARI-7591:
------------------------------------
Summary: ambari-server init script returns wrong exit status code when service is not running
Key: AMBARI-7591
URL: https://issues.apache.org/jira/browse/AMBARI-7591
Project: Ambari
Issue Type: Bug
Components: ambari-server
Affects Versions: 1.6.1
Environment: Redhat 6.5
Reporter: Clark Updike
Priority: Minor
Running {{service ambari-server status}} returns an exit status code of 0 even when the service is not running--as demonstrated with some && || conditions:
{code}
[ ~]# sudo service ambari-server status && echo "running" || echo "not running"
Using python /usr/bin/python2.6
Ambari-server status
Ambari Server running
Found Ambari Server PID: '3653 at: /var/run/ambari-server/ambari-server.pid
running
[ ~]# service ambari-server stop
Using python /usr/bin/python2.6
Stopping ambari-server
Ambari Server stopped
[ ~]# sudo service ambari-server status && echo "running" || echo "not running"
Using python /usr/bin/python2.6
Ambari-server status
Ambari Server not running. Stale PID File at: /var/run/ambari-server/ambari-server.pid
running #### WHOOPS!
{code}
This does not conform with standards:
http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
This prevents tools like Saltstack (a configuration management tool) from managing the service since it always thinks it is running.
A possible fix is to add an exit to line 105 of /etc/rc.d/init.d/ambari-server:
{code}
102 status)
103 #echo -e "Ambari-server status"
104 $PYTHON /usr/sbin/ambari-server.py $@
105 exit
{code}
And add a sys.exit(1) to /usr/sbin/ambari-server.py:
{code}
2890 else:
2891 print "Ambari Server not running. Stale PID File at: " + PID_DIR + os.sep + PID_NAME
2892 sys.exit(1)
{code}
Here is the related issue I filed with Saltstack (but it is dispositioned as a documentation issue):
https://github.com/saltstack/salt/issues/16245#issuecomment-57402182
Note that ambari-agent does not have this problem (it is implemented correctly):
{code}
[ ~]$ sudo service ambari-agent status && echo "running" || echo "not running"
Found ambari-agent PID: 3156
ambari-agent running.
Agent PID at: /var/run/ambari-agent/ambari-agent.pid
Agent out at: /var/log/ambari-agent/ambari-agent.out
Agent log at: /var/log/ambari-agent/ambari-agent.log
running
[ ~]$ sudo service ambari-agent stop
Verifying Python version compatibility...
Using python /usr/bin/python2.6
Found ambari-agent PID: 3156
Stopping ambari-agent
Removing PID file at /var/run/ambari-agent/ambari-agent.pid
ambari-agent successfully stopped
[ ~]$ sudo service ambari-agent status && echo "running" || echo "not running"
ambari-agent currently not running
Usage: /usr/sbin/ambari-agent {start|stop|restart|status}
not running #### CORRECT
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)