Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
For each poll of BK for jobs, run the rest of the pipeline (deduper -> limiter -> scheduler) in parallel (with a fairly conservative default concurrency of 5 goroutines).
Randomise the order in which jobs are sent.
Why
If 100% of jobs sent to k8s successfully create, then (up to the MaxInFlight limit if it applies) the current process should always make progress even if the k8s API was slow, because
staleCtx
only interrupts waiting for limiter tokens, not the creation of jobs. (Any job that makes its way through the limiter will be sent to k8s by the scheduler.) The other bits in the middle shouldn't be so slow thatstaleCtx
is cancelled first.If some jobs successfully create and some won't, then that's most likely a property of the job (e.g. the job name collides with an existing job). If we try and fail to create the same job over and over, and creating jobs is slow enough that we don't get through enough of the broken ones before
staleCtx
expires, we won't progress.Randomising the order of creating jobs means jobs that could successfully be created get a chance. Adding parallelism to create more jobs at a time will increase load on the k8s cluster, but let more jobs be tried before staleness kicks in.