Skip to content

Commit c0cd9d7

Browse files
authored
Update getMachineLimit logic (#6645)
- streamline the getNumMachines() and getMachineLimit() logic - limit dynamic or EBC machines to 40 (was set to 20 before) resolves: runtimes/automation/issues/686 Signed-off-by: Lan Xia <[email protected]>
1 parent 4d6accc commit c0cd9d7

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

buildenv/jenkins/JenkinsfileBase

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,17 @@ def setupParallelEnv() {
231231
if (params.TRSS_URL) {
232232
PARALLEL_OPTIONS += " TRSS_URL=${params.TRSS_URL}"
233233
}
234-
int MAX_NUM_MACHINES = Math.min(20, getMachineLimit());
234+
int MAX_NUM_MACHINES = getMachineLimit();
235235
if (params.NUM_MACHINES) {
236-
int numOfMachines = getNumMachines()
236+
int numOfMachines = getNumMachines(MAX_NUM_MACHINES)
237237
PARALLEL_OPTIONS += " NUM_MACHINES=${numOfMachines} TEST_TIME="
238238
NUM_LIST = genParallelList(PARALLEL_OPTIONS)
239239
} else if (params.TEST_TIME) {
240240
String PARALLEL_OPTIONS_TEMP = PARALLEL_OPTIONS
241241
PARALLEL_OPTIONS += " TEST_TIME=${params.TEST_TIME} NUM_MACHINES="
242242
NUM_LIST = genParallelList(PARALLEL_OPTIONS)
243243
if (NUM_LIST > MAX_NUM_MACHINES && params.CLOUD_PROVIDER != "EBC") {
244-
echo "TEST_TIME (${params.TEST_TIME} minutes) is not possible as it exceeds the machine limit."
244+
echo "TEST_TIME (${params.TEST_TIME} minutes) is not possible as it exceeds the machine limit. NUM_LIST ${NUM_LIST} > MAX_NUM_MACHINES ${MAX_NUM_MACHINES}"
245245
echo "Regenerate parallel list with NUM_MACHINES=${MAX_NUM_MACHINES}."
246246
PARALLEL_OPTIONS = PARALLEL_OPTIONS_TEMP + " NUM_MACHINES=${MAX_NUM_MACHINES} TEST_TIME="
247247
NUM_LIST = genParallelList(PARALLEL_OPTIONS)
@@ -378,30 +378,33 @@ def genParallelList(PARALLEL_OPTIONS) {
378378
// Returns num
379379
// num = params.NUM_MACHINES. If it is not provided, the default value is 1
380380
// num cannot be greater than machines limit
381-
def getNumMachines() {
381+
def getNumMachines(limit) {
382382
int num = params.NUM_MACHINES ? params.NUM_MACHINES.toInteger() : 1
383-
if (params.CLOUD_PROVIDER == "EBC") {
384-
return num
385-
} else {
386-
int limit = getMachineLimit()
387-
echo "machine limit is ${limit}"
388-
if (num > limit) {
389-
echo "Number of machines cannot be greater than ${limit}. Set num to ${limit}"
390-
num = limit
391-
}
392-
return num
383+
if (num > limit) {
384+
echo "Number of machines ${num} cannot be greater than ${limit}. Set num to ${limit}."
385+
num = limit
393386
}
387+
return num
394388
}
395389

396390
def getMachineLimit(){
397-
int limit = nodesByLabel(LABEL).size()
398-
if (limit == 0) {
399-
error("No active nodes match the supplied LABEL: ${LABEL}")
400-
}
401-
// Set limit for dynamic vm agents to 100
391+
int limit = 1
402392
if (LABEL.contains('ci.agent.dynamic')) {
403-
limit = 100
393+
limit = 40
394+
} else if (env.JENKINS_URL.contains("hyc-runtimes") && (PLATFORM.contains("linux") || PLATFORM.contains("windows"))) {
395+
limit = 40
396+
} else {
397+
limit = nodesByLabel(LABEL).size()
398+
if (limit == 0) {
399+
error("No active nodes match the supplied LABEL: ${LABEL}")
400+
}
401+
limit = Math.min(20, limit)
402+
}
403+
// For Grinder, set machine limit to 20 max
404+
if (JOB_NAME.contains("Grinder")) {
405+
limit = Math.min(20, limit)
404406
}
407+
echo "Machine limit is ${limit}."
405408
return limit
406409
}
407410

0 commit comments

Comments
 (0)