From 4a77613df549311bc78ace238da50b6c6274c1b9 Mon Sep 17 00:00:00 2001 From: MaxymVlasov Date: Sat, 1 Feb 2025 00:12:02 +0200 Subject: [PATCH] chore: Add docs and move vars inside their if's --- hooks/_common.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hooks/_common.sh b/hooks/_common.sh index bfc3b432e..4ffff3cea 100644 --- a/hooks/_common.sh +++ b/hooks/_common.sh @@ -197,12 +197,12 @@ function common::is_hook_run_on_whole_repo { function common::get_cpu_num { local -r parallelism_ci_cpu_cores=$1 - local cpu_quota cpu_period cpu_num - local millicpu - if [[ -f /sys/fs/cgroup/cpu/cpu.cfs_quota_us && ! -f /proc/sys/fs/binfmt_misc/WSLInterop ]]; then # WSL have cfs_quota_us, but WSL should be checked as usual Linux host # Inside K8s pod or DinD in K8s + local cpu_quota cpu_period cpu_num + # CPU quota should be calculated as `cpu.cfs_quota_us / cpu.cfs_period_us` + # See: https://docs.kernel.org/scheduler/sched-bwc.html cpu_quota=$(< /sys/fs/cgroup/cpu/cpu.cfs_quota_us) cpu_period=$(cat /sys/fs/cgroup/cpu/cpu.cfs_period_us 2> /dev/null || echo "$cpu_quota") @@ -242,6 +242,7 @@ function common::get_cpu_num { if [[ -f /sys/fs/cgroup/cpu.max ]]; then # Inside Linux (Docker?) container + local millicpu millicpu=$(cut -d' ' -f1 /sys/fs/cgroup/cpu.max) if [[ $millicpu == max ]]; then