Skip to content

Error in vCPUS computing #6

Description

@RenaudDemarneffe

Hi,

I built a container with the scripts and executed it on K8S.

I have an error on vCPU computing when running on IBM K8S cluster. I give 2 CPU to the Informix container.

The value of vCPU_CONTAINER returned by the container (in the script "calculate_onconfig.sh") is 40000.

informix@informixdb-0:/opt/ibm/config$ cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us
40000
informix@informixdb-0:/opt/ibm/config$ cat /sys/fs/cgroup/cpu/cpu.cfs_period_us
20000

When I run the same command in a docker on my laptop (CentOS), I get the following values.

informix@informixdb-0:/opt/ibm/config$ cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us
200000
informix@informixdb-0:/opt/ibm/config$ cat /sys/fs/cgroup/cpu/cpu.cfs_period_us
100000

I think the right formula to compute the number of vCPU allocated to the container is the following:

CPUFILE_QUOTA="/sys/fs/cgroup/cpu/cpu.cfs_quota_us"
CPUFILE_PERIOD="/sys/fs/cgroup/cpu/cpu.cfs_period_us"

vCPUS_CONTAINER_QUOTA=`cat $CPUFILE_QUOTA`
vCPUS_CONTAINER_PERIOD=`cat $CPUFILE_PERIOD`

###
### Set the amount of CPU's available to the docker container
###
if [[ $vCPUS_CONTAINER == "-1" ]]
then
   vCPUS=$vCPUS_HOST
else
   vCPUS=`echo "$vCPUS_CONTAINER_QUOTA / $vCPUS_CONTAINER_PERIOD" | bc`
fi

Could you please check?

Regards,
Renaud

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions