nova

package
v0.0.0-...-d0650ca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlavorMatchesHypervisor

func FlavorMatchesHypervisor(f flavors.Flavor, mh MatchingHypervisor) bool

FlavorMatchesHypervisor returns true if instances of this flavor can be placed on the given hypervisor.

func IsIronicFlavor

func IsIronicFlavor(f flavors.Flavor) bool

IsIronicFlavor returns whether the given flavor belongs to Ironic and should be ignored by the Nova plugins.

func IsSplitFlavor

func IsSplitFlavor(f flavors.Flavor) bool

IsSplitFlavor returns whether the given flavor has separate instance quota.

func ResourceNameForFlavor

func ResourceNameForFlavor(flavorName string) liquid.ResourceName

ResourceNameForFlavor returns the resource name for a flavor with separate instance quota.

Types

type BinpackBehavior

type BinpackBehavior struct {
	// When ranking nodes during placement, do not include the VCPU count dimension in the score.
	ScoreIgnoresCores bool `yaml:"score_ignores_cores"`
	// When ranking nodes during placement, do not include the disk size dimension in the score.
	ScoreIgnoresDisk bool `yaml:"score_ignores_disk"`
	// When ranking nodes during placement, do not include the RAM size dimension in the score.
	ScoreIgnoresRAM bool `yaml:"score_ignores_ram"`
}

BinpackBehavior contains configuration parameters for the binpack simulation.

type BinpackHypervisor

type BinpackHypervisor struct {
	Match MatchingHypervisor
	Nodes []*BinpackNode
}

BinpackHypervisor models an entire Nova hypervisor for the purposes of the binpacking simulation.

We assume the Nova hypervisor to be an entire cluster of physical nodes. We cannot see the sizes of the individual nodes in that cluster, only the total capacity and the MaxUnit value on the inventories. We have to make the assumption that the individual nodes are of identical size.

func PrepareHypervisorForBinpacking

func PrepareHypervisorForBinpacking(h MatchingHypervisor) (BinpackHypervisor, error)

PrepareHypervisorForBinpacking converts a MatchingHypervisor into a BinpackHypervisor.

func (BinpackHypervisor) RenderDebugView

func (h BinpackHypervisor) RenderDebugView(az limes.AvailabilityZone)

RenderDebugView prints an overview of the placements in this hypervisor on several logg.Debug lines.

type BinpackHypervisors

type BinpackHypervisors []BinpackHypervisor

BinpackHypervisors adds methods to type []BinpackHypervisor.

func (BinpackHypervisors) PlaceOneInstance

func (hh BinpackHypervisors) PlaceOneInstance(flavor flavors.Flavor, reason string, coresOvercommitFactor liquid.OvercommitFactor, blockedCapacity BinpackVector[uint64], bb BinpackBehavior) (ok bool)

PlaceOneInstance places a single instance of the given flavor using the vector-dot binpacking algorithm. If the instance cannot be placed, false is returned.

func (BinpackHypervisors) PlaceSeveralInstances

func (hh BinpackHypervisors) PlaceSeveralInstances(f flavors.Flavor, reason string, coresOvercommitFactor liquid.OvercommitFactor, blockedCapacity BinpackVector[uint64], bb BinpackBehavior, count uint64) (ok bool)

PlaceSeveralInstances calls PlaceOneInstance multiple times.

func (BinpackHypervisors) PlacementCountForFlavor

func (hh BinpackHypervisors) PlacementCountForFlavor(flavorName string) uint64

PlacementCountForFlavor returns how many instances have been placed for the given flavor name.

func (BinpackHypervisors) TotalCapacity

func (hh BinpackHypervisors) TotalCapacity() (result BinpackVector[uint64])

TotalCapacity returns the sum of capacity over all hypervisor nodes.

type BinpackInstance

type BinpackInstance struct {
	FlavorName string
	Size       BinpackVector[uint64]
	Reason     string // one of "used", "committed", "pending", "padding" (in descending priority), only for debug logging
}

BinpackInstance appears in type BinpackNode. It describes a single instance that has been placed on the node as part of the binpacking simulation.

type BinpackNode

type BinpackNode struct {
	Capacity  BinpackVector[uint64]
	Instances []BinpackInstance
}

BinpackNode appears in type BinpackHypervisor.

type BinpackVector

type BinpackVector[T float64 | uint64] struct {
	VCPUs    T `json:"vcpus"`
	MemoryMB T `json:"memory_mib"`
	LocalGB  T `json:"local_disk_gib"`
}

func (BinpackVector[T]) Add

func (v BinpackVector[T]) Add(other BinpackVector[T]) BinpackVector[T]

func (BinpackVector[T]) AsFloat

func (v BinpackVector[T]) AsFloat() BinpackVector[float64]

func (BinpackVector[T]) AsUint

func (v BinpackVector[T]) AsUint() BinpackVector[uint64]

func (BinpackVector[T]) Div

func (v BinpackVector[T]) Div(other BinpackVector[T]) BinpackVector[float64]

func (BinpackVector[T]) Dot

func (v BinpackVector[T]) Dot(other BinpackVector[T], bb BinpackBehavior) T

func (BinpackVector[T]) FitsIn

func (v BinpackVector[T]) FitsIn(other BinpackVector[T]) bool

func (BinpackVector[T]) IsAnyZero

func (v BinpackVector[T]) IsAnyZero() bool

func (BinpackVector[T]) Mul

func (v BinpackVector[T]) Mul(other BinpackVector[T]) BinpackVector[float64]

func (BinpackVector[T]) SaturatingSub

func (v BinpackVector[T]) SaturatingSub(other BinpackVector[T]) BinpackVector[T]

Like Sub, but never goes below zero.

func (BinpackVector[T]) String

func (v BinpackVector[T]) String() string

type FlavorInfo

type FlavorInfo struct {
	DiskGiB      uint64            `json:"disk"`
	EphemeralGiB uint64            `json:"ephemeral"`
	ExtraSpecs   map[string]string `json:"extra_specs"`
	OriginalName string            `json:"original_name"`
	MemoryMiB    uint64            `json:"ram"`
	SwapMiB      uint64            `json:"swap"`
	VCPUs        uint64            `json:"vcpus"`
}

FlavorInfo contains information about a flavor, in the format that appears in Nova's GET /servers/:id in the "flavor" key with newer Nova microversions.

type FlavorSelection

type FlavorSelection struct {
	// Only match flavors that have all of these extra specs.
	RequiredExtraSpecs map[string]string `yaml:"required_extra_specs"`
	// Exclude flavors that have any of these extra specs.
	ExcludedExtraSpecs map[string]string `yaml:"excluded_extra_specs"`
}

FlavorSelection describes a set of public flavors.

This is used for matching flavors that we enumerate via the flavor API itself (so we know things like extra specs). For matching flavors just by name, type FlavorNameSelection is used.

func (FlavorSelection) ForeachFlavor

func (s FlavorSelection) ForeachFlavor(ctx context.Context, novaV2 *gophercloud.ServiceClient, action func(flavors.Flavor) error) error

ForeachFlavor lists all public flavors matching this FlavorSelection, and calls the given callback once for each of them.

type Hypervisor

type Hypervisor struct {
	ID                 string `json:"id"`
	HypervisorHostname string `json:"hypervisor_hostname"`
	HypervisorType     string `json:"hypervisor_type"`
	// LocalGB            uint64              `json:"local_gb"`
	// MemoryMB           uint64              `json:"memory_mb"`
	// MemoryMBUsed       uint64              `json:"memory_mb_used"`
	RunningVMs uint64              `json:"running_vms"`
	Service    hypervisors.Service `json:"service"`
}

Hypervisor represents a Nova hypervisor as returned by the Nova API.

We are not using the hypervisors.Hypervisor type provided by Gophercloud. In our clusters, that type breaks because some hypervisors report unexpected NULL values on fields that we are not even interested in.

func (Hypervisor) Description

func (h Hypervisor) Description() string

Description returns a string that identifies this hypervisor in log messages.

type HypervisorSelection

type HypervisorSelection struct {
	// Only match hypervisors with a hypervisor_type attribute matching this pattern.
	HypervisorTypeRx regexpext.PlainRegexp `yaml:"hypervisor_type_pattern"`
	// Only match hypervisors that have any of these traits.
	// Trait names can include a `!` prefix to invert the match.
	RequiredTraits []string `yaml:"required_traits"`
	// Set the MatchingHypervisor.ShadowedByTrait field on hypervisors that have any of these traits.
	// Trait names can include a `!` prefix to invert the match.
	ShadowingTraits []string `yaml:"shadowing_traits"`
	// Only match hypervisors that reside in an aggregate matching this pattern.
	// If a hypervisor resides in multiple matching aggregates, an error is raised.
	AggregateNameRx regexpext.PlainRegexp `yaml:"aggregate_name_pattern"`
}

HypervisorSelection describes a set of hypervisors.

func (HypervisorSelection) ForeachHypervisor

func (s HypervisorSelection) ForeachHypervisor(ctx context.Context, novaV2, placementV1 *gophercloud.ServiceClient, action func(MatchingHypervisor) error) error

ForeachHypervisor lists all Nova hypervisors matching this HypervisorSelection, and calls the given callback once for each of them.

type MatchingHypervisor

type MatchingHypervisor struct {
	// information from Nova
	Hypervisor       Hypervisor
	AggregateName    string
	AvailabilityZone limes.AvailabilityZone
	// information from Placement
	Traits      []string
	Inventories map[string]resourceproviders.Inventory
	Usages      map[string]int
	// information from HypervisorSelection
	ShadowedByTrait string // empty if not shadowed
}

MatchingHypervisor is the callback argument for func HypervisorSelection.ForeachHypervisor().

func (MatchingHypervisor) CheckTopology

func (h MatchingHypervisor) CheckTopology() bool

CheckTopology logs an error and returns false if the hypervisor is not associated with an aggregate and AZ.

This is not a fatal error: During buildup, new hypervisors may not be mapped to an aggregate to prevent scheduling of instances onto them - we just log an error and ignore this hypervisor's capacity.

func (MatchingHypervisor) PartialCapacity

func (h MatchingHypervisor) PartialCapacity() PartialCapacity

PartialCapacity formats this hypervisor's capacity.

type OSTypeProber

type OSTypeProber struct {
	// caches
	CacheByImage    map[string]string // for instances booted from images
	CacheByInstance map[string]string // for instances booted from volumes
	// connections
	NovaV2   *gophercloud.ServiceClient
	CinderV3 *gophercloud.ServiceClient
	GlanceV2 *gophercloud.ServiceClient
}

OSTypeProber contains the logic for filling the OSType attribute of a Nova instance subresource.

func NewOSTypeProber

func NewOSTypeProber(novaV2, cinderV3, glanceV2 *gophercloud.ServiceClient) *OSTypeProber

NewOSTypeProber builds an OSTypeProber.

func (*OSTypeProber) Get

func (p *OSTypeProber) Get(ctx context.Context, instance servers.Server) string

type PartialCapacity

type PartialCapacity struct {
	VCPUs              PartialCapacityMetric
	MemoryMB           PartialCapacityMetric
	LocalGB            PartialCapacityMetric
	RunningVMs         uint64
	MatchingAggregates map[string]bool
	Subcapacities      []any // only filled on AZ level
}

PartialCapacity describes compute capacity at a level below the entire cluster (e.g. for a single hypervisor, aggregate or AZ).

func (*PartialCapacity) Add

func (c *PartialCapacity) Add(other PartialCapacity)

func (PartialCapacity) CappedToUsage

func (c PartialCapacity) CappedToUsage() PartialCapacity

func (PartialCapacity) IntoCapacityData

func (c PartialCapacity) IntoCapacityData(resourceName string, maxRootDiskSize float64, subcapacities []any) core.CapacityData

type PartialCapacityMetric

type PartialCapacityMetric struct {
	Capacity uint64
	Usage    uint64
}

PartialCapacityMetric appears in type PartialCapacity.

func (PartialCapacityMetric) CappedToUsage

func (m PartialCapacityMetric) CappedToUsage() PartialCapacityMetric

type PooledSubcapacityBuilder

type PooledSubcapacityBuilder struct {
	// These are actually []Subcapacity, but we store them as []any because
	// that's what goes into type core.CapacityData in the end.
	CoresSubcapacities     []any
	InstancesSubcapacities []any
	RAMSubcapacities       []any
}

PooledSubcapacityBuilder is used to build subcapacity lists for pooled resources.

func (*PooledSubcapacityBuilder) AddHypervisor

func (b *PooledSubcapacityBuilder) AddHypervisor(h MatchingHypervisor, maxRootDiskSize float64)

type ServerGroupProber

type ServerGroupProber struct {
	// contains filtered or unexported fields
}

ServerGroupProber measures server_group_members usage within a project.

The reason why this type exists at all is that: a) Nova does not report the usage for server_group_members directly, and b) we cannot ask for server groups in a specific foreign project.

We can only list *all* server groups globally at once. Since this is very expensive, we only do it once every few minutes.

func NewServerGroupProber

func NewServerGroupProber(novaV2 *gophercloud.ServiceClient) *ServerGroupProber

NewServerGroupProber builds a ServerGroupProber instance.

func (*ServerGroupProber) GetMemberUsageForProject

func (p *ServerGroupProber) GetMemberUsageForProject(ctx context.Context, projectID string) (uint64, error)

GetMemberUsageForProject returns server_group_members usage in the given project.

type SplitFlavorSubcapacityBuilder

type SplitFlavorSubcapacityBuilder struct {
	Subcapacities []any
}

PooledSubcapacityBuilder is used to build subcapacity lists for split flavors. These subcapacities are reported on the first flavor in alphabetic order.

func (*SplitFlavorSubcapacityBuilder) AddHypervisor

type Subcapacity

type Subcapacity struct {
	ServiceHost      string                 `json:"service_host"`
	AvailabilityZone limes.AvailabilityZone `json:"az"`
	AggregateName    string                 `json:"aggregate"`
	Capacity         *uint64                `json:"capacity,omitempty"`
	Usage            *uint64                `json:"usage,omitempty"`
	CapacityVector   *BinpackVector[uint64] `json:"capacity_vector,omitempty"`
	UsageVector      *BinpackVector[uint64] `json:"usage_vector,omitempty"`
	Traits           []string               `json:"traits"`
}

Subcapacity is the structure for subcapacities reported by the "nova" capacity plugin. Each subcapacity refers to a single Nova hypervisor.

This structure can appear on both pooled resources (using the Capacity and Usage fields to report only one dimension at a time), or on split flavors (using the CapacityVector and UsageVector fields to report all dimensions at once).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL