jenkinsci / jenkinsci/ec2-plugin

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

Open
#1,776 2 comments 0 reactions 0 assignees View on GitHub
component:ec2-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
292
Forks
709
Avg merge
3d 16h
Merged PRs (30d)
4

Description

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.

---
Originally reported by mjuszczak, imported from: Global instance cap incorrectly applying across all "Amazon EC2" clouds


  • assignee: thoulen
  • status: Open
  • priority: Minor
  • component(s): ec2-plugin
  • label(s): ec2-plugin, plugin
  • resolution: Unresolved
  • votes: 1
  • watchers: 3
  • imported: 2025-12-06

Raw content of original issue

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.

environment

```
java.runtime.name: OpenJDK Runtime Environment

java.runtime.version: 11.0.7+10-post-Ubuntu-2ubuntu218.04

ec2: 1.49.1

```

Contributor guide

Open the contributing guide

Research direction

Start in src/main/java/hudson/plugins/ec2/EC2Cloud.java at lines 587-597 and trace the methods used to calculate availableTotalSlaves. Follow how instanceCapStr and cloudName are applied when multiple Amazon EC2 cloud configurations exist. Done means the global instance cap is scoped to the relevant cloud rather than all EC2 instances.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, java
Domain
cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.