Documentation
¶
Index ¶
- func IndexFields(ctx context.Context, mcl *multicluster.Client) error
- func RunE2E(ctx context.Context, cl client.Client) error
- type FeatureMode
- type ResourceClassSyncer
- type Shim
- func (s *Shim) Collect(ch chan<- prometheus.Metric)
- func (s *Shim) Describe(ch chan<- *prometheus.Desc)
- func (s *Shim) HandleCreateResourceClass(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleCreateResourceProvider(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleDeleteAllocations(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleDeleteResourceClass(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleDeleteResourceProvider(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleDeleteResourceProviderInventories(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleDeleteResourceProviderInventory(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleDeleteResourceProviderTraits(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleDeleteTrait(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleGetRoot(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleListAllocationCandidates(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleListAllocations(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleListResourceClasses(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleListResourceProviderAggregates(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleListResourceProviderAllocations(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleListResourceProviderInventories(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleListResourceProviderTraits(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleListResourceProviderUsages(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleListResourceProviders(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleListTraits(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleListUsages(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleManageAllocations(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandlePostReshaper(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleShowResourceClass(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleShowResourceProvider(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleShowResourceProviderInventory(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleShowTrait(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleUpdateAllocations(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleUpdateResourceClass(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleUpdateResourceProvider(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleUpdateResourceProviderAggregates(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleUpdateResourceProviderInventories(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleUpdateResourceProviderInventory(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleUpdateResourceProviderTraits(w http.ResponseWriter, r *http.Request)
- func (s *Shim) HandleUpdateTrait(w http.ResponseWriter, r *http.Request)
- func (s *Shim) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
- func (s *Shim) RegisterRoutes(mux *http.ServeMux)
- func (s *Shim) SetupWithManager(ctx context.Context, mgr ctrl.Manager) (err error)
- func (s *Shim) Start(ctx context.Context) error
- type Syncer
- type TraitSyncer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IndexFields ¶
func IndexFields(ctx context.Context, mcl *multicluster.Client) error
IndexFields indexes all fields that are needed by the shim to quickly look up objects from the controller-runtime cache.
Types ¶
type FeatureMode ¶
type FeatureMode string
FeatureMode controls how an endpoint group interacts with upstream placement and the hypervisor CRD.
const ( // FeatureModePassthrough forwards all requests to upstream placement // without any shim logic. FeatureModePassthrough FeatureMode = "passthrough" // FeatureModeHybrid directs requests to both upstream placement and the // hypervisor CRD. Upstream must respond; the shim keeps CRD state in // sync to prepare for cutover. FeatureModeHybrid FeatureMode = "hybrid" // FeatureModeCRD serves requests exclusively from the hypervisor CRD. // No upstream placement dependency is required. FeatureModeCRD FeatureMode = "crd" )
type ResourceClassSyncer ¶
type ResourceClassSyncer struct {
// contains filtered or unexported fields
}
ResourceClassSyncer manages the lifecycle of the resource classes ConfigMap. It creates the ConfigMap on startup and periodically syncs from upstream.
func NewResourceClassSyncer ¶
func NewResourceClassSyncer( cl client.Client, configMapName string, namespace string, placementClient *gophercloud.ServiceClient, resourceLocker *resourcelock.ResourceLocker, ) *ResourceClassSyncer
func (*ResourceClassSyncer) Init ¶
func (rs *ResourceClassSyncer) Init(ctx context.Context) error
Init creates the resource classes ConfigMap if it does not already exist.
func (*ResourceClassSyncer) Run ¶
func (rs *ResourceClassSyncer) Run(ctx context.Context)
Run starts the periodic background sync from upstream placement. Blocks until ctx is cancelled.
type Shim ¶
Shim is the placement API shim. It holds a controller-runtime client for making Kubernetes API calls and exposes HTTP handlers that mirror the OpenStack Placement API surface.
func (*Shim) Collect ¶
func (s *Shim) Collect(ch chan<- prometheus.Metric)
Collect implements prometheus.Collector.
func (*Shim) Describe ¶
func (s *Shim) Describe(ch chan<- *prometheus.Desc)
Describe implements prometheus.Collector.
func (*Shim) HandleCreateResourceClass ¶
func (s *Shim) HandleCreateResourceClass(w http.ResponseWriter, r *http.Request)
HandleCreateResourceClass handles POST /resource_classes requests.
Feature modes:
- passthrough: forwards to upstream placement.
- hybrid: forwards to upstream; on success, adds the class to the local ConfigMap.
- crd: writes the class to the local ConfigMap (CUSTOM_ prefix required).
See: https://docs.openstack.org/api-ref/placement/#create-resource-class
func (*Shim) HandleCreateResourceProvider ¶
func (s *Shim) HandleCreateResourceProvider(w http.ResponseWriter, r *http.Request)
HandleCreateResourceProvider handles POST /resource_providers requests.
Creates a new resource provider. The request must include a name and may optionally specify a UUID and a parent_provider_uuid (since 1.14) to place the provider in a hierarchical tree. If no UUID is supplied, one is generated. Before microversion 1.37, the parent of a resource provider could not be changed after creation.
The response changed at microversion 1.20: earlier versions return only an HTTP 201 with a Location header, while 1.20+ returns the full resource provider object in the body. Returns 409 Conflict if a provider with the same name or UUID already exists.
If the name matches a KVM hypervisor already managed by Kubernetes, the shim returns 409 Conflict to prevent shadow resource providers from being created in upstream placement.
See: https://docs.openstack.org/api-ref/placement/#create-resource-provider
func (*Shim) HandleDeleteAllocations ¶
func (s *Shim) HandleDeleteAllocations(w http.ResponseWriter, r *http.Request)
HandleDeleteAllocations handles DELETE /allocations/{consumer_uuid} requests.
Removes all allocation records for the consumer across all resource providers. Returns 204 No Content on success, or 404 Not Found if the consumer has no existing allocations.
func (*Shim) HandleDeleteResourceClass ¶
func (s *Shim) HandleDeleteResourceClass(w http.ResponseWriter, r *http.Request)
HandleDeleteResourceClass handles DELETE /resource_classes/{name} requests.
Feature modes:
- passthrough: forwards to upstream placement.
- hybrid: forwards to upstream; on success, removes the class from the local ConfigMap.
- crd: removes the class from the local ConfigMap (CUSTOM_ prefix required).
See: https://docs.openstack.org/api-ref/placement/#delete-resource-class
func (*Shim) HandleDeleteResourceProvider ¶
func (s *Shim) HandleDeleteResourceProvider(w http.ResponseWriter, r *http.Request)
HandleDeleteResourceProvider handles DELETE /resource_providers/{uuid} requests.
Deletes a resource provider and disassociates all its aggregates and inventories. The operation fails with 409 Conflict if there are any allocations against the provider's inventories or if the provider has child providers in a tree hierarchy. Returns 204 No Content on success.
See: https://docs.openstack.org/api-ref/placement/#delete-resource-provider
func (*Shim) HandleDeleteResourceProviderInventories ¶
func (s *Shim) HandleDeleteResourceProviderInventories(w http.ResponseWriter, r *http.Request)
HandleDeleteResourceProviderInventories handles DELETE /resource_providers/{uuid}/inventories requests.
Deletes all inventory records for a resource provider. This operation is not safe for concurrent use; the recommended alternative for concurrent environments is PUT with an empty inventories dictionary. Returns 409 Conflict if allocations exist against any of the provider's inventories. Returns 404 if the provider does not exist. Available since microversion 1.5.
func (*Shim) HandleDeleteResourceProviderInventory ¶
func (s *Shim) HandleDeleteResourceProviderInventory(w http.ResponseWriter, r *http.Request)
HandleDeleteResourceProviderInventory handles DELETE /resource_providers/{uuid}/inventories/{resource_class} requests.
Deletes the inventory record for a specific resource class on the provider. Returns 409 Conflict if allocations exist against this provider and resource class combination, or if a concurrent update has occurred. Returns 404 if the provider or inventory does not exist. Returns 204 No Content on success.
func (*Shim) HandleDeleteResourceProviderTraits ¶
func (s *Shim) HandleDeleteResourceProviderTraits(w http.ResponseWriter, r *http.Request)
HandleDeleteResourceProviderTraits handles DELETE /resource_providers/{uuid}/traits requests.
Removes all trait associations from a resource provider. Because this endpoint does not accept a resource_provider_generation, it is not safe for concurrent use. In environments where multiple clients manage traits for the same provider, prefer PUT with an empty traits list instead. Returns 404 if the provider does not exist. Returns 409 Conflict on concurrent modification. Returns 204 No Content on success.
https://docs.openstack.org/api-ref/placement/#delete-resource-provider-traits
func (*Shim) HandleDeleteTrait ¶
func (s *Shim) HandleDeleteTrait(w http.ResponseWriter, r *http.Request)
HandleDeleteTrait handles DELETE /traits/{name} requests.
Feature modes:
- passthrough: forwards to upstream placement.
- hybrid: forwards to upstream; on success, removes the trait from the local ConfigMap.
- crd: removes the trait from the local ConfigMap (CUSTOM_ prefix required).
See: https://docs.openstack.org/api-ref/placement/#delete-traits
func (*Shim) HandleGetRoot ¶
func (s *Shim) HandleGetRoot(w http.ResponseWriter, r *http.Request)
HandleGetRoot handles GET / requests.
Returns information about all known major versions of the Placement API, including the minimum and maximum supported microversions for each version. Currently only one major version (v1.0) exists. Each version entry includes its status (e.g. CURRENT), links for discovery, and the microversion range supported by the running service. Clients use this endpoint to discover API capabilities and negotiate microversions before making further requests.
In passthrough mode, the request is forwarded to upstream placement. In hybrid mode, the shim returns the intersection (narrower range) of the upstream and local version configs. In crd mode, the response is served from the static versioning config alone.
See: https://docs.openstack.org/api-ref/placement/#list-versions
func (*Shim) HandleListAllocationCandidates ¶
func (s *Shim) HandleListAllocationCandidates(w http.ResponseWriter, r *http.Request)
HandleListAllocationCandidates handles GET /allocation_candidates requests.
Returns a collection of allocation requests and resource provider summaries that can satisfy a given set of resource and trait requirements. This is the primary endpoint used by Nova's scheduler to find suitable hosts for instance placement.
The resources query parameter specifies required capacity as a comma- separated list (e.g. VCPU:4,MEMORY_MB:2048,DISK_GB:64). The required parameter filters by traits, supporting forbidden traits via ! prefix (since 1.22) and the in: syntax for any-of semantics (since 1.39). The member_of parameter filters by aggregate membership with support for forbidden aggregates via ! prefix (since 1.32).
Since microversion 1.25, granular request groups are supported via numbered suffixes (resourcesN, requiredN, member_ofN) to express requirements that may be satisfied by different providers. The group_policy parameter (1.26+) controls whether groups must each be satisfied by a single provider or may span multiple. The in_tree parameter (1.31+) constrains results to a specific provider tree.
Each returned allocation request is directly usable as the body for PUT /allocations/{consumer_uuid}. The provider_summaries section includes inventory capacity and usage for informed decision-making. Available since microversion 1.10.
func (*Shim) HandleListAllocations ¶
func (s *Shim) HandleListAllocations(w http.ResponseWriter, r *http.Request)
HandleListAllocations handles GET /allocations/{consumer_uuid} requests.
Returns all allocation records for the consumer identified by {consumer_uuid}, across all resource providers. The response contains an allocations dictionary keyed by resource provider UUID. If the consumer has no allocations, an empty dictionary is returned.
The response has grown across microversions: project_id and user_id were added at 1.12, consumer_generation at 1.28, and consumer_type at 1.38. The consumer_generation and consumer_type fields are absent when the consumer has no allocations.
func (*Shim) HandleListResourceClasses ¶
func (s *Shim) HandleListResourceClasses(w http.ResponseWriter, r *http.Request)
HandleListResourceClasses handles GET /resource_classes requests.
Feature modes:
- passthrough: forwards to upstream placement.
- hybrid: forwards to upstream placement.
- crd: serves the resource class list from the local ConfigMap.
See: https://docs.openstack.org/api-ref/placement/#list-resource-classes
func (*Shim) HandleListResourceProviderAggregates ¶
func (s *Shim) HandleListResourceProviderAggregates(w http.ResponseWriter, r *http.Request)
HandleListResourceProviderAggregates handles GET /resource_providers/{uuid}/aggregates requests.
Returns the list of aggregate UUIDs associated with the resource provider. Aggregates model relationships among providers such as shared storage, affinity/anti-affinity groups, and availability zones. Returns an empty list if the provider has no aggregate associations.
Routing: the uuid is used to determine if the resource provider is a KVM hypervisor or vmware/ironic hypervisor. Passthrough mode forwards all requests to upstream placement. Hybrid mode uses the hypervisor CRD for KVM hypervisors and forwards for anything else. CRD-only mode rejects any non-KVM calls with 404.
https://docs.openstack.org/api-ref/placement/#list-resource-provider-aggregates
func (*Shim) HandleListResourceProviderAllocations ¶
func (s *Shim) HandleListResourceProviderAllocations(w http.ResponseWriter, r *http.Request)
HandleListResourceProviderAllocations handles GET /resource_providers/{uuid}/allocations requests.
Returns all allocations made against the resource provider identified by {uuid}, keyed by consumer UUID. This provides a provider-centric view of consumption, complementing the consumer-centric GET /allocations/{consumer} endpoint. The response includes the resource_provider_generation. Returns 404 if the provider does not exist.
func (*Shim) HandleListResourceProviderInventories ¶
func (s *Shim) HandleListResourceProviderInventories(w http.ResponseWriter, r *http.Request)
HandleListResourceProviderInventories handles GET /resource_providers/{uuid}/inventories requests.
Returns all inventory records for the resource provider identified by {uuid}. The response contains an inventories dictionary keyed by resource class, with each entry describing capacity constraints: total, reserved, min_unit, max_unit, step_size, and allocation_ratio. Also returns the resource_provider_generation, which is needed for subsequent update or delete operations. Returns 404 if the provider does not exist.
func (*Shim) HandleListResourceProviderTraits ¶
func (s *Shim) HandleListResourceProviderTraits(w http.ResponseWriter, r *http.Request)
HandleListResourceProviderTraits handles GET /resource_providers/{uuid}/traits requests.
Returns the list of traits associated with the resource provider identified by {uuid}. The response includes an array of trait name strings and the resource_provider_generation for concurrency tracking. Returns 404 if the provider does not exist.
https://docs.openstack.org/api-ref/placement/#list-resource-provider-traits
func (*Shim) HandleListResourceProviderUsages ¶
func (s *Shim) HandleListResourceProviderUsages(w http.ResponseWriter, r *http.Request)
HandleListResourceProviderUsages handles GET /resource_providers/{uuid}/usages requests.
Returns aggregated resource consumption for the resource provider identified by {uuid}. The response contains a usages dictionary keyed by resource class with integer usage amounts, along with the resource_provider_generation. Unlike the provider allocations endpoint, this does not break down usage by individual consumer. Returns 404 if the provider does not exist.
func (*Shim) HandleListResourceProviders ¶
func (s *Shim) HandleListResourceProviders(w http.ResponseWriter, r *http.Request)
HandleListResourceProviders handles GET /resource_providers requests.
Returns a filtered list of resource providers. Resource providers are entities that provide consumable inventory of one or more classes of resources (e.g. a compute node providing VCPU, MEMORY_MB, DISK_GB).
Supports numerous filter parameters including name, uuid, member_of (aggregate membership), resources (capacity filtering), in_tree (provider tree membership), and required (trait filtering). Multiple filters are combined with boolean AND logic. Many of these filters were added in later microversions: resources filtering at 1.3, tree queries at 1.14, trait requirements at 1.18, forbidden traits at 1.22, forbidden aggregates at 1.32, and the in: syntax for required at 1.39.
The shim fetches resource providers from upstream placement, then merges in KVM hypervisors managed by Kubernetes. On uuid or name collisions the Kubernetes version wins and a warning is logged.
See: https://docs.openstack.org/api-ref/placement/#list-resource-providers
func (*Shim) HandleListTraits ¶
func (s *Shim) HandleListTraits(w http.ResponseWriter, r *http.Request)
HandleListTraits handles GET /traits requests.
Feature modes:
- passthrough: forwards to upstream placement.
- hybrid: forwards to upstream placement.
- crd: serves the trait list from the local ConfigMap.
See: https://docs.openstack.org/api-ref/placement/#list-traits
func (*Shim) HandleListUsages ¶
func (s *Shim) HandleListUsages(w http.ResponseWriter, r *http.Request)
HandleListUsages handles GET /usages requests.
Returns a report of aggregated resource usage for a given project, and optionally a specific user within that project. The project_id query parameter is required; user_id is optional.
The response format changed at microversion 1.38: earlier versions return a flat dictionary of resource class to usage totals, while 1.38+ groups usages by consumer_type (e.g. INSTANCE, MIGRATION, all, unknown), with each group containing resource totals and a consumer_count. Since microversion 1.38, an optional consumer_type query parameter allows filtering the results. Available since microversion 1.9.
func (*Shim) HandleManageAllocations ¶
func (s *Shim) HandleManageAllocations(w http.ResponseWriter, r *http.Request)
HandleManageAllocations handles POST /allocations requests.
Atomically creates, updates, or deletes allocations for multiple consumers in a single request. This is the primary mechanism for operations that must modify allocations across several consumers atomically, such as live migrations and move operations where resources are transferred from one consumer to another. Available since microversion 1.13.
The request body is keyed by consumer UUID, each containing an allocations dictionary (keyed by resource provider UUID), along with project_id and user_id. Since microversion 1.28, consumer_generation enables consumer- level concurrency control. Since microversion 1.38, a consumer_type field (e.g. INSTANCE, MIGRATION) is supported. Returns 204 No Content on success, or 409 Conflict if inventory is insufficient or a concurrent update is detected (error code: placement.concurrent_update).
func (*Shim) HandlePostReshaper ¶
func (s *Shim) HandlePostReshaper(w http.ResponseWriter, r *http.Request)
HandlePostReshaper handles POST /reshaper requests.
Atomically migrates resource provider inventories and associated allocations in a single transaction. This endpoint is used when a provider tree needs to be restructured — for example, moving inventory from a root provider into newly created child providers — without leaving allocations in an inconsistent state during the transition.
The request body contains the complete set of inventories (keyed by resource provider UUID) and allocations (keyed by consumer UUID) that should exist after the operation. The Placement service validates all inputs atomically and applies them in a single database transaction. Returns 204 No Content on success. Returns 409 Conflict if any referenced resource provider does not exist or if inventory/allocation constraints would be violated. Available since microversion 1.30.
func (*Shim) HandleShowResourceClass ¶
func (s *Shim) HandleShowResourceClass(w http.ResponseWriter, r *http.Request)
HandleShowResourceClass handles GET /resource_classes/{name} requests.
Feature modes:
- passthrough: forwards to upstream placement.
- hybrid: forwards to upstream placement.
- crd: checks the local ConfigMap for the resource class.
See: https://docs.openstack.org/api-ref/placement/#show-resource-class
func (*Shim) HandleShowResourceProvider ¶
func (s *Shim) HandleShowResourceProvider(w http.ResponseWriter, r *http.Request)
HandleShowResourceProvider handles GET /resource_providers/{uuid} requests.
Returns a single resource provider identified by its UUID. The response includes the provider's name, generation (used for concurrency control in subsequent updates), and links. Starting at microversion 1.14, the response also includes parent_provider_uuid and root_provider_uuid to describe the provider's position in a hierarchical tree. Returns 404 if the provider does not exist.
See: https://docs.openstack.org/api-ref/placement/#show-resource-provider
func (*Shim) HandleShowResourceProviderInventory ¶
func (s *Shim) HandleShowResourceProviderInventory(w http.ResponseWriter, r *http.Request)
HandleShowResourceProviderInventory handles GET /resource_providers/{uuid}/inventories/{resource_class} requests.
Returns a single inventory record for one resource class on the specified provider. The response includes total, reserved, min_unit, max_unit, step_size, allocation_ratio, and the resource_provider_generation. Returns 404 if the provider or inventory for that class does not exist.
func (*Shim) HandleShowTrait ¶
func (s *Shim) HandleShowTrait(w http.ResponseWriter, r *http.Request)
HandleShowTrait handles GET /traits/{name} requests.
Feature modes:
- passthrough: forwards to upstream placement.
- hybrid: forwards to upstream placement.
- crd: checks the local ConfigMap for the trait.
See: https://docs.openstack.org/api-ref/placement/#show-traits
func (*Shim) HandleUpdateAllocations ¶
func (s *Shim) HandleUpdateAllocations(w http.ResponseWriter, r *http.Request)
HandleUpdateAllocations handles PUT /allocations/{consumer_uuid} requests.
Creates or replaces all allocation records for a single consumer. If allocations already exist for this consumer, they are entirely replaced by the new set. The request format changed at microversion 1.12 from an array-based layout to an object keyed by resource provider UUID. Microversion 1.28 added consumer_generation for concurrency control, and 1.38 introduced consumer_type.
Returns 204 No Content on success. Returns 409 Conflict if there is insufficient inventory or if a concurrent update was detected.
func (*Shim) HandleUpdateResourceClass ¶
func (s *Shim) HandleUpdateResourceClass(w http.ResponseWriter, r *http.Request)
HandleUpdateResourceClass handles PUT /resource_classes/{name} requests.
Feature modes:
- passthrough: forwards to upstream placement.
- hybrid: forwards to upstream; on success, adds the class to the local ConfigMap.
- crd: writes the class to the local ConfigMap (CUSTOM_ prefix required).
See: https://docs.openstack.org/api-ref/placement/#update-resource-class
func (*Shim) HandleUpdateResourceProvider ¶
func (s *Shim) HandleUpdateResourceProvider(w http.ResponseWriter, r *http.Request)
HandleUpdateResourceProvider handles PUT /resource_providers/{uuid} requests.
Updates a resource provider's name and, starting at microversion 1.14, its parent_provider_uuid. Since microversion 1.37, the parent may be changed to any existing provider UUID that would not create a loop in the tree, or set to null to make the provider a root. Returns 409 Conflict if another provider already has the requested name.
See: https://docs.openstack.org/api-ref/placement/#update-resource-provider
func (*Shim) HandleUpdateResourceProviderAggregates ¶
func (s *Shim) HandleUpdateResourceProviderAggregates(w http.ResponseWriter, r *http.Request)
HandleUpdateResourceProviderAggregates handles PUT /resource_providers/{uuid}/aggregates requests.
Replaces the complete set of aggregate associations for a resource provider. The request body must include an aggregates array and a resource_provider_generation for optimistic concurrency control. Returns 409 Conflict if the generation does not match. Returns 200 with the updated aggregate list on success.
Routing: same selective per-provider dispatch as GET.
https://docs.openstack.org/api-ref/placement/#update-resource-provider-aggregates
func (*Shim) HandleUpdateResourceProviderInventories ¶
func (s *Shim) HandleUpdateResourceProviderInventories(w http.ResponseWriter, r *http.Request)
HandleUpdateResourceProviderInventories handles PUT /resource_providers/{uuid}/inventories requests.
Atomically replaces the entire set of inventory records for a provider. The request must include the resource_provider_generation for optimistic concurrency control — if the generation does not match, the request fails with 409 Conflict. The inventories field is a dictionary keyed by resource class, each specifying at minimum a total value. Omitted inventory classes are deleted. Returns 409 Conflict if allocations exceed the new capacity or if a concurrent update has occurred.
func (*Shim) HandleUpdateResourceProviderInventory ¶
func (s *Shim) HandleUpdateResourceProviderInventory(w http.ResponseWriter, r *http.Request)
HandleUpdateResourceProviderInventory handles PUT /resource_providers/{uuid}/inventories/{resource_class} requests.
Creates or replaces the inventory record for a single resource class on the provider. The request must include resource_provider_generation for concurrency control and a total value. Optional fields control allocation constraints (allocation_ratio, min_unit, max_unit, step_size, reserved). Since microversion 1.26, the reserved value must not exceed total. Returns 409 Conflict on generation mismatch or if allocations would be violated.
func (*Shim) HandleUpdateResourceProviderTraits ¶
func (s *Shim) HandleUpdateResourceProviderTraits(w http.ResponseWriter, r *http.Request)
HandleUpdateResourceProviderTraits handles PUT /resource_providers/{uuid}/traits requests.
Replaces the complete set of trait associations for a resource provider. The request body must include a traits array and the resource_provider_generation for optimistic concurrency control. All previously associated traits are removed and replaced by the specified set. Returns 409 Conflict if the generation does not match.
https://docs.openstack.org/api-ref/placement/#update-resource-provider-traits
func (*Shim) HandleUpdateTrait ¶
func (s *Shim) HandleUpdateTrait(w http.ResponseWriter, r *http.Request)
HandleUpdateTrait handles PUT /traits/{name} requests.
Feature modes:
- passthrough: forwards to upstream placement.
- hybrid: forwards to upstream; on success, adds the trait to the local ConfigMap.
- crd: writes the trait to the local ConfigMap (CUSTOM_ prefix required).
See: https://docs.openstack.org/api-ref/placement/#update-trait
func (*Shim) Reconcile ¶
Reconcile is not used by the shim, but must be implemented to satisfy the controller-runtime Reconciler interface.
func (*Shim) RegisterRoutes ¶
RegisterRoutes binds all Placement API handlers to the given mux. The route patterns use the Go 1.22+ ServeMux syntax with explicit HTTP methods and path wildcards. The routes mirror the OpenStack Placement API surface as documented at https://docs.openstack.org/api-ref/placement/.
func (*Shim) SetupWithManager ¶
SetupWithManager sets up the controller with the manager. It registers watches for the Hypervisor CRD across all clusters and sets up the HTTP client for talking to the placement API.
type Syncer ¶
type Syncer interface {
// Init creates the ConfigMap if it does not exist. Called once during
// Shim.Start before any requests are served.
Init(ctx context.Context) error
// Run starts the periodic background sync from upstream. Blocks until
// ctx is cancelled. Called as a goroutine from Shim.Start.
Run(ctx context.Context)
}
Syncer manages the lifecycle of a ConfigMap-backed local store: creating the ConfigMap on startup, and running a periodic background sync from upstream placement.
type TraitSyncer ¶
type TraitSyncer struct {
// contains filtered or unexported fields
}
TraitSyncer manages the lifecycle of the single traits ConfigMap. It creates the ConfigMap on startup and periodically syncs from upstream.
func NewTraitSyncer ¶
func NewTraitSyncer( cl client.Client, configMapName string, namespace string, placementClient *gophercloud.ServiceClient, resourceLocker *resourcelock.ResourceLocker, ) *TraitSyncer
func (*TraitSyncer) Init ¶
func (ts *TraitSyncer) Init(ctx context.Context) error
Init creates the traits ConfigMap if it does not already exist.
func (*TraitSyncer) Run ¶
func (ts *TraitSyncer) Run(ctx context.Context)
Run starts the periodic background sync from upstream placement. Blocks until ctx is cancelled.
Source Files
¶
- auth.go
- auth_keystone.go
- field_index.go
- handle_allocation_candidates.go
- handle_allocation_candidates_e2e.go
- handle_allocations.go
- handle_allocations_e2e.go
- handle_reshaper.go
- handle_reshaper_e2e.go
- handle_resource_classes.go
- handle_resource_classes_e2e.go
- handle_resource_provider_aggregates.go
- handle_resource_provider_aggregates_e2e.go
- handle_resource_provider_allocations.go
- handle_resource_provider_allocations_e2e.go
- handle_resource_provider_inventories.go
- handle_resource_provider_inventories_e2e.go
- handle_resource_provider_traits.go
- handle_resource_provider_traits_e2e.go
- handle_resource_provider_usages.go
- handle_resource_provider_usages_e2e.go
- handle_resource_providers.go
- handle_resource_providers_e2e.go
- handle_root.go
- handle_root_e2e.go
- handle_traits.go
- handle_traits_e2e.go
- handle_usages.go
- handle_usages_e2e.go
- shim.go
- shim_e2e.go
- shim_io.go
- syncer.go
- syncer_resource_classes.go
- syncer_traits.go
- validation.go