Documentation
¶
Index ¶
- func CheckDomainNameHintRouting(ctx context.Context, config ChecksConfig)
- func NewPipelineWebhook() lib.PipelineAdmissionWebhook
- func RunChecks(ctx context.Context, client client.Client, config ChecksConfig)
- func ToSchedulerRequest(wire api.ExternalSchedulerRequest, intent v1alpha1.SchedulingIntent, ...) compute.PlacementRequest
- type CandidateGatherer
- type ChecksConfig
- type DeschedulingsCleanup
- type DeschedulingsCleanupOnStartup
- type DeschedulingsExecutor
- type DeschedulingsExecutorConfig
- type DetectorCycleBreaker
- type DetectorPipelineController
- func (c *DetectorPipelineController) CreateDeschedulingsPeriodically(ctx context.Context)
- func (c *DetectorPipelineController) InitPipeline(ctx context.Context, p v1alpha1.Pipeline) lib.PipelineInitResult[*lib.DetectorPipeline[plugins.VMDetection]]
- func (c *DetectorPipelineController) PipelineType() v1alpha1.PipelineType
- func (c *DetectorPipelineController) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
- func (c *DetectorPipelineController) SetupWithManager(mgr ctrl.Manager, mcl *multicluster.Client) error
- type DomainNameHintConfig
- type FailoverHostMatcher
- type FeatureGates
- type FilterWeigherPipelineController
- func (c *FilterWeigherPipelineController) InitPipeline(ctx context.Context, p v1alpha1.Pipeline) lib.PipelineInitResult[lib.FilterWeigherPipeline[compute.PlacementRequest]]
- func (c *FilterWeigherPipelineController) PipelineType() v1alpha1.PipelineType
- func (c *FilterWeigherPipelineController) Reconcile(context.Context, ctrl.Request) (ctrl.Result, error)
- func (c *FilterWeigherPipelineController) SetupWithManager(mgr manager.Manager, mcl *multicluster.Client) error
- type HTTPAPI
- type HTTPAPIConfig
- type HypervisorOvercommitConfig
- type HypervisorOvercommitController
- type HypervisorOvercommitMapping
- type NovaClient
- type NovaClientConfig
- type ServerDetail
- type VirtualMachineHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckDomainNameHintRouting ¶
func CheckDomainNameHintRouting(ctx context.Context, config ChecksConfig)
CheckDomainNameHintRouting sends a synthetic CR reservation scheduling request with _nova_check_type=reserve_for_committed_resource and domain_name=config.DomainName to the nova external scheduler and asserts HTTP 200. Confirms the hint flows through the pipeline and filter_external_customer evaluates it. Inspect the manager logs to see which hosts were kept or dropped.
func NewPipelineWebhook ¶
func NewPipelineWebhook() lib.PipelineAdmissionWebhook
Create a new pipeline admission webhook for the nova scheduling domain, using the known filters, weighers and detectors for validation.
func RunChecks ¶
func RunChecks(ctx context.Context, client client.Client, config ChecksConfig)
Run all checks.
func ToSchedulerRequest ¶
func ToSchedulerRequest( wire api.ExternalSchedulerRequest, intent v1alpha1.SchedulingIntent, pipeline string, ) compute.PlacementRequest
ToSchedulerRequest translates the Nova over-the-wire request into the typed, Nova-agnostic compute.PlacementRequest the pipeline consumes. This is the one place that reads Nova's loosely-typed scheduler hints and flavor/image extra specs; every downstream filter/weigher sees only resolved typed fields.
intent and pipeline are resolved by the caller (the HTTP API layer) and passed in.
Types ¶
type CandidateGatherer ¶
type CandidateGatherer interface {
// Gather all placement candidates and mutate the request accordingly.
MutateWithAllCandidates(ctx context.Context, request *compute.PlacementRequest) error
}
CandidateGatherer is an interface for gathering placement candidates for a given Nova scheduling request.
func NewCandidateGatherer ¶
func NewCandidateGatherer(c client.Client) CandidateGatherer
NewCandidateGatherer builds the default Nova candidate gatherer backed by the given client. It is handed to the compute.Placement, which invokes it when a request opts into gathering all placement candidates.
type ChecksConfig ¶
type ChecksConfig struct {
// Secret ref to keystone credentials stored in a k8s secret.
KeystoneSecretRef corev1.SecretReference `json:"keystoneSecretRef"`
// Secret ref to SSO credentials stored in a k8s secret, if applicable.
SSOSecretRef *corev1.SecretReference `json:"ssoSecretRef"`
// DomainNameHintCheck holds optional configuration for the domain_name hint check.
// When nil the check is skipped. Provide DomainName, EligibleHosts, and FlavorName
// to exercise the filter_external_customer path for CR reservation scheduling.
DomainNameHintCheck *DomainNameHintConfig `json:"domainNameHintCheck,omitempty"`
}
ChecksConfig holds configuration for nova e2e checks.
type DeschedulingsCleanup ¶
type DeschedulingsCleanup struct {
// Client for the kubernetes API.
client.Client
// Kubernetes scheme to use for the deschedulings.
Scheme *runtime.Scheme
}
Removes old deschedulings.
func (*DeschedulingsCleanup) SetupWithManager ¶
func (r *DeschedulingsCleanup) SetupWithManager(mgr ctrl.Manager, mcl *multicluster.Client) error
type DeschedulingsCleanupOnStartup ¶
type DeschedulingsCleanupOnStartup struct{ *DeschedulingsCleanup }
type DeschedulingsExecutor ¶
type DeschedulingsExecutor struct {
// Client for the kubernetes API.
client.Client
// Kubernetes scheme to use for the deschedulings.
Scheme *runtime.Scheme
// Nova client to execute the descheduling operations.
NovaClient NovaClient
// Configuration for the descheduler.
Conf DeschedulingsExecutorConfig
}
func (*DeschedulingsExecutor) Reconcile ¶
func (e *DeschedulingsExecutor) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state.
func (*DeschedulingsExecutor) SetupWithManager ¶
func (s *DeschedulingsExecutor) SetupWithManager(mgr manager.Manager, mcl *multicluster.Client) error
type DeschedulingsExecutorConfig ¶
type DeschedulingsExecutorConfig struct {
// DisableDeschedulerDryRun disables the dry-run mode of the descheduler, allowing it to execute live-migrations.
DisableDeschedulerDryRun bool `json:"disableDeschedulerDryRun"`
}
type DetectorCycleBreaker ¶
type DetectorCycleBreaker struct {
// Nova API to get needed information for cycle detection.
NovaClient NovaClient
}
func (*DetectorCycleBreaker) Filter ¶
func (c *DetectorCycleBreaker) Filter(ctx context.Context, decisions []plugins.VMDetection) ([]plugins.VMDetection, error)
type DetectorPipelineController ¶
type DetectorPipelineController struct {
// Toolbox shared between all pipeline controllers.
lib.BasePipelineController[*lib.DetectorPipeline[plugins.VMDetection]]
// Monitor to pass down to all pipelines.
Monitor lib.DetectorPipelineMonitor
// Cycle detector to avoid descheduling loops.
Breaker lib.DetectorCycleBreaker[plugins.VMDetection]
}
The deschedulings pipeline controller is responsible for periodically running the descheduling pipeline and creating descheduling resources based on the selections made.
Additionally, the controller watches for pipeline and step changes to reconfigure the pipelines as needed.
func (*DetectorPipelineController) CreateDeschedulingsPeriodically ¶
func (c *DetectorPipelineController) CreateDeschedulingsPeriodically(ctx context.Context)
func (*DetectorPipelineController) InitPipeline ¶
func (c *DetectorPipelineController) InitPipeline( ctx context.Context, p v1alpha1.Pipeline, ) lib.PipelineInitResult[*lib.DetectorPipeline[plugins.VMDetection]]
The base controller will delegate the pipeline creation down to this method.
func (*DetectorPipelineController) PipelineType ¶
func (c *DetectorPipelineController) PipelineType() v1alpha1.PipelineType
The type of pipeline this controller manages.
func (*DetectorPipelineController) SetupWithManager ¶
func (c *DetectorPipelineController) SetupWithManager(mgr ctrl.Manager, mcl *multicluster.Client) error
type DomainNameHintConfig ¶
type DomainNameHintConfig struct {
// DomainName is the OpenStack domain name passed as the domain_name scheduler hint.
// Use a real domain name from the target environment so filter_external_customer
// can apply its prefix-matching logic.
DomainName string `json:"domainName"`
// EligibleHosts is the list of compute hostnames offered to the scheduler.
// Include at least one host with CUSTOM_EXTERNAL_CUSTOMER_EXCLUSIVE and one without
// to give the filter something to act on.
EligibleHosts []string `json:"eligibleHosts"`
// FlavorName is the Nova flavor name to use in the request (e.g. "g_k_c1_m2_v2").
FlavorName string `json:"flavorName"`
// FlavorExtraSpecs are the extra specs for the flavor. Required by most pipeline
// filters to determine hypervisor type, capabilities, and traits.
// Example: {"capabilities:hypervisor_type": "CH", "quota:hw_version": "2101"}
FlavorExtraSpecs map[string]string `json:"flavorExtraSpecs,omitempty"`
// Pipeline is the scheduler pipeline to target. Empty means default.
Pipeline string `json:"pipeline,omitempty"`
}
DomainNameHintConfig holds parameters for CheckDomainNameHintRouting.
type FailoverHostMatcher ¶
type FailoverHostMatcher interface {
// ConfirmAndMarkInUse marks the failover host reservation selected for the
// request's source host InUse, but only when it is the pipeline's top
// candidate. It does not change the candidate list.
ConfirmAndMarkInUse(ctx context.Context, request api.ExternalSchedulerRequest, orderedHosts []string) error
}
FailoverHostMatcher pins an evacuation's gang target to a failover host reservation after the pipeline runs, marking the matching reservation InUse so subsequent evacuations from the same source land on the same target. It is run as a post-hook, under the scheduler lock. Implemented by reservations/failoverhost.Matcher; an interface here so the handler can be unit-tested and nova need not import failoverhost at the call site.
type FeatureGates ¶
type FeatureGates struct {
// CommittedResourceTracking enables committed resource integration: writing
// placed VM UUIDs back into Reservation slots and classifying no-host-found
// results by committed resource coverage. Enable only on deployments that
// use committed resources.
CommittedResourceTracking bool `json:"committedResourceTracking,omitempty"`
// VirtualMachineCreation enables the creation of VM resources based on the
// scheduling spec for non-read-only requests.
VirtualMachineCreation bool `json:"virtualMachineCreation,omitempty"`
// VirtualMachineCreationMandatory must be enabled together with
// the VirtualMachineCreation feature. If set, the pipeline will
// require that a VM is created for each scheduling request.
VirtualMachineCreationMandatory bool `json:"virtualMachineCreationMandatory,omitempty"`
}
FeatureGates holds boolean toggles for Nova scheduling features that are in active rollout or only relevant for certain deployment types. Set via conf.json under the "featureGates" key. All flags default to false (disabled) when omitted.
type FilterWeigherPipelineController ¶
type FilterWeigherPipelineController struct {
// Toolbox shared between all pipeline controllers.
lib.BasePipelineController[lib.FilterWeigherPipeline[compute.PlacementRequest]]
// Monitor to pass down to all pipelines.
Monitor lib.FilterWeigherPipelineMonitor
}
FilterWeigherPipelineController owns the Nova filter-weigher pipelines: it watches Pipeline and Knowledge resources to (re)configure the pipelines, and exposes them via GetPipeline for the compute.Placement to run. Placement requests no longer flow through this controller — the compute.Placement, driven by the external-scheduler HTTP API and the reservation controllers, is the entrypoint.
func (*FilterWeigherPipelineController) InitPipeline ¶
func (c *FilterWeigherPipelineController) InitPipeline( ctx context.Context, p v1alpha1.Pipeline, ) lib.PipelineInitResult[lib.FilterWeigherPipeline[compute.PlacementRequest]]
func (*FilterWeigherPipelineController) PipelineType ¶
func (c *FilterWeigherPipelineController) PipelineType() v1alpha1.PipelineType
The type of pipeline this controller manages.
func (*FilterWeigherPipelineController) Reconcile ¶
func (c *FilterWeigherPipelineController) Reconcile(context.Context, ctrl.Request) (ctrl.Result, error)
Reconcile is a no-op: this controller reconfigures pipelines through its Pipeline/Knowledge watch handlers, and placement runs through the compute.Placement, not through object reconciliation. A Reconcile method is required to satisfy the controller builder.
func (*FilterWeigherPipelineController) SetupWithManager ¶
func (c *FilterWeigherPipelineController) SetupWithManager(mgr manager.Manager, mcl *multicluster.Client) error
type HTTPAPI ¶
func NewAPI ¶
func NewAPI( config HTTPAPIConfig, scheduler *compute.Placement, vmHandler *VirtualMachineHandler, crRecorder crs.Recorder, featureGates FeatureGates, failoverMatcher FailoverHostMatcher, ) HTTPAPI
NewAPI builds the Nova external-scheduler HTTP API. It calls the shared compute.Placement directly; VM-resource creation, committed-resource tracking and failover-host pinning run as post-hooks after the pipeline, under the scheduler's lock. failoverMatcher may be nil, in which case no failover-host pinning is applied.
type HTTPAPIConfig ¶
type HTTPAPIConfig struct {
// NovaLimitHostsToRequest, if true, will filter the Nova scheduler response
// to only include hosts that were in the original request.
NovaLimitHostsToRequest bool `json:"novaLimitHostsToRequest,omitempty"`
// ForcedDestinationEnabled toggles replicating Nova's forced-destination
// behavior (force_hosts/force_nodes skip the scheduling pipeline and
// filters). Defaults to true when unset; set to false to disable and let
// forced requests flow through the normal pipeline instead.
ForcedDestinationEnabled *bool `json:"forcedDestinationEnabled,omitempty"`
}
Custom configuration for the Nova external scheduler api.
type HypervisorOvercommitConfig ¶
type HypervisorOvercommitConfig struct {
// OvercommitMappings is a list of mappings that map hypervisor traits to
// overcommit ratios. Note that this list is applied in order, so if there
// are multiple mappings applying to the same hypervisors, the last mapping
// in this list will override the previous ones.
OvercommitMappings []HypervisorOvercommitMapping `json:"overcommitMappings"`
}
HypervisorOvercommitConfig holds the configuration for the HypervisorOvercommitController and is loaded from a configmap that is mounted into the controller pod.
func (*HypervisorOvercommitConfig) Validate ¶
func (c *HypervisorOvercommitConfig) Validate() error
Validate the provided HypervisorOvercommitConfig, returning an error if the config is invalid.
type HypervisorOvercommitController ¶
type HypervisorOvercommitController struct {
client.Client
// contains filtered or unexported fields
}
HypervisorOvercommitController is a controller that reconciles on the hypervisor crd and sets desired overcommit ratios based on the hypervisor type.
func (*HypervisorOvercommitController) Reconcile ¶
func (c *HypervisorOvercommitController) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state.
For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.20.2/pkg/reconcile
For more details about the method shape, read up here: - https://ahmet.im/blog/controller-pitfalls/#reconcile-method-shape
func (*HypervisorOvercommitController) SetupWithManager ¶
func (c *HypervisorOvercommitController) SetupWithManager(mgr ctrl.Manager) (err error)
SetupWithManager sets up the controller with the Manager and a multicluster client. The multicluster client is used to watch for changes in the Hypervisor CRD across all clusters and trigger reconciliations accordingly.
type HypervisorOvercommitMapping ¶
type HypervisorOvercommitMapping struct {
// Overcommit is the overcommit ratio to set for hypervisors by resource name.
// Values must be set to something >= 1.0, otherwise the controller will
// ignore them.
Overcommit map[hv1.ResourceName]float64 `json:"overcommit"`
// HasTrait specifies a trait that a hypervisor may have, and that, if present,
// triggers the controller to set the overcommit ratio specified in the
// overcommit field for that hypervisor.
HasTrait *string `json:"hasTrait,omitempty"`
// HasntTrait specifies a trait that a hypervisor may have, and that, if
// NOT present, triggers the controller to set the overcommit ratio
// specified in the overcommit field for that hypervisor.
HasntTrait *string `json:"hasntTrait,omitempty"`
}
HypervisorOvercommitMapping maps hypervisor types to their desired overcommit ratios. This mapping will be loaded from a configmap that is mounted into the controller pod.
func (*HypervisorOvercommitMapping) Validate ¶
func (m *HypervisorOvercommitMapping) Validate() error
Validate the provided HypervisorOvercommitMapping, returning an error if the mapping is invalid.
type NovaClient ¶
type NovaClient interface {
// Initialize the Nova API with the Keystone authentication.
Init(ctx context.Context, client client.Client, conf NovaClientConfig) error
// Get a server by ID.
Get(ctx context.Context, id string) (server, error)
// Live migrate a server to a new host (doesnt wait for it to complete).
LiveMigrate(ctx context.Context, id string) error
// Get migrations for a server by ID.
GetServerMigrations(ctx context.Context, id string) ([]migration, error)
// List all servers for a project with detailed info.
ListProjectServers(ctx context.Context, projectID string) ([]ServerDetail, error)
}
func NewNovaClient ¶
func NewNovaClient() NovaClient
type NovaClientConfig ¶
type NovaClientConfig struct {
// Secret ref to keystone credentials stored in a k8s secret.
KeystoneSecretRef corev1.SecretReference `json:"keystoneSecretRef"`
// Secret ref to SSO credentials stored in a k8s secret, if applicable.
SSOSecretRef *corev1.SecretReference `json:"ssoSecretRef,omitempty"`
}
type ServerDetail ¶
type ServerDetail struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
TenantID string `json:"tenant_id"`
Created string `json:"created"`
AvailabilityZone string `json:"OS-EXT-AZ:availability_zone"`
Hypervisor string `json:"OS-EXT-SRV-ATTR:hypervisor_hostname"`
FlavorName string // Populated from nested flavor.original_name
FlavorRAM uint64 // Populated from nested flavor.ram
FlavorVCPUs uint64 // Populated from nested flavor.vcpus
FlavorDisk uint64 // Populated from nested flavor.disk
Metadata map[string]string // Server metadata key-value pairs
Tags []string // Server tags
OSType string // OS type determined by OSTypeProber
}
ServerDetail contains extended server information for usage reporting.
type VirtualMachineHandler ¶
VirtualMachineHandler maps a processed scheduling decision into a vm-operator VirtualMachine resource and upserts it. The VirtualMachine is routed to the cluster matching its availability zone by the multicluster client's VirtualMachineRouter.
func (*VirtualMachineHandler) Upsert ¶
func (h *VirtualMachineHandler) Upsert(ctx context.Context, result compute.PlacementResult, request api.ExternalSchedulerRequest, intent v1alpha1.SchedulingIntent) error
Upsert creates or patches the VirtualMachine resource described by the scheduling result and request. Region and AZ are immutable on the CRD and only written on create; mutable fields (target host, cortex spec, labels) are patched on updates. A human-readable explanation of the result and the intent are recorded on the VM's cortex spec.
Source Files
¶
- adapter.go
- candidate_gatherer.go
- deschedulings_cleanup.go
- deschedulings_executor.go
- detector_cycle_breaker.go
- detector_pipeline_controller.go
- e2e_checks.go
- external_scheduler_api.go
- features.go
- filter_weigher_pipeline_controller.go
- hypervisor_overcommit_controller.go
- nova_client.go
- pipeline_webhook.go
- vm_handler.go