Skip to content

Commit da2e9a8

Browse files
yermulnikpre-commitMaxymVlasov
authored
fix(WSL): Fix parallelism support for WSL systems with enabled systemd (antonbabenko#872)
* chore(_common.sh): Add `WSLInterop-late` file check in `get_cpu_num` * Fix typo * pre-commit fixes * Streamline condition wrapping * make WSLInterop local var readonly Co-authored-by: Maksym Vlasov <[email protected]> * Also check `/run/WSL` file does not exist --------- Co-authored-by: pre-commit <[email protected]> Co-authored-by: Maksym Vlasov <[email protected]>
1 parent f7717cd commit da2e9a8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

hooks/_common.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,10 @@ function common::get_cpu_num {
206206

207207
local cpu_quota cpu_period cpu_num
208208

209+
local -r wslinterop_path="/proc/sys/fs/binfmt_misc/WSLInterop"
210+
209211
if [[ -f /sys/fs/cgroup/cpu/cpu.cfs_quota_us &&
210-
! -f /proc/sys/fs/binfmt_misc/WSLInterop ]]; then # WSL have cfs_quota_us, but WSL should be checked as usual Linux host
212+
(! -f "${wslinterop_path}" && ! -f "${wslinterop_path}-late" && ! -f "/run/WSL") ]]; then # WSL has cfs_quota_us, but WSL should be checked as usual Linux host
211213
# Inside K8s pod or DinD in K8s
212214
cpu_quota=$(< /sys/fs/cgroup/cpu/cpu.cfs_quota_us)
213215
cpu_period=$(cat /sys/fs/cgroup/cpu/cpu.cfs_period_us 2> /dev/null || echo "$cpu_quota")

0 commit comments

Comments
 (0)