Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-11306

Debian init script: status command exit code is always 0

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • core
    • None
    • Debian Lenny (5.0.9), Jenkins 1.434

      Under debian Lenny, the /etc/init.d/jenkins status script always exit with return code 0, even it the service is not running. According to LSB standard, the return code should be the following:

      • 0 program is running or service is OK;
      • 1 program is dead and /var/run pid file exists;
      • 3 program is not running.

      Found on https://fedoraproject.org/wiki/FCNewInit/Initscripts#Init_Script_Actions as official LSB website is currently down.

      This fixed status code is quite annoying if we rely on the init script for monitoring purpose.

          [JENKINS-11306] Debian init script: status command exit code is always 0

          The Debian Wiki collects together relevant information at
          http://wiki.debian.org/LSBInitScripts

          In particular the final comment says that Debian policy diverges from LSB in that Debian always uses return code 0.

          What is a "proper" exit status code?

          Looking at #208010, this seems rather controversial. Non-zero exit codes might even cause breakage, and the LSB conflicts with Debian policy here.

          There is much discussion at
          http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=208010

          It looks to me like current Debian behaviour/best practice is to return 0 as Jenkins currently does.

          Richard Mortimer added a comment - The Debian Wiki collects together relevant information at http://wiki.debian.org/LSBInitScripts In particular the final comment says that Debian policy diverges from LSB in that Debian always uses return code 0. What is a "proper" exit status code? Looking at #208010, this seems rather controversial. Non-zero exit codes might even cause breakage, and the LSB conflicts with Debian policy here. There is much discussion at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=208010 It looks to me like current Debian behaviour/best practice is to return 0 as Jenkins currently does.

          Reynald Borer added a comment -

          The situation of LSB compliance in Debian is indeed quite unclear, there is clearly no Debian way for the status command. Now in my use-case, I would find quite convenient to have a proper exit code if the service is not running, and I am probably not the only one in that case.

          Do you see any obvious case where this could have side effect?

          In the end, it looks like its up to the maintainer of the package to decide which way to go. I have manually patched the script on my Jenkins installations and my patch is not erased after each package upgrade, if anyone wants to apply the same patch, I opened a pull request: https://github.com/jenkinsci/jenkins/pull/281

          Reynald Borer added a comment - The situation of LSB compliance in Debian is indeed quite unclear, there is clearly no Debian way for the status command. Now in my use-case, I would find quite convenient to have a proper exit code if the service is not running, and I am probably not the only one in that case. Do you see any obvious case where this could have side effect? In the end, it looks like its up to the maintainer of the package to decide which way to go. I have manually patched the script on my Jenkins installations and my patch is not erased after each package upgrade, if anyone wants to apply the same patch, I opened a pull request: https://github.com/jenkinsci/jenkins/pull/281

          I looked at the debian bug #208010 and my reading is that the only disputed point is on a narrow point of "what exit code to return if the package is removed but not purged" (see msg #233 for example).

          I further looked /etc/init.d/ssh, which uses the standard /lib/lsb/init-functions code. The pidofproc() function in this script implements the same set of exit code as the proposed change.

          Furthermore, it's easy to ignore the status code if the caller doesn't care if we integrate this change, yet there's no easy workaround for the caller if we leave it out.

          So on the whole, I'm going to merge this change in.

          Kohsuke Kawaguchi added a comment - I looked at the debian bug #208010 and my reading is that the only disputed point is on a narrow point of "what exit code to return if the package is removed but not purged" (see msg #233 for example). I further looked /etc/init.d/ssh, which uses the standard /lib/lsb/init-functions code. The pidofproc() function in this script implements the same set of exit code as the proposed change. Furthermore, it's easy to ignore the status code if the caller doesn't care if we integrate this change, yet there's no easy workaround for the caller if we leave it out. So on the whole, I'm going to merge this change in.

          Code changed in jenkins
          User: Reynald Borer
          Path:
          changelog.html
          debian/debian/jenkins.init
          http://jenkins-ci.org/commit/jenkins/2f9fff923981c7aeccca9ca88482062a7e578a24
          Log:
          JENKINS-11306 Debian init script: return a proper status code when Jenkins is not running.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Reynald Borer Path: changelog.html debian/debian/jenkins.init http://jenkins-ci.org/commit/jenkins/2f9fff923981c7aeccca9ca88482062a7e578a24 Log: JENKINS-11306 Debian init script: return a proper status code when Jenkins is not running.

          Code changed in jenkins
          User: Reynald Borer
          Path:
          debian/debian/jenkins.init
          http://jenkins-ci.org/commit/jenkins/2cc316cb6e170b238598d0f38a8d7e7fe87c989e
          Log:
          JENKINS-11306 Debian init script: return a proper status code when Jenkins is not running.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Reynald Borer Path: debian/debian/jenkins.init http://jenkins-ci.org/commit/jenkins/2cc316cb6e170b238598d0f38a8d7e7fe87c989e Log: JENKINS-11306 Debian init script: return a proper status code when Jenkins is not running.

          dogfood added a comment -

          Integrated in jenkins_main_trunk #1274
          JENKINS-11306 Debian init script: return a proper status code when Jenkins is not running.

          Kohsuke Kawaguchi : 2f9fff923981c7aeccca9ca88482062a7e578a24
          Files :

          • debian/debian/jenkins.init
          • changelog.html

          dogfood added a comment - Integrated in jenkins_main_trunk #1274 JENKINS-11306 Debian init script: return a proper status code when Jenkins is not running. Kohsuke Kawaguchi : 2f9fff923981c7aeccca9ca88482062a7e578a24 Files : debian/debian/jenkins.init changelog.html

          Code changed in jenkins
          User: Reynald Borer
          Path:
          debian/jenkins.init
          http://jenkins-ci.org/commit/packaging/69e2d324eb23122ddf35a4b687c5bc0589b15c23
          Log:
          JENKINS-11306 Debian init script: return a proper status code when Jenkins is not running.

          Originally-From: jenkins-ci.org/commit/core/2f9fff923981c7aeccca9ca88482062a7e578a24

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Reynald Borer Path: debian/jenkins.init http://jenkins-ci.org/commit/packaging/69e2d324eb23122ddf35a4b687c5bc0589b15c23 Log: JENKINS-11306 Debian init script: return a proper status code when Jenkins is not running. Originally-From: jenkins-ci.org/commit/core/2f9fff923981c7aeccca9ca88482062a7e578a24

            Unassigned Unassigned
            rborer Reynald Borer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: