Initscript is not returning its exec code properly

Bug #1452878 reported by Caio Begotti
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Capomastro
Fix Released
High
Unassigned

Bug Description

Manual check:

ubuntu@juju-stg-pes-capomastro-machine-4:/var/log/capomastro$ celery -A capomastro inspect active
-> celery@juju-stg-pes-capomastro-machine-4: OK
    - empty -
ubuntu@juju-stg-pes-capomastro-machine-4:/var/log/capomastro$ echo $?
0

Using the initscript:

ubuntu@juju-stg-pes-capomastro-machine-4:/var/log/capomastro$ sudo service capomastro check
-> celery@juju-stg-pes-capomastro-machine-4: OK
    - empty -
ubuntu@juju-stg-pes-capomastro-machine-4:/var/log/capomastro$ echo $?
1

That's wrong and will probably count as one more hole in the initscript that will force us to use Celeryd's scripts instead, I guess.

Related branches

Revision history for this message
Daniel Manrique (roadmr) wrote :

Oh, I see where the problem is.

do_check () {
  ${DAEMON} -A ${NAME} ${*}

  [ "${?}" = 2 ] && return 2
  return "${?}"
}

The [ "${?}" = 2 ] comparison is reassigning the value of $?, so when you check it on the next line, you get 1 (false), which is the result of the comparison, not of the daemon run check.

The function should look like this instead, so it immediately stores the value of celery inspect active to protect it from future alterations:

do_check () {
  ${DAEMON} -A ${NAME} ${*}
  retval=${?}
  [ "${retval}" = 2 ] && return 2
  return "${retval}"
}

Changed in capomastro:
importance: Undecided → High
milestone: none → 2015-06
status: New → Triaged
Daniel Manrique (roadmr)
Changed in capomastro:
status: Triaged → In Progress
assignee: nobody → Daniel Manrique (roadmr)
Daniel Manrique (roadmr)
Changed in capomastro:
status: In Progress → Fix Committed
Daniel Manrique (roadmr)
Changed in capomastro:
status: Fix Committed → Fix Released
assignee: Daniel Manrique (roadmr) → nobody
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.