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

Node's offlineCause due to schedule lost after restart

      I am working on a tool that uses the Jenkins APIs to figure out which offline machines and be shut down and then which should be restarted before they are supposed to go online. Because I didn't want to shut down a machine if someone brought it offline manually, I look for offlineCause elements with a _class attribute of hudson.slaves.OfflineCause$SimpleOfflineCause from the /computer/api/xml REST API.

      That worked great until I upgraded Jenkins in the LTS series. Then all of a sudden, my code couldn't detect any scheduled offline nodes.

      It could be that an upgrade itself is the reason why the offlineCause was lost. The odd thing is that the Jenkins UI still knew why that node was offline:

      This node’s availability policy is: “Bring this agent online according to a schedule” Currently, this mandates that the node be offline.

      I assume/hope that when Jenkins interacts with node scheduled, offlineCauses will be properly formed at least until the next reboot.

          [JENKINS-72725] Node's offlineCause due to schedule lost after restart

          Robert added a comment -

          When a machine is scheduled offline after this happens, the offlineCause for that machine is in fact correct.

          Robert added a comment - When a machine is scheduled offline after this happens, the offlineCause for that machine is in fact correct.

          Markus Winter added a comment -

          I think the state you look for doesn't require to read the offline cause at all.
          You can read from the API the values "launchSupported" (which is true when it is an outbound agent, e.g. an ssh agent) and "manualLaunchAllowed".
          If an agent is offline and launchSupported =true and manualLaunchAllowed = false will lead to the message

          This node’s availability policy is: “Bring this agent online according to a schedule” Currently, this mandates that the node be offline.

          Markus Winter added a comment - I think the state you look for doesn't require to read the offline cause at all. You can read from the API the values "launchSupported" (which is true when it is an outbound agent, e.g. an ssh agent) and "manualLaunchAllowed". If an agent is offline and launchSupported =true and manualLaunchAllowed = false will lead to the message This node’s availability policy is: “Bring this agent online according to a schedule” Currently, this mandates that the node be offline.

            Unassigned Unassigned
            rpk_pro Robert
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: