Documentation
¶
Index ¶
- Constants
- func GlobalRequestIDFromContext(ctx context.Context) string
- func IndexReservationByHost(ctx context.Context, mcl *multicluster.Client) (err error)
- func RequestIDFromContext(ctx context.Context) string
- func WithGlobalRequestID(ctx context.Context, id string) context.Context
- func WithRequestID(ctx context.Context, id string) context.Context
- type ContextKey
- type DBVMSource
- func (s *DBVMSource) GetDeletedVMInfo(ctx context.Context, vmUUID string) (*DeletedVMInfo, error)
- func (s *DBVMSource) GetVM(ctx context.Context, vmUUID string) (*VM, error)
- func (s *DBVMSource) IsServerActive(ctx context.Context, vmUUID string) (bool, error)
- func (s *DBVMSource) ListVMs(ctx context.Context) ([]VM, error)
- func (s *DBVMSource) ListVMsByProject(ctx context.Context, projectID string) ([]VM, error)
- func (s *DBVMSource) ListVMsOnHypervisors(ctx context.Context, hypervisorList *hv1.HypervisorList, ...) ([]VM, error)
- type DeletedVMInfo
- type VM
- type VMSource
Constants ¶
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 ¶
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 ¶
RequestIDFromContext retrieves the request ID from the context. Returns empty string if not set.
func WithGlobalRequestID ¶
WithGlobalRequestID returns a new context with the global request ID set. GlobalRequestID identifies the overall reconciliation context.
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 ¶
GetVM returns a specific VM by UUID. Returns nil, nil if the VM is not found.
func (*DBVMSource) IsServerActive ¶
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 ¶
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.
Directories
¶
| Path | Synopsis |
|---|---|
|
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. |