nova

package
v0.0.0-...-72f05a7 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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(ff FullFlavor, reason string, coresOvercommitFactor core.OvercommitFactor, blockedCapacity BinpackVector[uint64]) (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(ff FullFlavor, reason string, coresOvercommitFactor core.OvercommitFactor, blockedCapacity BinpackVector[uint64], 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]) 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 FlavorNameSelection

type FlavorNameSelection []FlavorNameSelectionRule

FlavorNameSelection describes a selection of flavors exclusively by name. If the entire flavor is available, type FlavorSelection is used to match a selection thereof.

This selection method is used for flavor names returned by ListFlavorsWithSeparateInstanceQuota.

func (FlavorNameSelection) MatchFlavorName

func (s FlavorNameSelection) MatchFlavorName(flavorName string) (category string)

MatchFlavorName returns the category into which this flavor shall be grouped, or an empty string if the flavor shall be ignored.

type FlavorNameSelectionRule

type FlavorNameSelectionRule struct {
	NamePattern  regexpext.PlainRegexp `yaml:"name_pattern"`
	CategoryName string                `yaml:"category"`
}

FlavorNameSelectionRule appears in type FlavorNameSelection.

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(novaV2 *gophercloud.ServiceClient, action func(FullFlavor) error) error

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

type FlavorTranslationEntry

type FlavorTranslationEntry struct {
	// All possible names for this flavor, including the preferred names that have
	// their separate fields below.
	Aliases []string
	// The name that Limes prefers for this flavor. The resource name for a
	// separate instance quota is derived from this name, if needed. Also, this
	// name is what we show on instance subresources.
	LimesPreferredName string
	// The name that Nova prefers for this flavor, or an empty string if we don't
	// know yet which name Nova prefers. This is the name that gets used in API
	// calls to get or set separate instance quotas.
	NovaPreferredName string
}

FlavorTranslationEntry is an entry for one particular flavor in type FlavorTranslationTable.

type FlavorTranslationTable

type FlavorTranslationTable struct {
	Entries []*FlavorTranslationEntry
}

FlavorTranslationTable is used in situations where certain flavors can have more than one name in Nova, to translate between the names preferred by Nova and those preferred by Limes.

func NewFlavorTranslationTable

func NewFlavorTranslationTable(flavorAliases map[string][]string) FlavorTranslationTable

NewFlavorTranslationTable builds a FlavorTranslationEntry from the format found within plugin configuration.

func (FlavorTranslationTable) LimesResourceNameForFlavor

func (t FlavorTranslationTable) LimesResourceNameForFlavor(flavorName string) limesresources.ResourceName

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

func (FlavorTranslationTable) ListFlavorsWithSeparateInstanceQuota

func (t FlavorTranslationTable) ListFlavorsWithSeparateInstanceQuota(computeV2 *gophercloud.ServiceClient) ([]string, error)

ListFlavorsWithSeparateInstanceQuota queries Nova for all separate instance quotas, and returns the flavor names that Nova prefers for each.

func (FlavorTranslationTable) NovaQuotaNameForLimesResourceName

func (t FlavorTranslationTable) NovaQuotaNameForLimesResourceName(resourceName limesresources.ResourceName) string

NovaQuotaNameForLimesResourceName returns the Nova quota name for the given Limes resource name, or "" if the given resource name does not refer to a separate instance quota.

func (*FlavorTranslationTable) UnmarshalYAML

func (t *FlavorTranslationTable) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type FullFlavor

type FullFlavor struct {
	Flavor     flavors.Flavor
	ExtraSpecs map[string]string
}

FullFlavor is a flavor plus its set of extra specs.

func (FullFlavor) MatchesHypervisor

func (f FullFlavor) MatchesHypervisor(mh MatchingHypervisor) bool

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

type Hypervisor

type Hypervisor struct {
	ID                 int    `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(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 HypervisorTypeRule

type HypervisorTypeRule struct {
	Key            string                `yaml:"match"`
	Pattern        regexpext.PlainRegexp `yaml:"pattern"`
	HypervisorType string                `yaml:"type"`
}

HypervisorTypeRule is a single entry in type HypervisorTypeRules.

type HypervisorTypeRules

type HypervisorTypeRules []HypervisorTypeRule

HypervisorTypeRules is a set of rules that allows to compute the HypervisorType attribute of a Nova instance subresource from its FlavorInfo.

func (HypervisorTypeRules) Evaluate

func (rules HypervisorTypeRules) Evaluate(flavor FlavorInfo) string

Evaluate returns the HypervisorType string for the given instance flavor.

func (HypervisorTypeRules) Validate

func (rules HypervisorTypeRules) Validate() error

Validate returns an error if this rule is not valid.

type Instance

Instance is a Nova instance as shown on the Nova API. This includes some API extensions that we need.

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(instance Instance) 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) 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.

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(projectID string) (uint64, error)

GetMemberUsageForProject returns server_group_members usage in the given project.

Jump to

Keyboard shortcuts

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