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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 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
            unicolet Umberto Nicoletti
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: