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

feat: relationship between domain.cpu and requests #1

Open
scottd018 opened this issue Nov 22, 2024 · 1 comment
Open

feat: relationship between domain.cpu and requests #1

scottd018 opened this issue Nov 22, 2024 · 1 comment

Comments

@scottd018
Copy link
Collaborator

Currently, there are 2 ways to specify CPU when creating a Kubevirt VM instance.

  1. In the .spec.domain.[requests, limits].cpu section
  2. In the .spec.domain.cpu.[cores, sockets, thread] section

I believe the former applies to the launcher pod and the latter applies to the actual VM, so I believe calculating off of the latter is correct. We need to verify and adjust if needed. Here is the code:

	for vm := 0; vm < len(instances); vm++ {
		// according to kubevirt docs, vcpu is determined by the value of sockets * cores * threads
		// see https://kubevirt.io/user-guide/compute/dedicated_cpu_resources/#requesting-dedicated-cpu-resources
		sockets := int(instances[vm].Spec.Domain.CPU.Sockets)
		if sockets == 0 {
			sockets = 1
		}

		cores := int(instances[vm].Spec.Domain.CPU.Cores)
		if cores == 0 {
			cores = 1
		}

		threads := int(instances[vm].Spec.Domain.CPU.Threads)
		if threads == 0 {
			threads = 1
		}

		sum += sockets * cores * threads
	}
@scottd018
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant