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

Global instance cap incorrectly applying across all "Amazon EC2" clouds

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • ec2-plugin
    • java.runtime.name: OpenJDK Runtime Environment
      java.runtime.version: 11.0.7+10-post-Ubuntu-2ubuntu218.04
      ec2: 1.49.1

      It appears these lines of code and the methods they call are miscalculating availableTotalSlaves when using multiple "Amazon EC2" cloud configurations with the ec2 plugin.

      We have multiple "Amazon EC2" clouds configured with one AMI config each instead of using a single "Amazon EC2" configuration with multiple AMI configs. This is due to using Jenkins Configuration as Code and wanting to be able to put each AMI config in a separate YAML file (one per "customer").

      When we use the global instance cap (instanceCapStr) on one of these configurations, it seems to apply to ALL ec2 instances launched by the Jenkins master, not just the instances launched by that specific "Amazon EC2" cloud. It doesn't seem to use "cloudName" in the filter.

      We have worked around this temporarily by using the AMI-specific instanceCap.

          [JENKINS-62647] Global instance cap incorrectly applying across all "Amazon EC2" clouds

          Adam Gardner added a comment -

          As weird as it is, I'm pretty certain this is working as intended - it's not that the instance cap is counting instances from all of your configured EC2 clouds, it's literally counting all of the instances you have in EC2, period, even the ones that have nothing to do with Jenkins. Per the documentation: "For example, if this field is 3, Jenkins will only launch a new instance as long as total number of instances you run on EC2 (regardless of whether that is for Jenkins or for other purposes) doesn't exceed this number." 

          The "global" instanceCapStr is of pretty limited utility, frankly. It's basically just a safety net to prevent infinite instance creation if Jenkins creates instances, then loses track of them without terminating them and so creates new ones, etc.

           

          Adam Gardner added a comment - As weird as it is, I'm pretty certain this is working as intended - it's not that the instance cap is counting instances from all of your configured EC2 clouds, it's literally counting all of the instances you have in EC2, period, even the ones that have nothing to do with Jenkins. Per the documentation: "For example, if this field is 3, Jenkins will only launch a new instance as long as total number of instances you run on EC2 (regardless of whether that is for Jenkins or for other purposes) doesn't exceed this number."  The "global" instanceCapStr is of pretty limited utility, frankly. It's basically just a safety net to prevent infinite instance creation if Jenkins creates instances, then loses track of them without terminating them and so creates new ones, etc.  

          Matt Juszczak added a comment -

          philomory In that case, I agree with you that this isn't a bug per the documentation. Perhaps this would be better as a feature request to allow the cap to only apply to Jenkins-spawned instances (filtering on tag, perhaps the jenkins master URL). Thanks for your help on this.

          Matt Juszczak added a comment - philomory In that case, I agree with you that this isn't a bug per the documentation. Perhaps this would be better as a feature request to allow the cap to only apply to Jenkins-spawned instances (filtering on tag, perhaps the jenkins master URL). Thanks for your help on this.

            thoulen FABRIZIO MANFREDI
            mjuszczak Matt Juszczak
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: