Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,20 @@ func (s *FilterHasEnoughCapacity) Run(traceLog *slog.Logger, request api.Externa
return nil, err
}
for _, hv := range hvs.Items {
var sourceMap map[hv1.ResourceName]resource.Quantity
if hv.Status.EffectiveCapacity == nil {
traceLog.Warn("hypervisor with nil effective capacity, use capacity instead (overprovisioning not considered)", "host", hv.Name)
freeResourcesByHost[hv.Name] = hv.Status.Capacity
sourceMap = hv.Status.Capacity
} else {
// Start with the total effective capacity which is capacity * overcommit ratio.
freeResourcesByHost[hv.Name] = hv.Status.EffectiveCapacity
sourceMap = hv.Status.EffectiveCapacity
}
// Deep-copy the map to avoid mutating the informer cache.
copied := make(map[hv1.ResourceName]resource.Quantity, len(sourceMap))
for k, v := range sourceMap {
copied[k] = v.DeepCopy()
}
freeResourcesByHost[hv.Name] = copied

// Subtract allocated resources (skip when ignoring allocations for empty-datacenter capacity queries).
if !ignoreAllocations {
Expand Down