Skip to content
Merged
Show file tree
Hide file tree
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: 5 additions & 3 deletions helm/bundles/cortex-nova/templates/knowledges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,17 @@ spec:
apiVersion: cortex.cloud/v1alpha1
kind: Knowledge
metadata:
name: host-details
name: vmware-host-details
spec:
schedulingDomain: nova
extractor:
name: sap_host_details_extractor
name: vmware_host_details_extractor
description: |
This knowledge extracts SAP-specific host details information.
This knowledge extracts details of VMware compute hosts. KVM hosts are
served by a dedicated CRD and ironic hosts are excluded.
recency: "60s"
dependencies:
datasources:
- name: placement-resource-provider-traits
- name: placement-resource-provider-inventory-usages
- name: nova-hypervisors
4 changes: 2 additions & 2 deletions helm/bundles/cortex-nova/templates/kpis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ spec:
- name: identity-projects
- name: identity-domains
knowledges:
- name: host-details
- name: vmware-host-details
description: |
This KPI tracks the resource utilization of projects running VMs on VMware hosts.
---
Expand Down Expand Up @@ -203,7 +203,7 @@ spec:
impl: vmware_host_capacity_kpi
dependencies:
knowledges:
- name: host-details
- name: vmware-host-details
- name: host-utilization
description: |
This KPI tracks the capacity and utilization of VMware hosts in terms of CPU, RAM, and disk resources.
1 change: 0 additions & 1 deletion helm/bundles/cortex-nova/templates/kpis_kvm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ spec:
impl: kvm_host_capacity_kpi
dependencies:
knowledges:
- name: host-details
- name: host-utilization
description: |
This KPI tracks the total, utilized, reserved and failover capacity of KVM hosts.
Expand Down
2 changes: 1 addition & 1 deletion internal/knowledge/extractor/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ func TestKnowledgeReconciler_Reconcile_SupportedExtractors(t *testing.T) {
"vm_life_span_histogram_extractor",
"host_az_extractor",
"host_pinned_projects_extractor",
"sap_host_details_extractor",
"vmware_host_details_extractor",
}

for _, extractorName := range supportedExtractors {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

type HostDetails struct {
// VMwareHostDetails describes a single VMware compute host. Only VMware hosts
// are extracted here (KVM hosts are served by a dedicated CRD, and ironic hosts
// are excluded); the extractor SQL filters everything else out.
type VMwareHostDetails struct {
// Name of the OpenStack compute host.
ComputeHost string `db:"compute_host"`
// Availability zone of the compute host.
AvailabilityZone string `db:"availability_zone"`
// CPU Architecture of the compute host.
// Can be "cascade-lake" or "sapphire-rapids"
CPUArchitecture string `db:"cpu_architecture"`
// Hypervisor type of the compute host.
HypervisorType string `db:"hypervisor_type"`
// Hypervisor family of the compute host.
// Can be "kvm" or "vmware"
HypervisorFamily string `db:"hypervisor_family"`
// Amount of VMs currently running on the compute host.
RunningVMs int `db:"running_vms"`
// Type of workload running on the compute host.
Expand All @@ -45,28 +43,28 @@ type HostDetails struct {
// Physical size category of a single host inside a VMware building block,
// derived from the memory inventory and rounded to the nearest TiB
// (e.g. "4TiB"), or to the nearest GiB (e.g. "512GiB") when smaller than
// 1 TiB. Only meaningful for VMware hosts; "unknown" otherwise.
// 1 TiB. "unknown" when the memory inventory is missing.
PhysicalHostSize string `db:"physical_host_size"`
}

type HostDetailsExtractor struct {
type VMwareHostDetailsExtractor struct {
// Common base for all extractors that provides standard functionality.
plugins.BaseExtractor[
struct{}, // No options passed through yaml config
HostDetails, // Feature model
struct{}, // No options passed through yaml config
VMwareHostDetails, // Feature model
]
}

//go:embed host_details.sql
var hostDetailsQuery string
//go:embed vmware_host_details.sql
var vmwareHostDetailsQuery string

// Extract the traits of a compute host from the database.
func (e *HostDetailsExtractor) Extract() ([]plugins.Feature, error) {
// Extract the details of the VMware compute hosts from the database.
func (e *VMwareHostDetailsExtractor) Extract() ([]plugins.Feature, error) {
if e.DB == nil {
return nil, errors.New("database connection is not initialized")
}
var hostDetails []HostDetails
if _, err := e.DB.Select(&hostDetails, hostDetailsQuery); err != nil {
var hostDetails []VMwareHostDetails
if _, err := e.DB.Select(&hostDetails, vmwareHostDetailsQuery); err != nil {
return nil, err
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
-- Details of VMware compute hosts. Only VMware hosts are considered here: KVM
-- hosts are served by a dedicated CRD, and ironic hosts are excluded. The
-- WHERE clause keeps rows whose service host matches the VMware naming
-- convention (nova-compute-%) while dropping ironic ones (nova-compute-ironic-%).
WITH host_traits AS (
SELECT
h.id AS hypervisor_id,
h.service_host,
h.hypervisor_type,
h.running_vms,
h.state,
h.status,
Expand All @@ -11,7 +14,9 @@ WITH host_traits AS (
FROM openstack_hypervisors h
LEFT JOIN openstack_resource_provider_traits t
ON h.id = t.resource_provider_uuid
GROUP BY h.id, h.service_host, h.hypervisor_type, h.running_vms, h.state, h.status, h.service_disabled_reason
WHERE h.service_host LIKE 'nova-compute-%'
AND h.service_host NOT LIKE 'nova-compute-ironic-%'
GROUP BY h.id, h.service_host, h.running_vms, h.state, h.status, h.service_disabled_reason
),
-- Physical memory size (in MiB) of a single host inside a VMware building block.
-- A building block pools multiple physical hosts into one resource provider, so
Expand All @@ -37,12 +42,6 @@ SELECT
WHEN ht.traits LIKE '%CUSTOM_HW_SAPPHIRE_RAPIDS%' THEN 'sapphire-rapids'
ELSE 'cascade-lake'
END AS cpu_architecture,
ht.hypervisor_type,
CASE
WHEN ht.service_host LIKE 'nova-compute-%' THEN 'vmware'
WHEN ht.service_host LIKE 'node%-bb%' THEN 'kvm'
ELSE 'unknown'
END AS hypervisor_family,
CASE
WHEN ht.traits LIKE '%CUSTOM_HANA_EXCLUSIVE_HOST%' THEN 'hana'
ELSE 'general-purpose'
Expand All @@ -67,10 +66,11 @@ SELECT
WHEN ht.state != 'up' THEN '[down] ' || COALESCE(ht.service_disabled_reason, '--')
ELSE NULL
END AS disabled_reason,
-- Physical host size category. The size is first rounded to whole GiB; if
-- that is at least 1024 GiB it is reported in TiB ("<n>TiB"), otherwise in
-- GiB ("<n>GiB"). Rounding to GiB first avoids a value like 1023.6 GiB being
-- shown as "1024GiB" instead of "1TiB".
-- Physical host size category of a single host inside the building block.
-- The size is first rounded to whole GiB; if that is at least 1024 GiB it is
-- reported in TiB, otherwise in GiB. Rounding to GiB
-- first avoids a value like 1023.6 GiB being shown as "1024GiB" instead of
-- "1TiB". "unknown" when the memory inventory is missing.
CASE
WHEN hpm.physical_size_mb IS NULL THEN 'unknown'
WHEN ROUND(hpm.physical_size_mb / 1024.0) >= 1024
Expand All @@ -79,4 +79,4 @@ SELECT
END AS physical_host_size
FROM host_traits ht
LEFT JOIN host_physical_memory hpm
ON ht.hypervisor_id = hpm.resource_provider_uuid;
ON ht.hypervisor_id = hpm.resource_provider_uuid;
Loading