Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: JENKINS-36878: vSphere now respects per-slave instance cap.
Bugfix: JENKINS-32112: NPE bug in vSphere.getTemplate(). Enhancement: vSphere.java now distributes load over all matching templates. This satisfies JENKINS-30203 if Jenkins is configured with a template. Correction: Jenkins UI no longer offers facility to manually create a Cloud-provisioned slave (the cloud provisions those itself). Normal vSphere slaves are still manually provisionable. Cleaned up logging in vSphere.java. Typo in vSphereCloudSlaveTemplate: getNumberOfExceutors -> getNumberOfExecutors.
- Loading branch information
Showing
8 changed files
with
1,219 additions
and
159 deletions.
There are no files selected for viewing
273 changes: 173 additions & 100 deletions
273
src/main/java/org/jenkinsci/plugins/vSphereCloud.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/org/jenkinsci/plugins/vsphere/tools/CloudProvisioningAlgorithm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.jenkinsci.plugins.vsphere.tools; | ||
|
||
import java.util.Collection; | ||
import java.util.Comparator; | ||
import java.util.Iterator; | ||
import java.util.Set; | ||
import java.util.SortedSet; | ||
import java.util.TreeSet; | ||
|
||
import org.jenkinsci.plugins.vSphereCloudSlaveTemplate; | ||
|
||
/** | ||
* How we decide what template to create the next slave on. | ||
*/ | ||
public final class CloudProvisioningAlgorithm { | ||
private CloudProvisioningAlgorithm() { | ||
} | ||
|
||
/** | ||
* Given a bunch of templates to choose from, works out which one we should | ||
* use next. | ||
* | ||
* @param provisionables | ||
* Template records to decide between. | ||
* @return The record with the most free capacity, or null if there are none | ||
* with any capacity. | ||
*/ | ||
public static CloudProvisioningRecord findTemplateWithMostFreeCapacity( | ||
Collection<? extends CloudProvisioningRecord> provisionables) { | ||
final SortedSet<CloudProvisioningRecord> sortedSet = new TreeSet<CloudProvisioningRecord>( | ||
CloudProvisioningRecord.leastUsedFirst); | ||
sortedSet.addAll(provisionables); | ||
final Iterator<CloudProvisioningRecord> iterator = sortedSet.iterator(); | ||
if (iterator.hasNext()) { | ||
final CloudProvisioningRecord bestOption = iterator.next(); | ||
if (bestOption.hasCapacityForMore()) { | ||
return bestOption; | ||
} | ||
} | ||
return null; | ||
} | ||
} |
Oops, something went wrong.