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

Instance cap calculation ignores instance profile

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • ec2-plugin
    • None
    • Jenkins 2.235.4
      ec2-plugin 1.51

      We have 2 agent templates that use the same AMI but with a different instance profile.

      If I set instance cap = 1 on both agent templates, and there is already one agent active for one of them, then the other agent will fail to start.

      The log would loop on

      Jul 15, 2020 8:28:57 AM INFO hudson.plugins.ec2.EC2Cloud provision
      SlaveTemplate{ami='ami-059e244da7c54c1fe', labels='docker docker-bakery'}. Attempting to provision slave needed by excess workload of 4 units
      Jul 15, 2020 8:28:57 AM INFO hudson.plugins.ec2.EC2Cloud getNewOrExistingAvailableSlave
      SlaveTemplate{ami='ami-059e244da7c54c1fe', labels='docker docker-bakery'}. Cannot provision - no capacity for instances: 0
      Jul 15, 2020 8:28:57 AM WARNING hudson.plugins.ec2.EC2Cloud provision
      Can't raise nodes for SlaveTemplate{ami='ami-059e244da7c54c1fe', labels='docker docker-bakery'}

      I think the reason is that the query doesn't include instance profile.

      Looking for existing instances with describe-instance: {Filters: [{Name: image-id,Values: [ami-059e244da7c54c1fe]}, {Name: instance-type,Values: [t3.micro]}, {Name: key-name,Values: [j4a-ec2-ssh-key]}, {Name: subnet-id,Values: [subnet-0eeb1506910488624]}, {Name: instance.group-id,Values: [sg-092080629f55910cb]}, {Name: tag:Name,Values: [ew1-j4a-jenkins-slave-ec2]}, {Name: tag:jenkins_server_url,Values: [https://example.com/]}, {Name: tag:DeploymentName,Values: [ew1-j4a]}, {Name: tag:Contact,Values: [example@example.com]}, {Name: tag:DeploymentType,Values: [dev]}, {Name: tag:DeploymentGroup,Values: [ew1-j4a]}, {Name: tag:CostCenter,Values: [31505007]}, {Name: tag:jenkins_slave_type,Values: [demand_ec2 (ami-059e244da7c54c1fe)]}],InstanceIds: [],}
      

      I was able to work around the issue by adding a tag with the same value as instance profile.

            thoulen FABRIZIO MANFREDI
            jbochenski Jakub Bochenski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: