Skip to content

Commit bc1d56d

Browse files
Extend hypervisor crd for cortex filtering (#217)
## Background In [this pull request](cobaltcore-dev/cortex#441) we implemented a cortex filtering pipeline for KVM. This pipeline uses the hypervisor CRD as single source of truth to find out on which hypervisors a vm can be scheduled. To complete this implementation, we need to extend the hypervisor CRD. ## Tasks Support filtering based on hypervisor type and other capabilities: - [x] The capabilities struct should be extended to support the hypervisor type. Later, we will probably need to extend this struct further. - [x] Add fields for supported devices (e.g. video device), cpu modes, and features (for migration filtering) Capacity filtering: - [x] We need a spec + status not only for the size of the host, but also for the currently used capacity. This will be used by cortex to filter out hosts without the required capacity. This scheduling logic can be made more intelligent in the future, by mapping out individual numa cells and including reserved capacity. Pinned projects: - [x] Provide a spec to declare pinned projects on this hypervisor. (Bonus) - [x] Add numa cell capacity & allocation information so we can implement numa sensitive initial placement When finished: - [x] Ensure backwards compatibility so we can roll this out without any issues ## Dependencies > [!NOTE] > The scope of this PR is to establish a minimum viable scheduling pipeline in cortex, with the least amount of changes possible. Refactorings of the hypervisor crd spec can follow if needed. KVM node agent PR: cobaltcore-dev/kvm-node-agent#40
1 parent 768f631 commit bc1d56d

File tree

11 files changed

+730
-36
lines changed

11 files changed

+730
-36
lines changed

api/v1/hypervisor_types.go

Lines changed: 99 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ type HypervisorSpec struct {
9393
// Aggregates are used to apply aggregates to the hypervisor.
9494
Aggregates []string `json:"aggregates"`
9595

96+
// +kubebuilder:default:={}
97+
// AllowedProjects defines which openstack projects are allowed to schedule
98+
// instances on this hypervisor. The values of this list should be project
99+
// uuids. If left empty, all projects are allowed.
100+
AllowedProjects []string `json:"allowedProjects"`
101+
96102
// +kubebuilder:default:=true
97103
// HighAvailability is used to enable the high availability handling of the hypervisor.
98104
HighAvailability bool `json:"highAvailability"`
@@ -190,8 +196,8 @@ type OperatingSystemStatus struct {
190196
GardenLinuxFeatures []string `json:"gardenLinuxFeatures,omitempty"`
191197
}
192198

193-
// Current capabilities reported by libvirt.
194-
type CapabilitiesStatus struct {
199+
// Capabilities of the hypervisor as reported by libvirt.
200+
type Capabilities struct {
195201
// +kubebuilder:default:=unknown
196202
// The hosts CPU architecture (not the guests).
197203
HostCpuArch string `json:"cpuArch,omitempty"`
@@ -201,6 +207,77 @@ type CapabilitiesStatus struct {
201207
HostCpus resource.Quantity `json:"cpus,omitempty"`
202208
}
203209

210+
// Domain capabilities of the hypervisor as reported by libvirt.
211+
// These details are relevant to check if a VM can be scheduled on the hypervisor.
212+
type DomainCapabilities struct {
213+
// The available domain cpu architecture.
214+
// +kubebuilder:default:=unknown
215+
Arch string `json:"arch,omitempty"`
216+
217+
// The supported type of virtualization for domains, such as "ch".
218+
// +kubebuilder:default:=unknown
219+
HypervisorType string `json:"hypervisorType,omitempty"`
220+
221+
// Supported devices for domains.
222+
//
223+
// The format of this list is the device type, and if specified, a specific
224+
// model. For example, the take the following xml domain device definition:
225+
//
226+
// <video supported='yes'>
227+
// <enum name='modelType'>
228+
// <value>nvidia</value>
229+
// </enum>
230+
// </video>
231+
//
232+
// The corresponding entries in this list would be "video" and "video/nvidia".
233+
//
234+
// +kubebuilder:default:={}
235+
SupportedDevices []string `json:"supportedDevices,omitempty"`
236+
237+
// Supported cpu modes for domains.
238+
//
239+
// The format of this list is cpu mode, and if specified, a specific
240+
// submode. For example, the take the following xml domain cpu definition:
241+
//
242+
// <mode name='host-passthrough' supported='yes'>
243+
// <enum name='hostPassthroughMigratable'/>
244+
// </mode>
245+
//
246+
// The corresponding entries in this list would be "host-passthrough" and
247+
// "host-passthrough/migratable".
248+
//
249+
// +kubebuilder:default:={}
250+
SupportedCpuModes []string `json:"supportedCpuModes,omitempty"`
251+
252+
// Supported features for domains, such as "sev" or "sgx".
253+
//
254+
// This is a flat list of supported features, meaning the following xml:
255+
//
256+
// <features>
257+
// <sev supported='no'/>
258+
// <sgx supported='no'/>
259+
// </features>
260+
//
261+
// Would correspond to the entries "sev" and "sgx" in this list.
262+
//
263+
// +kubebuilder:default:={}
264+
SupportedFeatures []string `json:"supportedFeatures,omitempty"`
265+
}
266+
267+
// Cell represents a NUMA cell on the hypervisor.
268+
type Cell struct {
269+
// Cell ID.
270+
CellID uint64 `json:"cellID"`
271+
272+
// Auto-discovered resource allocation of all hosted VMs in this cell.
273+
// +kubebuilder:validation:Optional
274+
Allocation map[string]resource.Quantity `json:"allocation"`
275+
276+
// Auto-discovered capacity of this cell.
277+
// +kubebuilder:validation:Optional
278+
Capacity map[string]resource.Quantity `json:"capacity"`
279+
}
280+
204281
// HypervisorStatus defines the observed state of Hypervisor
205282
type HypervisorStatus struct {
206283
// +kubebuilder:default:=unknown
@@ -216,8 +293,26 @@ type HypervisorStatus struct {
216293
// Represents the Hypervisor hosted Virtual Machines
217294
Instances []Instance `json:"instances,omitempty"`
218295

219-
// The capabilities of the hypervisors as reported by libvirt.
220-
Capabilities CapabilitiesStatus `json:"capabilities,omitempty"`
296+
// Auto-discovered capabilities as reported by libvirt.
297+
// +kubebuilder:validation:Optional
298+
Capabilities Capabilities `json:"capabilities"`
299+
300+
// Auto-discovered domain capabilities relevant to check if a VM
301+
// can be scheduled on the hypervisor.
302+
// +kubebuilder:validation:Optional
303+
DomainCapabilities DomainCapabilities `json:"domainCapabilities"`
304+
305+
// Auto-discovered resource allocation of all hosted VMs.
306+
// +kubebuilder:validation:Optional
307+
Allocation map[string]resource.Quantity `json:"allocation"`
308+
309+
// Auto-discovered capacity of the hypervisor.
310+
// +kubebuilder:validation:Optional
311+
Capacity map[string]resource.Quantity `json:"capacity"`
312+
313+
// Auto-discovered cells on this hypervisor.
314+
// +kubebuilder:validation:Optional
315+
Cells []Cell `json:"cells,omitempty"`
221316

222317
// +kubebuilder:default:=0
223318
// Represent the num of instances

api/v1/zz_generated.deepcopy.go

Lines changed: 91 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applyconfigurations/api/v1/capabilitiesstatus.go renamed to applyconfigurations/api/v1/capabilities.go

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applyconfigurations/api/v1/cell.go

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)