reservations

package
v0.0.0-...-ccb81e8 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const IdxReservationByHost = "reservations.host"

IdxReservationByHost is the field index key for looking up Reservations by host. Both Spec.TargetHost and Status.Host are indexed so reservations in transit (TargetHost != Status.Host) are found via either field. All reservation types are included.

Variables

This section is empty.

Functions

func GlobalRequestIDFromContext

func GlobalRequestIDFromContext(ctx context.Context) string

GlobalRequestIDFromContext retrieves the global request ID from the context. Returns empty string if not set.

func IndexReservationByHost

func IndexReservationByHost(ctx context.Context, mcl *multicluster.Client) (err error)

IndexReservationByHost registers the shared host index on the multicluster client. Safe to call multiple times — registration happens only once.

func RequestIDFromContext

func RequestIDFromContext(ctx context.Context) string

RequestIDFromContext retrieves the request ID from the context. Returns empty string if not set.

func WithGlobalRequestID

func WithGlobalRequestID(ctx context.Context, id string) context.Context

WithGlobalRequestID returns a new context with the global request ID set. GlobalRequestID identifies the overall reconciliation context.

func WithRequestID

func WithRequestID(ctx context.Context, id string) context.Context

WithRequestID returns a new context with the request ID set. RequestID identifies the specific item being processed (typically VM UUID).

Types

type ContextKey

type ContextKey string

ContextKey is the type for context keys used in request tracking.

const (
	// GlobalRequestIDKey is the context key for the global request ID.
	GlobalRequestIDKey ContextKey = "globalRequestID"
	// RequestIDKey is the context key for the request ID.
	RequestIDKey ContextKey = "requestID"
)

type DBVMSource

type DBVMSource struct {
	NovaReader external.NovaReaderInterface
}

DBVMSource implements VMSource by reading directly from the database. This is the preferred implementation as it avoids the size limitations of Knowledge CRDs.

func NewDBVMSource

func NewDBVMSource(novaReader external.NovaReaderInterface) *DBVMSource

NewDBVMSource creates a new DBVMSource.

func (*DBVMSource) GetDeletedVMInfo

func (s *DBVMSource) GetDeletedVMInfo(ctx context.Context, vmUUID string) (*DeletedVMInfo, error)

GetDeletedVMInfo returns metadata about a deleted VM from the deleted_servers table.

func (*DBVMSource) GetVM

func (s *DBVMSource) GetVM(ctx context.Context, vmUUID string) (*VM, error)

GetVM returns a specific VM by UUID. Returns nil, nil if the VM is not found.

func (*DBVMSource) IsServerActive

func (s *DBVMSource) IsServerActive(ctx context.Context, vmUUID string) (bool, error)

IsServerActive returns true if the server exists in the servers table and is not DELETED.

func (*DBVMSource) ListVMs

func (s *DBVMSource) ListVMs(ctx context.Context) ([]VM, error)

ListVMs returns all VMs across all projects by joining server and flavor data.

func (*DBVMSource) ListVMsByProject

func (s *DBVMSource) ListVMsByProject(ctx context.Context, projectID string) ([]VM, error)

ListVMsByProject returns all VMs for a specific project, querying only that project's servers.

func (*DBVMSource) ListVMsOnHypervisors

func (s *DBVMSource) ListVMsOnHypervisors(
	ctx context.Context,
	hypervisorList *hv1.HypervisorList,
	trustHypervisorLocation bool,
) ([]VM, error)

ListVMsOnHypervisors returns VMs that are on the given hypervisors.

type DeletedVMInfo

type DeletedVMInfo struct {
	ProjectID        string
	AvailabilityZone string
	FlavorName       string
	RAMMiB           uint64
	VCPUs            uint64
}

DeletedVMInfo contains the metadata needed to compute resource decrements for a deleted VM.

type VM

type VM struct {
	// UUID is the unique identifier of the VM.
	UUID string
	// Name is the display name of the VM in Nova.
	Name string
	// Status is the Nova status of the VM (e.g. ACTIVE, SHUTOFF).
	Status string
	// FlavorName is the name of the flavor used by the VM.
	FlavorName string
	// ProjectID is the OpenStack project ID that owns the VM.
	ProjectID string
	// DomainName is the OpenStack domain name that owns the VM, resolved from the
	// VM's project. Used by domain-based scheduling filters (external customer
	// isolation and domain pinning) when creating/validating failover reservations.
	// Empty if the domain could not be resolved.
	DomainName string
	// CurrentHypervisor is the hypervisor where the VM is currently running.
	CurrentHypervisor string
	// AvailabilityZone is the availability zone where the VM is located.
	// This is used to ensure failover reservations are created in the same AZ.
	AvailabilityZone string
	// CreatedAt is the ISO 8601 timestamp when the VM was created in Nova.
	// Used by the quota controller to distinguish new VMs from migrations.
	CreatedAt string
	// Resources contains the VM's resource allocations (e.g., "memory", "cpu").
	Resources map[string]resource.Quantity
	// FlavorExtraSpecs contains the flavor's extra specifications (e.g., traits, capabilities).
	// This is used by filters like filter_has_requested_traits and filter_capabilities.
	FlavorExtraSpecs map[string]string
	// DiskGB is the flavor's root disk size in GiB.
	DiskGB uint64
	// OSType is the operating system type pre-computed from Glance image properties.
	// "unknown" when not found or for volume-booted instances.
	OSType string
}

VM represents a virtual machine managed by the reservation system.

type VMSource

type VMSource interface {
	// ListVMs returns all VMs across all projects.
	ListVMs(ctx context.Context) ([]VM, error)
	// ListVMsByProject returns all VMs belonging to a specific project.
	ListVMsByProject(ctx context.Context, projectID string) ([]VM, error)
	// ListVMsOnHypervisors returns VMs that are on the given hypervisors.
	// If trustHypervisorLocation is true, uses hypervisor CRD as source of truth for VM location.
	// If trustHypervisorLocation is false, uses postgres as source of truth but filters to VMs on known hypervisors.
	ListVMsOnHypervisors(ctx context.Context, hypervisorList *hv1.HypervisorList, trustHypervisorLocation bool) ([]VM, error)
	// GetVM returns a specific VM by UUID.
	// Returns nil, nil if the VM is not found.
	GetVM(ctx context.Context, vmUUID string) (*VM, error)
	// IsServerActive returns true if the server exists in the servers table and is not DELETED.
	// Returns false if not found. Used by quota controller to determine if a removed HV instance was deleted vs migrated.
	IsServerActive(ctx context.Context, vmUUID string) (bool, error)
	// GetDeletedVMInfo returns metadata about a deleted VM (from deleted_servers table),
	// including resolved flavor resources. Returns nil, nil if not found.
	GetDeletedVMInfo(ctx context.Context, vmUUID string) (*DeletedVMInfo, error)
}

VMSource provides VMs managed by the reservation system. This interface allows swapping the implementation when a VM CRD arrives.

func NewPostgresVMSource

func NewPostgresVMSource(k8sClient client.Client, datasourceName string) VMSource

NewPostgresVMSource creates a VMSource backed by the named Datasource CRD. The Postgres connection is established on first use, so this is safe to call before the manager cache is ready.

Directories

Path Synopsis
api
Package failoverhost keeps a fleet of OpenStack Nova compute hosts ready to absorb the workload of a failed host.
Package failoverhost keeps a fleet of OpenStack Nova compute hosts ready to absorb the workload of a failed host.

Jump to

Keyboard shortcuts

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