@@ -260,29 +260,30 @@ function get_cgroup_value() {
260260 cat " $cgroup /$1 "
261261}
262262
263- # Helper to check a if value in a cgroup file matches the expected one .
263+ # Check if a value in a cgroup file $1 matches $2 or $3 (if specified) .
264264function check_cgroup_value() {
265- local current
266- current=" $( get_cgroup_value " $1 " ) "
267- local expected=$2
265+ local got
266+ got=" $( get_cgroup_value " $1 " ) "
267+ local want=$2
268+ local want2=" ${3:- } "
268269
269- echo " current $current !? $expected "
270- [ " $current " = " $expected " ]
270+ echo " $1 : got $got , want $want $want2 "
271+ [ " $got " = " $want " ] || [[ -n " $want2 " && " $got " = " $want2 " ] ]
271272}
272273
273- # Helper to check a value in systemd.
274+ # Check if a value of systemd unit property $1 matches $2 or $3 (if specified) .
274275function check_systemd_value() {
275276 [ ! -v RUNC_USE_SYSTEMD ] && return
276277 local source=" $1 "
277278 [ " $source " = " unsupported" ] && return
278- local expected =" $2 "
279- local expected2 =" ${3:- } "
279+ local want =" $2 "
280+ local want2 =" ${3:- } "
280281 local user=" "
281282 [ $EUID -ne 0 ] && user=" --user"
282283
283- current =$( systemctl show $user --property " $source " " $SD_UNIT_NAME " | awk -F= ' {print $2}' )
284- echo " systemd $source : current $current !? $expected $expected2 "
285- [ " $current " = " $expected " ] || [[ -n " $expected2 " && " $current " = " $expected2 " ]]
284+ got =$( systemctl show $user --property " $source " " $SD_UNIT_NAME " | awk -F= ' {print $2}' )
285+ echo " systemd $source : got $got , want $want $want2 "
286+ [ " $got " = " $want " ] || [[ -n " $want2 " && " $got " = " $want2 " ]]
286287}
287288
288289function check_cpu_quota() {
@@ -316,8 +317,10 @@ function check_cpu_quota() {
316317function check_cpu_burst() {
317318 local burst=$1
318319 if [ -v CGROUP_V2 ]; then
319- burst=$(( burst / 1000 ))
320- check_cgroup_value " cpu.max.burst" " $burst "
320+ # Due to a kernel bug (fixed by commit 49217ea147df, see
321+ # https://lore.kernel.org/all/[email protected] /), 322+ # older kernels printed value divided by 1000. Check for both.
323+ check_cgroup_value " cpu.max.burst" " $burst " " $(( burst / 1000 )) "
321324 else
322325 check_cgroup_value " cpu.cfs_burst_us" " $burst "
323326 fi
0 commit comments