Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: system property to disable no delay provisioner cloud shuffle #1400

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ Please read [Features controlled by system properties](https://www.jenkins.io/do

* `KUBERNETES_JENKINS_URL` : Jenkins URL to be used by agents. This is meant to be used for OEM integration.
* `io.jenkins.plugins.kubernetes.disableNoDelayProvisioning` (since 1.19.1) Whether to disable the no-delay provisioning strategy the plugin uses (defaults to `false`).
* `io.jenkins.plugins.kubernetes.NoDelayProvisionerStrategy.disableCloudShuffle` Whether to disable the shuffling of clouds. When true clouds will be searched in order they are defined (defaults to `false`).
* `jenkins.host.address` : (for unit tests) controls the host agents should use to contact Jenkins
* `org.csanchez.jenkins.plugins.kubernetes.PodTemplate.connectionTimeout` : The time in seconds to wait before considering the pod scheduling has failed (defaults to `1000`)
* `org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator.stdinBufferSize` : stdin buffer size in bytes for commands sent to Kubernetes exec api. A low value will cause slowness in commands executed. A higher value will consume more memory (defaults to `16*1024`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class NoDelayProvisionerStrategy extends NodeProvisioner.Strategy {
private static final Logger LOGGER = Logger.getLogger(NoDelayProvisionerStrategy.class.getName());
private static final boolean DISABLE_NODELAY_PROVISING = Boolean.valueOf(
System.getProperty("io.jenkins.plugins.kubernetes.disableNoDelayProvisioning"));
private static final boolean DISABLE_CLOUD_SHUFFLE = Boolean.getBoolean(NoDelayProvisionerStrategy.class.getName() + ".disableCloudShuffle");

@Override
public NodeProvisioner.StrategyDecision apply(NodeProvisioner.StrategyState strategyState) {
Expand All @@ -56,7 +57,10 @@ public NodeProvisioner.StrategyDecision apply(NodeProvisioner.StrategyState stra
new Object[]{availableCapacity, currentDemand});
if (availableCapacity < currentDemand) {
List<Cloud> jenkinsClouds = new ArrayList<>(Jenkins.get().clouds);
Collections.shuffle(jenkinsClouds);
if (!DISABLE_CLOUD_SHUFFLE) {
Collections.shuffle(jenkinsClouds);
}

Cloud.CloudState cloudState = new Cloud.CloudState(label, strategyState.getAdditionalPlannedCapacity());
for (Cloud cloud : jenkinsClouds) {
int workloadToProvision = currentDemand - availableCapacity;
Expand All @@ -67,6 +71,7 @@ public NodeProvisioner.StrategyDecision apply(NodeProvisioner.StrategyState stra
continue;
}
}

Collection<NodeProvisioner.PlannedNode> plannedNodes = cloud.provision(cloudState, workloadToProvision);
LOGGER.log(Level.FINE, "Planned {0} new nodes", plannedNodes.size());
fireOnStarted(cloud, strategyState.getLabel(), plannedNodes);
Expand Down