Upstart can NOT handle service/job started by others

Bug #1337407 reported by bugproxy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
upstart (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

-- Problem Description --
Upstart can not see a service/job/process that has been started and running by someone else. Old style init.d/systemd fully/partially handle start/stop correctly (on other Linux systems without Upstart), no matter who started the process.

Our PMLinux collecting agent "daemon_PMLnx" was designed to start/run by root with any means, such as crontab, inittab, service, or even command line at a terminal. The program itself will quit immediately at the beginning if finds the process already running.

Generally, we prefer to organize PMLinux as a service, plus create a start hook in the crontab to run "daemon_PMLnx" at 3am every day, in order to guarantee a restart won't be forgot if someone ever stopped the job.

Here are some command outputs from Ubuntu/Upstart:

# uname -a
Linux ubuntu 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:09:21 UTC 2014 ppc64le ppc64le ppc64le GNU/Linux

# dpkg -l upstart
Name Version Architecture Description
-===========-================-=============-========================
ii upstart 1.12.1-0ubuntu4 ppc64el event-based init daemon

# ps -ef | grep -e PMLnx$ -e CRON$
root 10263 771 0 17:59 ? 00:00:00 CRON
root 10264 10263 0 17:59 ? 00:00:00 /bin/sh -c /var/perf/pm/bin/daemon_PMLnx (bug!)
root 10265 10264 0 17:59 ? 00:00:00 /var/perf/pm/bin/daemon_PMLnx

# start PMLinux
PMLinux stop/waiting <--- bad!

# status PMLinux
PMLinux stop/waiting <--- bad!

# stop PMLinux
stop: Unknown instance: <--- bad!

# kill -2 10265

# start PMLinux
PMLinux start/running, process 10562

# ps -ef | grep -e PMLnx$
root 10562 1 0 19:49 ? 00:00:00 /var/perf/pm/bin/daemon_PMLnx

# start PMLinux
start: Job is already running: PMLinux

# stop PMLinux
PMLinux stop/waiting

# stop PMLinux
stop: Unknown instance:

# cat /etc/init/PMLinux.conf
# daemon_PMLnx - Collecting Agent of IBM Performance Management for Power Linux (PMLinux)
#
# daemon_PMLnx collects PMLinux data at periodic scheduled times
# working HOME directory - /var/perf/pm

description "IBM PMLinux collecting daemon"
author "IBM PMLinux Team, Rochester, USA"

start on runlevel [2345]
stop on runlevel [!2345]

# console output # not works as expected: output to the working terminal (instead of system console)
pre-start script
        unset myErrMSG
        if [ ! -x /var/perf/pm/bin/daemon_PMLnx ]; then
                export myErrMSG='Daemon programs disappeared; please re-install ibmPMLinux'
# elif ps -C daemon_PMLnx >/dev/null; then
# export myErrMSG='PMLinux collecting daemon is already running!'
        elif [ ! -L /var/adm/perfmgr ] || [ ! -d /var/adm/perfmgr ]; then
                export myErrMSG='PMLinux was NOT enabled; Please run "config.PMLnx" to activate'
        fi
        if [ -n "$myErrMSG" ]; then
                echo -n "`date +'%D %T'` "; stop;
                echo "`date +'%D %T'` $myErrMSG"; exit 0
        fi
end script

post-start script
        if ps -C daemon_PMLnx >/dev/null; then
                echo "`date +'%D %T'` PMLinux collecting daemon running..."
        else
                echo "`date +'%D %T'` FAILED: Could NOT start PMLinux collecting daemon!!!"
        fi
end script

post-stop script
        echo "`date +'%D %T'` PMLinux collecting daemon stopped."
end script

exec /var/perf/pm/bin/daemon_PMLnx

The attachment is a screenshot to demonstrate an old init under a different distro 1 that can find/stop PMLinux daemon started from user terminal.

Revision history for this message
bugproxy (bugproxy) wrote : Init example that can handle service/job correctly

Default Comment by Bridge

tags: added: architecture-ppc64le bugnameltc-112942 severity-major
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https://wiki.ubuntu.com/Bugs/FindRightPackage. You might also ask for help in the #ubuntu-bugs irc channel on Freenode.

To change the source package that this bug is filed about visit https://bugs.launchpad.net/ubuntu/+bug/1337407/+editstatus and add the package name in the text box next to the word Package.

[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]

tags: added: bot-comment
Liangchang Guo (vcd0a5)
affects: ubuntu → upstart (Ubuntu)
bugproxy (bugproxy)
tags: added: severity-high targetmilestone-inin1410
removed: severity-major
bugproxy (bugproxy)
tags: added: severity-medium
removed: severity-high
Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla

------- Comment From <email address hidden> 2014-10-09 17:08 EDT-------
(In reply to comment #7)
> do you need to have scripts being fixed for you?
Yes, need to fix/enhance Upstart for me and other customers who accidentally type in and run a job at command line, or start the job from crontab, because once that was done (i.e. the job was started from outside of the Upstart), Upstart will be unable to stop/restart the job.

> are daemons missing permissions to execute properly and retrieve infos ?
No, the Upstart daemon has all the permission to do the expected things (stop/restart a job). It simply just can not function as what I expect.

Perhaps some people just think not Upstart's business to handle (stop/restart) the process which it did not ever run?

I believe the problem was clearly described at the defect opening.

Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2014-11-19 08:29 EDT-------
Looking at the man page, upstart is related to init process.
When a start cmd is issued there is a connection with init process to have the command being handled by init daemon.
So I don't think it is possible to manually start a process and then have init handling it.
Your request doesn't seem valuable for me unless you get another poinr of vue.

The only solution I see is that you put in your manual start script a check to issue a start command if not already started by it.

Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2014-11-19 15:16 EDT-------
(In reply to comment #10-11)
Please take a look at the attachment for how the "service" facility in Linux correctly handles a service.
If a system utility can NOT do the normal system-wide management, what value does it really have? I personally think "upstart" in Ubuntu has miles to go from the average expectation.

Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2014-11-20 16:54 EDT-------
(In reply to comment #12)
Even if systemd-sysv functions perfectly, it is not a solution to us, unless it will take the place of "upstart", or make the later behave as expected. The simple reason is: we can not decide which command the customers will use to manage their jobs/services. All is at our fault if they are unable to handle our daemon process (if started from crontab) with "upstart".

bugproxy (bugproxy)
tags: added: targetmilestone-inin14042
removed: targetmilestone-inin1410
Luciano Chavez (lnx1138)
Changed in upstart (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.