From: Kienan Stewart Date: Tue, 20 Jun 2023 15:30:08 +0000 (-0400) Subject: jjb: Immediately remove currentJobs with null build X-Git-Url: https://git.liburcu.org/?a=commitdiff_plain;h=eedda9798a7ef2d43fda1ebf5fd238f2b52532b1;p=lttng-ci.git jjb: Immediately remove currentJobs with null build In 9ee19c2b8f8af895460c3cc132282a9f85ec27dd, jobs ended up getting set as 'Cancelled' if LaunchJob returned null instead of a Job object. Those cancellations meant that the entire result of the trigger was set to 'Aborted', masking otherwise successful runs. This commit changes the behaviour slightly by prunning entries with a null build immediately after the jobs are queued. This means that jobs that couldn't be found by name don't cause the build to be flagged as 'Aborted'. Change-Id: Ie76bb7bf05625eb541b0abdf0f05e95eb2d740c4 --- diff --git a/scripts/system-tests/system-trigger.groovy b/scripts/system-tests/system-trigger.groovy index c4013da..6b1028d 100644 --- a/scripts/system-tests/system-trigger.groovy +++ b/scripts/system-tests/system-trigger.groovy @@ -441,7 +441,21 @@ currentJobs.each { jobName, jobInfo -> jobInfo['status'] = 'PENDING'; jobInfo['build'] = LaunchJob(jobName, jobInfo); - ongoingJobs += 1; + if (jobInfo['build'] != null) { + ongoingJobs += 1; + } +} + +// Some jobs may have a null build immediately if LaunchJob +// failed for some reason, those jobs can immediately be removed. +def jobKeys = currentJobs.collect { jobName, jobInfo -> + return jobName; +} +jobKeys.each { k -> + if (currentJobs.get(k)['build'] == null) { + println(String.format("Removing job '%s' since build is null", k)); + currentJobs.remove(k); + } } while (ongoingJobs > 0) { @@ -455,7 +469,7 @@ while (ongoingJobs > 0) { // The isCancelled() method checks if the run was cancelled before // execution. We consider such run as being aborted. - if (jobBuild == null || jobBuild.isCancelled()) { + if (jobBuild.isCancelled()) { println("${jobName} was cancelled before launch.") isAborted = true; abortedRuns.add(jobName);