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

Failure to restart from Jenkins: "jenkins: /usr/bin/java" not found

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • core
    • Jenkins LTS 2.303.3 (via pkg.jenkins.io/debian-stable) on Debian 11 “Bullseye”

      Jenkins 2.303.3 fails to restart itself, e.g. after adjusting plugins (additions, updates, deletions), leaving users to face the “Please wait while Jenkins is restarting” page).

      The following trace is left behind:

      WARNING jenkins.model.Jenkins$20#run: Failed to restart Jenkins
      java.io.IOException: Failed to exec 'jenkins: /usr/bin/java' No such file or directory
        at hudson.lifecycle.UnixLifecycle.restart(UnixLifecycle.java:88)
        at jenkins.model.Jenkins$20.run(Jenkins.java:4482)

      Checking the code, there seems to be an absolute trust in the current arguments (except for --daemon getting stripped): https://github.com/jenkinsci/jenkins/blob/stable-2.303/core/src/main/java/hudson/lifecycle/UnixLifecycle.java#L54-L64

      That cannot work since daemon version 0.7.0-1 as found in Debian 11+ (published 2021-08), and apparently Ubuntu since Hirsute Hippo (published 2021-04)… prepends the value of the --name parameter in argv[0], contrary to 0.6.4-1 as found in Debian 6-10 and earlier Ubuntu versions.

      The relevant code added between 0.6.4-1 and 0.7.0-1: https://sources.debian.org/src/daemon/0.7-1/daemon.c/#L4338-L4351

      This can be checked with the ps command (asking for detailed output) or with e.g.:

      # tr '\0' '\n' < /proc/<pid>/cmdline
      jenkins: /usr/bin/java
      -Djava.awt.headless=true
      -jar
      /usr/share/jenkins/jenkins.war
      --webroot=/var/cache/jenkins/war
      --httpPort=8080

      I'm not sure what a proper fix would look like though. If that kind of fun is limited to newer daemon versions, maybe just rewriting the first argument, dropping a possible leading "jenkins: " string would be sufficient to dodge this issue, without having to rethink the whole restart procedure?

            basil Basil Crow
            cyrilbrulebois Cyril Brulebois
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: