Skip to content

Commit

Permalink
Clamp thread count to number of envs to export (#905)
Browse files Browse the repository at this point in the history
* Clamp thread count to number of envs to export
No need to launch 32 workers if we have two envs to export!

* Update pkg/tanka/parallel.go

Co-authored-by: Javier Palomo <javier.palomo@grafana.com>

---------

Co-authored-by: Javier Palomo <javier.palomo@grafana.com>
  • Loading branch information
julienduchesne and jvrplmlmn authored Aug 9, 2023
1 parent 965612c commit 2238ad2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/tanka/parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ func parallelLoadEnvironments(envs []*v1alpha1.Environment, opts parallelOpts) (
opts.Parallelism = defaultParallelism
}

if opts.Parallelism > len(envs) {
log.Info().Int("parallelism", opts.Parallelism).Int("envs", len(envs)).Msg("Reducing parallelism to match number of environments")
opts.Parallelism = len(envs)
}

for i := 0; i < opts.Parallelism; i++ {
go parallelWorker(jobsCh, outCh)
}
Expand Down

0 comments on commit 2238ad2

Please sign in to comment.