Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
1.6.1
-
None
-
Redhat 6.5
Description
Running service ambari-server status returns an exit status code of 0 even when the service is not running--as demonstrated with some && || conditions:
[ ~]# 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!
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:
102 status)
103 #echo -e "Ambari-server status"
104 $PYTHON /usr/sbin/ambari-server.py $@
105 exit
And add a sys.exit(1) to /usr/sbin/ambari-server.py:
2890 else: 2891 print "Ambari Server not running. Stale PID File at: " + PID_DIR + os.sep + PID_NAME 2892 sys.exit(1)
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):
[ ~]$ 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
Attachments
Attachments
Issue Links
- links to