Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

grpc: honour CPU constraints in Kubernetes #242

Merged
merged 1 commit into from
May 18, 2018

Conversation

devimc
Copy link

@devimc devimc commented May 16, 2018

Once all vCPUs have been connected, cpuset cgroup MUST BE updated,
to achieve that, each cpuset cgroup parent of the container
MUST BE updated with the actual range of vCPUs.

fixes #239

Signed-off-by: Julio Montes [email protected]

// Each cpuset cgroup MUST BE updated with the actual number of vCPUs.
cpusetPath := sysfsCpusetPath
cgroupsPaths := strings.Split(contConfig.Cgroups.Path, "/")
for _, path := range cgroupsPaths {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does cgroupsPaths only contain cpu cgroup path?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From cgroup_linux.go

specifies the path to cgroups that are created and/or joined by the container.
The path is assumed to be relative to the host system cgroup mountpoint.

For example, if contConfig.Cgroups.Path is docker/3201e3829cc65216f462da39363e8f36a10d80c63ece7f55818c9932b7a899a4, then each cgroup (memory, cpu, pids, cpuset, etc) contains a directory with this path

$ ls /sys/fs/cgroup/cpuset
cgroup.clone_children	cpuset.memory_pressure_enabled
cgroup.procs		cpuset.memory_spread_page
cgroup.sane_behavior	cpuset.memory_spread_slab
cpuset.cpu_exclusive	cpuset.mems
cpuset.cpus		cpuset.sched_load_balance
cpuset.effective_cpus	cpuset.sched_relax_domain_level
cpuset.effective_mems	docker
cpuset.mem_exclusive	notify_on_release
cpuset.mem_hardwall	release_agent
cpuset.memory_migrate	tasks
cpuset.memory_pressure

$ ls /sys/fs/cgroup/cpuset/docker
3201e3829cc65216f462da39363e8f36a10d80c63ece7f55818c9932b7a899a4
cgroup.clone_children
cgroup.procs
cpuset.cpu_exclusive
cpuset.cpus
cpuset.effective_cpus
cpuset.effective_mems
cpuset.mem_exclusive
cpuset.mem_hardwall
cpuset.memory_migrate
cpuset.memory_pressure
cpuset.memory_spread_page
cpuset.memory_spread_slab
cpuset.mems
cpuset.sched_load_balance
cpuset.sched_relax_domain_level
notify_on_release
tasks

@egernst
Copy link
Member

egernst commented May 17, 2018

see failure in tests:
./grpc_test.go:171:2: undefined: sysfsDockerCpusetPath

Copy link
Contributor

@jodh-intel jodh-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have tests (or atleast a https://github.com/kata-containers/tests issue to create new tests) for this change?

@@ -57,7 +56,7 @@ var (
sysfsCPUOnlinePath = "/sys/devices/system/cpu"
sysfsMemOnlinePath = "/sys/devices/system/memory"
sysfsConnectedCPUsPath = filepath.Join(sysfsCPUOnlinePath, "online")
sysfsDockerCpusetPath = "/sys/fs/cgroup/cpuset/docker/cpuset.cpus"
sysfsCpusetPath = "/sys/fs/cgroup/cpuset"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

grpc.go Outdated

agentLog.Debugf("Number of vCPUs to connect: %d", req.NbCpus)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: stylistically, I prefer to use WithField() or WithFields() for this message and others below:

agentLog.WithField("vcpus-to-connect", req.NbCpus).Debug("connecting vCPUs)

It also makes the logs easier+safer to parse as those fields are less likely to change.

@devimc
Copy link
Author

devimc commented May 17, 2018

@jodh-intel I filed an issue kata-containers/tests#309

@devimc devimc force-pushed the cpu/ks8FixConstraints branch 2 times, most recently from 08727a6 to 7fd38b0 Compare May 17, 2018 15:03
@codecov
Copy link

codecov bot commented May 17, 2018

Codecov Report

Merging #242 into master will increase coverage by 0.98%.
The diff coverage is 86.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #242      +/-   ##
==========================================
+ Coverage    41.8%   42.79%   +0.98%     
==========================================
  Files          13       13              
  Lines        1935     2033      +98     
==========================================
+ Hits          809      870      +61     
- Misses       1027     1056      +29     
- Partials       99      107       +8
Impacted Files Coverage Δ
mockcontainer.go 100% <100%> (ø) ⬆️
grpc.go 29.48% <85.71%> (+2.65%) ⬆️
network.go 49.16% <0%> (+0.44%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 60bcebf...4bad43e. Read the comment docs.

Once all vCPUs have been connected, cpuset cgroup MUST BE updated,
to achieve that, each cpuset cgroup parent of the container
MUST BE updated with the actual range of vCPUs.

fixes kata-containers#239
fixes kata-containers#232

Signed-off-by: Julio Montes <[email protected]>
@devimc devimc force-pushed the cpu/ks8FixConstraints branch from 7fd38b0 to 4bad43e Compare May 17, 2018 19:44
@devimc
Copy link
Author

devimc commented May 18, 2018

@jodh-intel @egernst please take a look

@jodh-intel
Copy link
Contributor

jodh-intel commented May 18, 2018

lgtm

Approved with PullApprove

@jodh-intel jodh-intel merged commit ee29fbc into kata-containers:master May 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

k8s: vCPUs are not connected
4 participants