batches: use Docker CPU count as default parallelism, not GOMAXPROCS
Created by: LawnGnome
This PR changes the default parallelism of src batch preview|apply
runs to be based on the CPU cores reported by docker info
.
Practically, this means that Docker Desktop users will now have their parallelism based on the VM Docker runs within, not their host machine. The trade off here is that Docker Desktop users will likely have their default parallelism cut significantly, but this is also likely to make issues caused by the Docker VM having its resources exhausted considerably less likely.
Implementation notes
- I've migrated the previous
docker version
preflight to usedocker info
instead, which means we can get the CPU count and preflight Docker at the same time. - Since
docker info
should always be quick, this reuses the same timeout behaviour as #783, which has been renamed from beingimage inspect
specific to being used for any "fast commands" issued to Docker. The behaviour is otherwise unchanged. - In testing this, I found an issue where
os/exec
is inconsistent in terms of the error returned when a deadline is exceeded; I've updated both places we use the fast command context to look both at the returned error and the context error.
Screenshot of the timeout
Test plan
Added unit tests, and tested this in various scenarios locally (Docker not running; Docker running but unresponsive; Docker running normally).