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

Plugin starts a worked and might immediately stop it, because of cached EC2Computer.getUptime()



    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • ec2-plugin
    • None
    • Jenkins ver. 2.164.2
      Amazon EC2 plugin 1.42
    • 1.45


      AFAIU there's a race condition in EC2RetentionStrategy.java#L99


      a few lines below the  call to `computer.getUptime()` will return a cached value, whereas `computer.getState();` will not. If the worker was just started, this might lead to a race condition where the uptime will be calculated on the previous start time, rather then the current, and state will instead correctly report running.

      As a result of this inconsistency the plugin will end up stopping the instance because it will falsely compute uptime from the previous launch time, rather the current one (time difference from previous launch time is most likely to be more that idle timeout, which for us is 60 minutes).

      Does not happen often, perhaps we can just change `computer.getUptime()` to return the actual value rather than a cached value? Ideally calls to `computer` methods should return a consistent view for all getters.

      I'm willing to provide a PR, if someone could provide guidance on the suggested solution. Thanks!




          unicolet Umberto Nicoletti created issue -
          thoulen FABRIZIO MANFREDI made changes -
          Field Original Value New Value
          Status Open [ 1 ] In Progress [ 3 ]
          thoulen FABRIZIO MANFREDI made changes -
          Released As 1.45
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Closed [ 6 ]


            unicolet Umberto Nicoletti
            unicolet Umberto Nicoletti
            3 Vote for this issue
            5 Start watching this issue