controller

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Overview

Package controller implements the controller logic

Index

Constants

View Source
const (
	// ManagementStateManual indicates that the resource should not be managed by the controller
	ManagementStateManual = "manual"

	// ManagementStateUnmanaged indicates that the resource should be ignored by the controller
	ManagementStateUnmanaged = "unmanaged"
)

Variables

View Source
var ErrPublicIPAttachmentNotFound = errors.New("public IP attachment not found in fulfillment service")
View Source
var ErrPublicIPNotFound = errors.New("public IP not found in fulfillment service")
View Source
var ErrTenantBeingDeleted = errors.New("tenant is being deleted")

ErrTenantBeingDeleted is returned by getTenant when the tenant exists but has DeletionTimestamp set.

Functions

func ComputeInstanceNamespacePredicate

func ComputeInstanceNamespacePredicate(namespace string) predicate.Predicate

func NamespacePredicate

func NamespacePredicate(namespace string) predicate.Predicate

func NetworkingNamespacePredicate

func NetworkingNamespacePredicate(namespace string) predicate.Predicate

NetworkingNamespacePredicate filters events by namespace for networking resources.

Types

type ClusterOrderReconciler

type ClusterOrderReconciler struct {
	client.Client

	Scheme                *runtime.Scheme
	ClusterOrderNamespace string
	ProvisioningProvider  provisioning.ProvisioningProvider
	StatusPollInterval    time.Duration
	MaxJobHistory         int
	// contains filtered or unexported fields
}

ClusterOrderReconciler reconciles a ClusterOrder object

func NewClusterOrderReconciler

func NewClusterOrderReconciler(
	client client.Client,
	apiReader client.Reader,
	scheme *runtime.Scheme,
	clusterOrderNamespace string,
	provisioningProvider provisioning.ProvisioningProvider,
	statusPollInterval time.Duration,
	maxJobHistory int,
) *ClusterOrderReconciler

func (*ClusterOrderReconciler) Reconcile

func (r *ClusterOrderReconciler) 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 (*ClusterOrderReconciler) SetupWithManager

func (r *ClusterOrderReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager sets up the controller with the Manager.

type ComputeInstanceFeedbackReconciler

type ComputeInstanceFeedbackReconciler struct {
	// contains filtered or unexported fields
}

ComputeInstanceFeedbackReconciler sends updates to the fulfillment service.

func NewComputeInstanceFeedbackReconciler

func NewComputeInstanceFeedbackReconciler(hubClient clnt.Client, grpcConn *grpc.ClientConn, computeInstanceNamespace string) *ComputeInstanceFeedbackReconciler

NewComputeInstanceFeedbackReconciler creates a reconciler that sends to the fulfillment service updates about compute instances.

func (*ComputeInstanceFeedbackReconciler) Reconcile

func (r *ComputeInstanceFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error)

Reconcile is the implementation of the reconciler interface.

func (*ComputeInstanceFeedbackReconciler) SetupWithManager

func (r *ComputeInstanceFeedbackReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager adds the reconciler to the controller manager.

type ComputeInstanceReconciler

type ComputeInstanceReconciler struct {
	client.Client
	Scheme   *runtime.Scheme
	Recorder events.EventRecorder

	ComputeInstanceNamespace string
	TenantNamespace          string
	NetworkingNamespace      string
	ProvisioningProvider     provisioning.ProvisioningProvider
	// StatusPollInterval defines how often to check provisioning job status
	StatusPollInterval time.Duration
	// MaxJobHistory defines how many jobs to keep in status.jobs array
	MaxJobHistory int
	// contains filtered or unexported fields
}

ComputeInstanceReconciler reconciles a ComputeInstance object

func NewComputeInstanceReconciler

func NewComputeInstanceReconciler(
	mgr mcmanager.Manager,
	computeInstanceNamespace string,
	tenantNamespace string,
	networkingNamespace string,
	provisioningProvider provisioning.ProvisioningProvider,
	statusPollInterval time.Duration,
	maxJobHistory int,
	targetCluster mc.ClusterName,
) *ComputeInstanceReconciler

func (*ComputeInstanceReconciler) Reconcile

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 (*ComputeInstanceReconciler) SetupWithManager

func (r *ComputeInstanceReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager sets up the controller with the Manager.

type FeedbackReconciler

type FeedbackReconciler struct {
	// contains filtered or unexported fields
}

FeedbackReconciler sends updates to the fulfillment service.

func NewFeedbackReconciler

func NewFeedbackReconciler(logger logr.Logger, hubClient clnt.Client, grpcConn *grpc.ClientConn, clusterOrderNamespace string) *FeedbackReconciler

NewFeedbackReconciler creates a reconciler that sends to the fulfillment service updates about cluster orders.

func (*FeedbackReconciler) Reconcile

func (r *FeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error)

Reconcile is the implementation of the reconciler interface.

func (*FeedbackReconciler) SetupWithManager

func (r *FeedbackReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager adds the reconciler to the controller manager.

type NewComponentFn

type NewComponentFn func(context.Context, *v1alpha1.ClusterOrder) (*appResource, error)

NewComponentFn is the type of a function that creates a required component

type PublicIPAttachmentFeedbackReconciler

type PublicIPAttachmentFeedbackReconciler struct {
	// contains filtered or unexported fields
}

func NewPublicIPAttachmentFeedbackReconciler

func NewPublicIPAttachmentFeedbackReconciler(hubClient clnt.Client, grpcConn *grpc.ClientConn, networkingNamespace string) *PublicIPAttachmentFeedbackReconciler

func (*PublicIPAttachmentFeedbackReconciler) Reconcile

func (*PublicIPAttachmentFeedbackReconciler) SetupWithManager

type PublicIPAttachmentReconciler

type PublicIPAttachmentReconciler struct {
	client.Client
	APIReader client.Reader
	Scheme    *runtime.Scheme

	NetworkingNamespace      string
	ComputeInstanceNamespace string
	ProvisioningProvider     provisioning.ProvisioningProvider
	StatusPollInterval       time.Duration
	MaxJobHistory            int
	// contains filtered or unexported fields
}

PublicIPAttachmentReconciler reconciles PublicIPAttachment CRs.

Creating a PublicIPAttachment triggers an attach operation (osac-attach-public-ip AAP template) that moves the MetalLB Service from the parking namespace to the VM namespace. Deleting the CR triggers detach (osac-detach-public-ip) which reverses that.

The controller uses RunProvisioningLifecycle for provisioning, giving automatic exponential-backoff retry on failure. It also watches ComputeInstance resources to auto-delete the PublicIPAttachment when the target CI is deleted.

func NewPublicIPAttachmentReconciler

func NewPublicIPAttachmentReconciler(
	mgr mcmanager.Manager,
	networkingNamespace string,
	computeInstanceNamespace string,
	provisioningProvider provisioning.ProvisioningProvider,
	statusPollInterval time.Duration,
	maxJobHistory int,
	targetCluster mc.ClusterName,
) *PublicIPAttachmentReconciler

NewPublicIPAttachmentReconciler creates a new reconciler for PublicIPAttachment resources.

func (*PublicIPAttachmentReconciler) Reconcile

Reconcile handles create/update/delete for a PublicIPAttachment CR.

func (*PublicIPAttachmentReconciler) SetupWithManager

func (r *PublicIPAttachmentReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager registers this controller with the multicluster manager.

type PublicIPFeedbackReconciler

type PublicIPFeedbackReconciler struct {
	// contains filtered or unexported fields
}

PublicIPFeedbackReconciler sends updates to the fulfillment service.

func NewPublicIPFeedbackReconciler

func NewPublicIPFeedbackReconciler(hubClient clnt.Client, grpcConn *grpc.ClientConn, networkingNamespace string) *PublicIPFeedbackReconciler

NewPublicIPFeedbackReconciler creates a reconciler that sends to the fulfillment service updates about public IPs.

func (*PublicIPFeedbackReconciler) Reconcile

func (r *PublicIPFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error)

Reconcile is the implementation of the reconciler interface.

func (*PublicIPFeedbackReconciler) SetupWithManager

func (r *PublicIPFeedbackReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager adds the reconciler to the controller manager.

type PublicIPPoolFeedbackReconciler

type PublicIPPoolFeedbackReconciler struct {
	// contains filtered or unexported fields
}

PublicIPPoolFeedbackReconciler watches PublicIPPool CRs on the hub cluster and reports their phase and capacity back to the fulfillment service via gRPC. This is the reverse channel: the provisioning controller drives the CR forward, while this controller keeps the fulfillment service in sync with the CR's current state.

func NewPublicIPPoolFeedbackReconciler

func NewPublicIPPoolFeedbackReconciler(hubClient clnt.Client, grpcConn *grpc.ClientConn, networkingNamespace string) *PublicIPPoolFeedbackReconciler

NewPublicIPPoolFeedbackReconciler creates a reconciler that sends to the fulfillment service updates about public IP pools.

func (*PublicIPPoolFeedbackReconciler) Reconcile

func (r *PublicIPPoolFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error)

Reconcile syncs the PublicIPPool CR's phase and capacity to the fulfillment service. The flow has six steps:

  1. Fetch the CR (exit if deleted between event and processing)
  2. Check for the fulfillment-service ID label (skip manually-created CRs)
  3. Fetch the current proto record from the fulfillment service (handle NotFound during deletion)
  4. Map CR state to proto state via handleUpdate/handleDelete
  5. Persist changes via gRPC Update (only if proto.Equal detects a diff)
  6. On deletion: remove finalizer and Signal the fulfillment service to re-reconcile immediately

func (*PublicIPPoolFeedbackReconciler) SetupWithManager

func (r *PublicIPPoolFeedbackReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager registers this controller with controller-runtime. Named("publicippool-feedback") distinguishes it from the provisioning controller, which also watches PublicIPPool CRs. The namespace predicate limits reconciliation to CRs in the networking namespace.

type PublicIPPoolReconciler

type PublicIPPoolReconciler struct {
	client.Client
	APIReader client.Reader
	Scheme    *runtime.Scheme

	NetworkingNamespace  string
	ProvisioningProvider provisioning.ProvisioningProvider
	StatusPollInterval   time.Duration
	MaxJobHistory        int
	// contains filtered or unexported fields
}

PublicIPPoolReconciler reconciles PublicIPPool CRs created by the fulfillment-service.

A PublicIPPool defines a range of public IP addresses (CIDRs) that can be allocated as individual PublicIP resources. Unlike PublicIP (which inherits its strategy from the parent pool), PublicIPPool reads the implementation strategy from its own spec.

The controller adds a finalizer, triggers AAP provisioning/deprovisioning jobs via the shared provisioning lifecycle, and transitions phases: "" -> Progressing -> Ready/Failed; on delete: Deleting.

func NewPublicIPPoolReconciler

func NewPublicIPPoolReconciler(
	mgr mcmanager.Manager,
	networkingNamespace string,
	provisioningProvider provisioning.ProvisioningProvider,
	statusPollInterval time.Duration,
	maxJobHistory int,
	targetCluster mc.ClusterName,
) *PublicIPPoolReconciler

NewPublicIPPoolReconciler creates a new reconciler for PublicIPPool resources.

func (*PublicIPPoolReconciler) Reconcile

Reconcile handles create/update/delete for a PublicIPPool CR. On create/update it ensures a finalizer, reads the implementation strategy from spec, and runs provisioning. On delete it triggers deprovisioning and removes the finalizer.

func (*PublicIPPoolReconciler) SetupWithManager

func (r *PublicIPPoolReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager registers this controller with the multicluster manager. It watches PublicIPPool CRs in the networking namespace on the local cluster only.

type PublicIPReconciler

type PublicIPReconciler struct {
	client.Client
	APIReader client.Reader
	Scheme    *runtime.Scheme
	Recorder  events.EventRecorder

	NetworkingNamespace  string
	ProvisioningProvider provisioning.ProvisioningProvider
	StatusPollInterval   time.Duration
	MaxJobHistory        int
	// contains filtered or unexported fields
}

PublicIPReconciler reconciles PublicIP CRs created by the fulfillment-service.

Each PublicIP belongs to a parent PublicIPPool (referenced by UUID in spec.pool). The controller adds a finalizer, inherits the implementation strategy from the parent pool, then delegates to the shared provisioning lifecycle to trigger AAP jobs for allocation and deallocation.

Attach/detach is handled by the PublicIPAttachment controller.

Phase transitions: "" -> Progressing -> Ready/Failed; on delete: Deleting.

func NewPublicIPReconciler

func NewPublicIPReconciler(
	mgr mcmanager.Manager,
	networkingNamespace string,
	provisioningProvider provisioning.ProvisioningProvider,
	statusPollInterval time.Duration,
	maxJobHistory int,
	targetCluster mc.ClusterName,
) *PublicIPReconciler

NewPublicIPReconciler creates a new reconciler for PublicIP resources.

func (*PublicIPReconciler) Reconcile

Reconcile handles create/update/delete for a PublicIP CR. On create/update it ensures a finalizer, resolves the parent pool, and runs provisioning. On delete it triggers deprovisioning and removes the finalizer when complete.

func (*PublicIPReconciler) SetupWithManager

func (r *PublicIPReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager registers this controller with the multicluster manager. It watches PublicIP CRs in the networking namespace on the local cluster only.

type SecurityGroupFeedbackReconciler

type SecurityGroupFeedbackReconciler struct {
	// contains filtered or unexported fields
}

SecurityGroupFeedbackReconciler sends updates to the fulfillment service.

func NewSecurityGroupFeedbackReconciler

func NewSecurityGroupFeedbackReconciler(hubClient clnt.Client, grpcConn *grpc.ClientConn, networkingNamespace string) *SecurityGroupFeedbackReconciler

NewSecurityGroupFeedbackReconciler creates a reconciler that sends to the fulfillment service updates about security groups.

func (*SecurityGroupFeedbackReconciler) Reconcile

func (r *SecurityGroupFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error)

Reconcile is the implementation of the reconciler interface.

func (*SecurityGroupFeedbackReconciler) SetupWithManager

func (r *SecurityGroupFeedbackReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager adds the reconciler to the controller manager.

type SecurityGroupReconciler

type SecurityGroupReconciler struct {
	client.Client
	APIReader client.Reader
	Scheme    *runtime.Scheme

	NetworkingNamespace  string
	ProvisioningProvider provisioning.ProvisioningProvider
	StatusPollInterval   time.Duration
	MaxJobHistory        int
	// contains filtered or unexported fields
}

SecurityGroupReconciler reconciles a SecurityGroup object

func NewSecurityGroupReconciler

func NewSecurityGroupReconciler(
	mgr mcmanager.Manager,
	networkingNamespace string,
	provisioningProvider provisioning.ProvisioningProvider,
	statusPollInterval time.Duration,
	maxJobHistory int,
	targetCluster mc.ClusterName,
) *SecurityGroupReconciler

NewSecurityGroupReconciler creates a new reconciler for SecurityGroup resources.

func (*SecurityGroupReconciler) Reconcile

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 (*SecurityGroupReconciler) SetupWithManager

func (r *SecurityGroupReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager sets up the controller with the Manager.

type SubnetFeedbackReconciler

type SubnetFeedbackReconciler struct {
	// contains filtered or unexported fields
}

SubnetFeedbackReconciler sends updates to the fulfillment service.

func NewSubnetFeedbackReconciler

func NewSubnetFeedbackReconciler(hubClient clnt.Client, grpcConn *grpc.ClientConn, networkingNamespace string) *SubnetFeedbackReconciler

NewSubnetFeedbackReconciler creates a reconciler that sends to the fulfillment service updates about subnets.

func (*SubnetFeedbackReconciler) Reconcile

func (r *SubnetFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error)

Reconcile is the implementation of the reconciler interface.

func (*SubnetFeedbackReconciler) SetupWithManager

func (r *SubnetFeedbackReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager adds the reconciler to the controller manager.

type SubnetReconciler

type SubnetReconciler struct {
	client.Client
	APIReader client.Reader
	Scheme    *runtime.Scheme

	NetworkingNamespace  string
	ProvisioningProvider provisioning.ProvisioningProvider
	StatusPollInterval   time.Duration
	MaxJobHistory        int
	// contains filtered or unexported fields
}

SubnetReconciler reconciles a Subnet object

func NewSubnetReconciler

func NewSubnetReconciler(
	mgr mcmanager.Manager,
	networkingNamespace string,
	provisioningProvider provisioning.ProvisioningProvider,
	statusPollInterval time.Duration,
	maxJobHistory int,
	targetCluster mc.ClusterName,
) *SubnetReconciler

NewSubnetReconciler creates a new reconciler for Subnet resources.

func (*SubnetReconciler) Reconcile

func (r *SubnetReconciler) Reconcile(ctx context.Context, req mcreconcile.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 (*SubnetReconciler) SetupWithManager

func (r *SubnetReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager sets up the controller with the Manager.

type TenantReconciler

type TenantReconciler struct {
	client.Client
	Scheme   *runtime.Scheme
	Recorder events.EventRecorder

	ProvisioningProvider provisioning.ProvisioningProvider
	StatusPollInterval   time.Duration
	MaxJobHistory        int
	// contains filtered or unexported fields
}

TenantReconciler reconciles a Tenant object

func NewTenantReconciler

func NewTenantReconciler(
	mgr mcmanager.Manager,
	tenantNamespace string,
	targetCluster mc.ClusterName,
	provisioningProvider provisioning.ProvisioningProvider,
	statusPollInterval time.Duration,
	maxJobHistory int,
) *TenantReconciler

func (*TenantReconciler) Reconcile

func (r *TenantReconciler) Reconcile(ctx context.Context, req mcreconcile.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 (*TenantReconciler) SetupWithManager

func (r *TenantReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager sets up the controller with the Manager.

type VirtualNetworkFeedbackReconciler

type VirtualNetworkFeedbackReconciler struct {
	// contains filtered or unexported fields
}

VirtualNetworkFeedbackReconciler sends updates to the fulfillment service.

func NewVirtualNetworkFeedbackReconciler

func NewVirtualNetworkFeedbackReconciler(hubClient clnt.Client, grpcConn *grpc.ClientConn, networkingNamespace string) *VirtualNetworkFeedbackReconciler

NewVirtualNetworkFeedbackReconciler creates a reconciler that sends to the fulfillment service updates about virtual networks.

func (*VirtualNetworkFeedbackReconciler) Reconcile

func (r *VirtualNetworkFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error)

Reconcile is the implementation of the reconciler interface.

func (*VirtualNetworkFeedbackReconciler) SetupWithManager

func (r *VirtualNetworkFeedbackReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager adds the reconciler to the controller manager.

type VirtualNetworkReconciler

type VirtualNetworkReconciler struct {
	client.Client
	APIReader client.Reader
	Scheme    *runtime.Scheme

	NetworkingNamespace  string
	ProvisioningProvider provisioning.ProvisioningProvider
	StatusPollInterval   time.Duration
	MaxJobHistory        int
	// contains filtered or unexported fields
}

VirtualNetworkReconciler reconciles a VirtualNetwork object

func NewVirtualNetworkReconciler

func NewVirtualNetworkReconciler(
	mgr mcmanager.Manager,
	networkingNamespace string,
	provisioningProvider provisioning.ProvisioningProvider,
	statusPollInterval time.Duration,
	maxJobHistory int,
	targetCluster mc.ClusterName,
) *VirtualNetworkReconciler

NewVirtualNetworkReconciler creates a new reconciler for VirtualNetwork resources.

func (*VirtualNetworkReconciler) Reconcile

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 (*VirtualNetworkReconciler) SetupWithManager

func (r *VirtualNetworkReconciler) SetupWithManager(mgr mcmanager.Manager) error

SetupWithManager sets up the controller with the Manager.

Jump to

Keyboard shortcuts

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