Skip to content

Commit

Permalink
chore: Add docs and move vars inside their if's
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxymVlasov committed Jan 31, 2025
1 parent 9bd7a26 commit 4a77613
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions hooks/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4a77613

Please sign in to comment.