@@ -142,14 +142,10 @@ class Scheduler {
142142 policy = GuaranteedPolicy ();
143143 }
144144 final int ? priority = await policy.triggerPriority (task: task, datastore: datastore);
145- // Skip scheduling `bringup: true` targets. They may be newly created and
146- // their corresponding LUCI builder configs may not be ready yet considering we
147- // disabled the `ci_yaml roller` backfill. Existing `bringup: true` targets
148- // can rely on backfiller to get tasks scheduled and executed.
149- if (priority != null && ! target.value.bringup) {
145+ if (_shouldSchedule (priority, target.value.bringup, policy)) {
150146 // Mark task as in progress to ensure it isn't scheduled over
151147 task.status = Task .statusInProgress;
152- toBeScheduled.add (Tuple <Target , Task , int >(target, task, priority));
148+ toBeScheduled.add (Tuple <Target , Task , int >(target, task, priority! ));
153149 }
154150 }
155151
@@ -169,6 +165,22 @@ class Scheduler {
169165 await _uploadToBigQuery (commit);
170166 }
171167
168+ /// Checks whether the task should be scheduled.
169+ ///
170+ /// Skips scheduling `bringup: true` targets for BatchPolicy. For BatchPolicy,
171+ /// targets may be newly created and their corresponding LUCI builder configs may
172+ /// not be ready yet considering we disabled the `ci_yaml roller` backfill.
173+ /// Existing `bringup: true` targets can rely on backfiller to get tasks scheduled and executed.
174+ bool _shouldSchedule (int ? priority, bool bringup, SchedulerPolicy policy) {
175+ if (priority == null ) {
176+ return false ;
177+ }
178+ if (bringup) {
179+ return policy is ! BatchPolicy ;
180+ }
181+ return true ;
182+ }
183+
172184 /// Schedule all builds in batch requests instead of a single request.
173185 ///
174186 /// Each batch request contains [Config.batchSize] builds to be scheduled.
0 commit comments