Skip to content
Draft
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
36 changes: 36 additions & 0 deletions helm/bundles/cortex-nova/templates/pipelines_kvm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -520,4 +520,40 @@ spec:
requested by the nova flavor extra specs, like `{"arch": "x86_64",
"maxphysaddr:bits": 46, ...}`.
weighers: []
---
apiVersion: cortex.cloud/v1alpha1
kind: Pipeline
metadata:
name: kvm-report-capacity
spec:
schedulingDomain: nova
description: |
This pipeline is used by the Liquid capacity reporter to determine the
theoretical maximum capacity of each flavor group per availability zone,
as if all hosts were completely empty. It ignores current VM allocations
and all reservation blockings so that only raw hardware capacity is
considered.
type: filter-weigher
createDecisions: false
# Fetch all placement candidates, ignoring nova's preselection.
ignorePreselection: true
filters:
- name: filter_correct_az
description: |
Restricts host candidates to the requested availability zone.
- name: filter_has_enough_capacity
description: |
Filters hosts that cannot fit the flavor based on raw hardware capacity.
VM allocations and all reservation types are ignored to represent an
empty datacenter scenario.
params:
- {key: ignoreAllocations, boolValue: true}
- {key: ignoredReservationTypes, stringListValue: ["CommittedResourceReservation", "FailoverReservation"]}
- name: filter_has_requested_traits
description: |
Ensures hosts have the hardware traits required by the flavor.
- name: filter_status_conditions
description: |
Excludes hosts that are not ready or are disabled.
weighers: []
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ type FilterHasEnoughCapacityOpts struct {
// When a reservation type is in this list, its capacity is not blocked.
// Default: empty (all reservation types are considered)
IgnoredReservationTypes []v1alpha1.ReservationType `json:"ignoredReservationTypes,omitempty"`

// IgnoreAllocations skips subtracting current VM allocations from host capacity.
// When true, only raw hardware capacity is considered (empty datacenter scenario).
IgnoreAllocations bool `json:"ignoreAllocations,omitempty"`
}

func (FilterHasEnoughCapacityOpts) Validate() error { return nil }
Expand Down Expand Up @@ -71,18 +75,20 @@ func (s *FilterHasEnoughCapacity) Run(traceLog *slog.Logger, request api.Externa
freeResourcesByHost[hv.Name] = hv.Status.EffectiveCapacity
}

// Subtract allocated resources.
for resourceName, allocated := range hv.Status.Allocation {
free, ok := freeResourcesByHost[hv.Name][resourceName]
if !ok {
traceLog.Error(
"hypervisor with allocation for unknown resource",
"host", hv.Name, "resource", resourceName,
)
continue
// Subtract allocated resources (skip when ignoring allocations for empty-datacenter capacity queries).
if !s.Options.IgnoreAllocations {
for resourceName, allocated := range hv.Status.Allocation {
free, ok := freeResourcesByHost[hv.Name][resourceName]
if !ok {
traceLog.Error(
"hypervisor with allocation for unknown resource",
"host", hv.Name, "resource", resourceName,
)
continue
}
free.Sub(allocated)
freeResourcesByHost[hv.Name][resourceName] = free
}
free.Sub(allocated)
freeResourcesByHost[hv.Name][resourceName] = free
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/scheduling/reservations/commitments/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewAPIWithConfig(client client.Client, config Config) *HTTPAPI {

func (api *HTTPAPI) Init(mux *http.ServeMux) {
mux.HandleFunc("/v1/commitments/change-commitments", api.HandleChangeCommitments)
// mux.HandleFunc("/v1/report-capacity", api.HandleReportCapacity)
mux.HandleFunc("/v1/report-capacity", api.HandleReportCapacity)
mux.HandleFunc("/v1/commitments/info", api.HandleInfo)
}

Expand Down
Loading
Loading