Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

virt-install: do not assign vpu's when executed in Kubernetes #284

Merged
merged 1 commit into from
Jan 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/virt-install
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ def get_libvirt_smp_arg():
See e.g. https://www.redhat.com/archives/libvirt-users/2017-June/msg00025.html
We want to match the number of host physical cores.
"""

# When running under K8S, the scehduling may be much more restrictive than
# physical core count, and the code below will assign that count, leading
# to a VM hang. (e.g. 64 vcpu's to a 1 cpu assignment...)
p1c = open("/proc/1/cgroup")
if re.search(r'.*kubepods.*', p1c.read()):
return '--vcpus=sockets=1,cores=1,threads=1'
Copy link
Member

Choose a reason for hiding this comment

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

Humm...I swear we tested this though. When I e.g. rsh into a MCD pod and type nproc I get 2 which matches the host.

You're saying this code is returning 64 today?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I saw this in OpenShift where I had a resource limit of 2CPU's. Looking at the logs, it was clearly getting 64.


# We may be run in a cgroup with fewer cores available than physical.
available_cpu = int(subprocess.check_output(['nproc']).strip())
# https://stackoverflow.com/questions/6481005/how-to-obtain-the-number-of-cpus-cores-in-linux-from-the-command-line
Expand Down