Skip to content

Commit e87ee43

Browse files
fix(WSL): Make parallelism work appropriately (antonbabenko#728)
* fix(`common::get_cpu_num`): Do not identify WSL as K8S --------- Co-authored-by: MaxymVlasov <MaxymVlasov@users.noreply.github.com>
1 parent 068ebb5 commit e87ee43

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

hooks/_common.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ function common::get_cpu_num {
199199

200200
local millicpu
201201

202-
if [[ -f /sys/fs/cgroup/cpu/cpu.cfs_quota_us ]]; then
202+
if [[ -f /sys/fs/cgroup/cpu/cpu.cfs_quota_us &&
203+
! -f /proc/sys/fs/binfmt_misc/WSLInterop ]]; then # WSL have cfs_quota_us, but WSL should be checked as usual Linux host
203204
# Inside K8s pod or DinD in K8s
204205
millicpu=$(< /sys/fs/cgroup/cpu/cpu.cfs_quota_us)
205206

@@ -251,7 +252,7 @@ function common::get_cpu_num {
251252
fi
252253

253254
# On host machine or any other case
254-
# `nproc` - Linux/FreeBSD, `sysctl -n hw.ncpu` - macOS/BSD, `echo 1` - fallback
255+
# `nproc` - Linux/FreeBSD/WSL, `sysctl -n hw.ncpu` - macOS/BSD, `echo 1` - fallback
255256
nproc 2> /dev/null || sysctl -n hw.ncpu 2> /dev/null || echo 1
256257
}
257258

0 commit comments

Comments
 (0)