Documentation
¶
Index ¶
- Variables
- func DegradedControllerPanicHandler(ctx context.Context, ...) func(interface{})
- func DeleteRecursively(ctx context.Context, resourcesDBClient corecosmosstorage.ResourcesDBClient, ...) error
- func GetOrCreateController(ctx context.Context, resourcesDBClient corecosmosstorage.ResourcesDBClient, ...) (*coreapi.Controller, error)
- func HostedClusterNamespace(envIdentifier, csClusterID string) string
- func HostedControlPlaneNamespace(envIdentifier, csClusterID, csClusterDomainPrefix string) string
- func ManagementClusterContentResourceIDFromParentResourceID(parentResourceID *azcorearm.ResourceID, ...) *azcorearm.ResourceID
- func MarkBillingDocumentDeleted(ctx context.Context, billingDBClient billingcosmosstorage.BillingDBClient, ...) error
- func NewInitialManagementClusterContent(managementClusterContentResourceID *azcorearm.ResourceID) *coreapi.ManagementClusterContent
- func ReportSyncError(syncErr error) controllerMutationFunc
- func WriteController(ctx context.Context, ...) error
- type ActiveOperationBasedChecker
- type AfterEnqueuer
- type ClusterSyncer
- type Controller
- func NewClusterWatchingController(name string, resourcesDBClient corecosmosstorage.ResourcesDBClient, ...) Controller
- func NewExternalAuthWatchingController(name string, resourcesDBClient corecosmosstorage.ResourcesDBClient, ...) Controller
- func NewGenericOperationController(name string, synchronizer OperationSynchronizer, ...) Controller
- func NewManagementClusterWatchingController(name string, fleetDBClient fleetcosmosstorage.FleetDBClient, ...) Controller
- func NewNodePoolWatchingController(name string, resourcesDBClient corecosmosstorage.ResourcesDBClient, ...) Controller
- func NewSubscriptionWatchingController(name string, informers coreinformers.BackendInformers, ...) Controller
- func NewSystemAdminCredentialRequestWatchingController(name string, resourcesDBClient corecosmosstorage.ResourcesDBClient, ...) Controller
- func NewSystemAdminCredentialRevocationWatchingController(name string, resourcesDBClient corecosmosstorage.ResourcesDBClient, ...) Controller
- type ExternalAuthSyncer
- type HCPClusterKey
- type HCPExternalAuthKey
- type HCPNodePoolKey
- type InitialControllerFunc
- type ManagementClusterKey
- type ManagementClusterSyncer
- type NodePoolSyncer
- type Notifier
- type OperationKey
- type OperationSynchronizer
- type SubscriptionKey
- type SubscriptionSyncer
- type SystemAdminCredentialRequestKey
- func (k SystemAdminCredentialRequestKey) AddLoggerValues(logger logr.Logger) logr.Logger
- func (k SystemAdminCredentialRequestKey) GetClusterResourceID() *azcorearm.ResourceID
- func (k SystemAdminCredentialRequestKey) GetResourceID() *azcorearm.ResourceID
- func (k SystemAdminCredentialRequestKey) InitialController(controllerName string) *coreapi.Controller
- type SystemAdminCredentialRequestSyncer
- type SystemAdminCredentialRevocationKey
- func (k SystemAdminCredentialRevocationKey) AddLoggerValues(logger logr.Logger) logr.Logger
- func (k SystemAdminCredentialRevocationKey) GetClusterResourceID() *azcorearm.ResourceID
- func (k SystemAdminCredentialRevocationKey) GetResourceID() *azcorearm.ResourceID
- func (k SystemAdminCredentialRevocationKey) InitialController(controllerName string) *coreapi.Controller
- type SystemAdminCredentialRevocationSyncer
Constants ¶
This section is empty.
Variables ¶
var ( // ReconcileTotal counts the total number of reconciliations per controller. ReconcileTotal = promauto.With(legacyregistry.Registerer()).NewCounterVec( prometheus.CounterOpts{ Name: "backend_controller_reconcile_total", Help: "Total number of reconciliations per controller.", }, []string{"controller"}, ) )
Functions ¶
func DegradedControllerPanicHandler ¶
func DegradedControllerPanicHandler(ctx context.Context, controllerCRUD cosmosstorageutils.ResourceCRUD[coreapi.Controller, *coreapi.Controller], controllerName string, initialControllerFn InitialControllerFunc) func(interface{})
func DeleteRecursively ¶
func DeleteRecursively(ctx context.Context, resourcesDBClient corecosmosstorage.ResourcesDBClient, rootResourceID *azcorearm.ResourceID) error
func GetOrCreateController ¶
func GetOrCreateController( ctx context.Context, resourcesDBClient corecosmosstorage.ResourcesDBClient, parentResourceID *azcorearm.ResourceID, controllerName string, initialControllerFn InitialControllerFunc, ) (*coreapi.Controller, error)
GetOrCreateController gets the named Controller document under the given parent resource (cluster, node pool, or external auth). If it does not exist, it creates one using initialControllerFn. On create conflict (HTTP 409), it re-reads and returns the existing document (same pattern as corecosmosstorage.GetOrCreateServiceProviderCluster).
func HostedClusterNamespace ¶
HostedClusterNamespace returns the management-cluster namespace that hosts a given HCP's HostedCluster / NodePool objects. Cluster Service names it "ocm-<envIdentifier>-<csClusterID>" and we must mirror that exactly so the kube-applier targets the right namespace.
func HostedControlPlaneNamespace ¶
HostedControlPlaneNamespace returns the management-cluster namespace that hosts a given HCP's control plane workloads (including ControlPlaneComponent CRs). Hypershift names it "ocm-<envIdentifier>-<csClusterID>-<csClusterDomainPrefix>".
func ManagementClusterContentResourceIDFromParentResourceID ¶
func ManagementClusterContentResourceIDFromParentResourceID(parentResourceID *azcorearm.ResourceID, maestroBundleInternalName coreapi.MaestroBundleInternalName) *azcorearm.ResourceID
ManagementClusterContentResourceIDFromParentResourceID returns the resource ID for the ManagementClusterContent nested under parentResourceID with the given maestro bundle internal name.
func MarkBillingDocumentDeleted ¶
func MarkBillingDocumentDeleted(ctx context.Context, billingDBClient billingcosmosstorage.BillingDBClient, resourceID *azcorearm.ResourceID, deletionTime time.Time) error
MarkBillingDocumentDeleted patches a Cosmos DB document in the Billing container to add a deletion timestamp.
func NewInitialManagementClusterContent ¶
func NewInitialManagementClusterContent(managementClusterContentResourceID *azcorearm.ResourceID) *coreapi.ManagementClusterContent
NewInitialManagementClusterContent returns a new ManagementClusterContent with the given full managementClusterContents ARM resource ID. The returned value can be used to consistently initialize a new ManagementClusterContent
func ReportSyncError ¶
func ReportSyncError(syncErr error) controllerMutationFunc
func WriteController ¶
func WriteController(ctx context.Context, controllerCRUD cosmosstorageutils.ResourceCRUD[coreapi.Controller, *coreapi.Controller], controllerName string, initialControllerFn InitialControllerFunc, mutationFns ...controllerMutationFunc) error
WriteController will read the existing value, call the mutations in order, then write the result. It only tries *once*. If it fails, then the an error is returned. This detail is important, it doesn't even retry conflicts. This is so that if a failure happens the control-loop will re-run and restablish the information it was trying to write as valid. This prevents accidental recreation of controller instances in cosmos during a delete.
Types ¶
type ActiveOperationBasedChecker ¶
type ActiveOperationBasedChecker struct {
// contains filtered or unexported fields
}
func DefaultActiveOperationPrioritizingCooldown ¶
func DefaultActiveOperationPrioritizingCooldown(activeOperationLister corelisters.ActiveOperationLister) *ActiveOperationBasedChecker
func NewActiveOperationPrioritizingCooldown ¶
func NewActiveOperationPrioritizingCooldown(activeOperationLister corelisters.ActiveOperationLister, activeOperationCooldown, inactiveOperationCooldown time.Duration) *ActiveOperationBasedChecker
type AfterEnqueuer ¶
type AfterEnqueuer = controllerutil.AfterEnqueuer
Type aliases re-export types from internal/controllerutils so that existing backend callers continue to compile without import changes.
type ClusterSyncer ¶
type ClusterSyncer interface {
SyncOnce(ctx context.Context, keyObj HCPClusterKey) error
}
type Controller ¶
type Controller interface {
QueueForInformers(resyncDuration time.Duration, notifiers ...Notifier) error
SyncOnce(ctx context.Context, keyObj any) error
Run(ctx context.Context, threadiness int)
}
func NewClusterWatchingController ¶
func NewClusterWatchingController( name string, resourcesDBClient corecosmosstorage.ResourcesDBClient, informers coreinformers.BackendInformers, kubeApplierInformers *unionkubeapplierinformers.UnionKubeApplierInformers, resyncDuration time.Duration, syncer ClusterSyncer, ) Controller
NewClusterWatchingController periodically looks up all clusters and queues them cooldownDuration is how long to wait before allowing a new notification to fire the controller. Since our detection of change is coarse, we are being triggered every few second without new information. Until we get a changefeed, the cooldownDuration value is effectively the min resync time. This does NOT prevent us from re-executing on errors, so errors will continue to trigger fast checks as expected.
kubeApplierInformers is optional: when non-nil, the controller also enqueues on ReadDesire events from the union kube-applier informer surface. The status that the kube-applier writes back lives on the ReadDesire, so a ReadDesire update is how this controller learns "the kube-applier reported something new about a cluster". Apply/Delete desires are not wired in because their status doesn't carry cluster-state signal.
func NewExternalAuthWatchingController ¶
func NewExternalAuthWatchingController( name string, resourcesDBClient corecosmosstorage.ResourcesDBClient, informers coreinformers.BackendInformers, resyncDuration time.Duration, syncer ExternalAuthSyncer, ) Controller
NewExternalAuthWatchingController periodically looks up all ExternalAuths and queues them cooldownDuration is how long to wait before allowing a new notification to fire the controller. Since our detection of change is coarse, we are being triggered every few second without new information. Until we get a changefeed, the cooldownDuration value is effectively the min resync time. This does NOT prevent us from re-executing on errors, so errors will continue to trigger fast checks as expected.
func NewGenericOperationController ¶
func NewGenericOperationController( name string, synchronizer OperationSynchronizer, activeOperationScanInterval time.Duration, activeOperationInformer cache.SharedIndexInformer, resourcesDBClient corecosmosstorage.ResourcesDBClient, ) Controller
NewGenericOperationController returns a Controller that updates Cosmos DB documents tracking ongoing asynchronous operations. Each Controller instance has a unique OperationSynchronizer that reconciles a particular type of asynchronous operation, like cluster creation or node pool deletion.
func NewManagementClusterWatchingController ¶
func NewManagementClusterWatchingController( name string, fleetDBClient fleetcosmosstorage.FleetDBClient, fleetInformers fleetinformers.FleetInformers, resyncDuration time.Duration, syncer ManagementClusterSyncer, ) Controller
NewManagementClusterWatchingController periodically looks up all management clusters and queues them.
func NewNodePoolWatchingController ¶
func NewNodePoolWatchingController( name string, resourcesDBClient corecosmosstorage.ResourcesDBClient, informers coreinformers.BackendInformers, kubeApplierInformers *unionkubeapplierinformers.UnionKubeApplierInformers, resyncDuration time.Duration, syncer NodePoolSyncer, ) Controller
NewNodePoolWatchingController periodically looks up all NodePools and queues them cooldownDuration is how long to wait before allowing a new notification to fire the controller. Since our detection of change is coarse, we are being triggered every few second without new information. Until we get a changefeed, the cooldownDuration value is effectively the min resync time. This does NOT prevent us from re-executing on errors, so errors will continue to trigger fast checks as expected.
kubeApplierInformers is optional: when non-nil, the controller also enqueues on ReadDesire events from the union kube-applier informer surface. The status that the kube-applier writes back lives on the ReadDesire, so a ReadDesire update is how this controller learns "the kube-applier reported something new about a node pool". Apply/Delete desires are not wired in because their status doesn't carry node-pool-state signal.
func NewSubscriptionWatchingController ¶
func NewSubscriptionWatchingController( name string, informers coreinformers.BackendInformers, resyncDuration time.Duration, syncer SubscriptionSyncer, ) Controller
NewSubscriptionWatchingController periodically looks up all subscriptions and queues them. cooldownDuration is how long to wait before allowing a new notification to fire the controller. Since our detection of change is coarse, we are being triggered every few second without new information. Until we get a changefeed, the cooldownDuration value is effectively the min resync time. This does NOT prevent us from re-executing on errors, so errors will continue to trigger fast checks as expected.
func NewSystemAdminCredentialRequestWatchingController ¶
func NewSystemAdminCredentialRequestWatchingController( name string, resourcesDBClient corecosmosstorage.ResourcesDBClient, backendInformers coreinformers.BackendInformers, kubeApplierInformers *unionkubeapplierinformers.UnionKubeApplierInformers, resyncDuration time.Duration, syncer SystemAdminCredentialRequestSyncer, ) Controller
NewSystemAdminCredentialRequestWatchingController creates a controller that fires on individual SystemAdminCredentialRequest informer events rather than cluster-level events. This ensures controllers react immediately when a credential request is created or updated, instead of relying on periodic cluster resync.
kubeApplierInformers is optional: when non-nil, the controller also enqueues on ReadDesire events from the union kube-applier informer surface (the same pattern as ClusterWatchingController, but walking up to the credential request resource type instead of the cluster type).
func NewSystemAdminCredentialRevocationWatchingController ¶
func NewSystemAdminCredentialRevocationWatchingController( name string, resourcesDBClient corecosmosstorage.ResourcesDBClient, backendInformers coreinformers.BackendInformers, kubeApplierInformers *unionkubeapplierinformers.UnionKubeApplierInformers, resyncDuration time.Duration, syncer SystemAdminCredentialRevocationSyncer, ) Controller
NewSystemAdminCredentialRevocationWatchingController creates a controller that fires on individual SystemAdminCredentialRevocation informer events. Each revocation drives its own lifecycle (marking credential requests for deletion, managing the CRR desires, and final teardown), so keying on the revocation lets a small set of focused controllers react immediately to revocation changes and re-poll on resync.
type ExternalAuthSyncer ¶
type ExternalAuthSyncer interface {
SyncOnce(ctx context.Context, keyObj HCPExternalAuthKey) error
}
type HCPClusterKey ¶
type HCPClusterKey struct {
SubscriptionID string `json:"subscriptionID"`
ResourceGroupName string `json:"resourceGroupName"`
HCPClusterName string `json:"hcpClusterName"`
}
HCPClusterKey is for driving workqueues keyed for clusters
func (HCPClusterKey) AddLoggerValues ¶
func (k HCPClusterKey) AddLoggerValues(logger logr.Logger) logr.Logger
func (HCPClusterKey) GetResourceID ¶
func (k HCPClusterKey) GetResourceID() *azcorearm.ResourceID
func (HCPClusterKey) InitialController ¶
func (k HCPClusterKey) InitialController(controllerName string) *coreapi.Controller
type HCPExternalAuthKey ¶
type HCPExternalAuthKey struct {
SubscriptionID string `json:"subscriptionID"`
ResourceGroupName string `json:"resourceGroupName"`
HCPClusterName string `json:"hcpClusterName"`
HCPExternalAuthName string `json:"hcpExternalAuthName"`
}
func (*HCPExternalAuthKey) AddLoggerValues ¶
func (k *HCPExternalAuthKey) AddLoggerValues(logger logr.Logger) logr.Logger
func (*HCPExternalAuthKey) GetResourceID ¶
func (k *HCPExternalAuthKey) GetResourceID() *azcorearm.ResourceID
func (*HCPExternalAuthKey) InitialController ¶
func (k *HCPExternalAuthKey) InitialController(controllerName string) *coreapi.Controller
type HCPNodePoolKey ¶
type HCPNodePoolKey struct {
SubscriptionID string `json:"subscriptionID"`
ResourceGroupName string `json:"resourceGroupName"`
HCPClusterName string `json:"hcpClusterName"`
HCPNodePoolName string `json:"hcpNodePoolName"`
}
HCPNodePoolKey is for driving workqueus keyed for nodepools
func (HCPNodePoolKey) AddLoggerValues ¶
func (k HCPNodePoolKey) AddLoggerValues(logger logr.Logger) logr.Logger
func (HCPNodePoolKey) GetResourceID ¶
func (k HCPNodePoolKey) GetResourceID() *azcorearm.ResourceID
func (HCPNodePoolKey) InitialController ¶
func (k HCPNodePoolKey) InitialController(controllerName string) *coreapi.Controller
type InitialControllerFunc ¶
type InitialControllerFunc func(controllerName string) *coreapi.Controller
InitialControllerFunc builds a new coreapi.Controller for the given logical controller name (for example HCPClusterKey.InitialController).
type ManagementClusterKey ¶
type ManagementClusterKey struct {
StampIdentifier string `json:"stampIdentifier"`
}
func (ManagementClusterKey) AddLoggerValues ¶
func (k ManagementClusterKey) AddLoggerValues(logger logr.Logger) logr.Logger
func (ManagementClusterKey) GetResourceID ¶
func (k ManagementClusterKey) GetResourceID() *azcorearm.ResourceID
func (ManagementClusterKey) InitialController ¶
func (k ManagementClusterKey) InitialController(controllerName string) *coreapi.Controller
type ManagementClusterSyncer ¶
type ManagementClusterSyncer interface {
SyncOnce(ctx context.Context, key ManagementClusterKey) error
CooldownChecker() controllerutil.CooldownChecker
}
type NodePoolSyncer ¶
type NodePoolSyncer interface {
SyncOnce(ctx context.Context, keyObj HCPNodePoolKey) error
}
type Notifier ¶
type Notifier = controllerutil.Notifier
Type aliases re-export types from internal/controllerutils so that existing backend callers continue to compile without import changes.
type OperationKey ¶
type OperationKey struct {
SubscriptionID string `json:"subscriptionID"`
OperationName string `json:"operationName"`
ParentResourceID string `json:"parentResourceID"`
}
OperationKey is for driving workqueues keyed for operations
func (OperationKey) AddLoggerValues ¶
func (k OperationKey) AddLoggerValues(logger logr.Logger) logr.Logger
func (OperationKey) GetParentResourceID ¶
func (k OperationKey) GetParentResourceID() *azcorearm.ResourceID
func (OperationKey) InitialController ¶
func (k OperationKey) InitialController(controllerName string) *coreapi.Controller
type OperationSynchronizer ¶
type SubscriptionKey ¶
type SubscriptionKey struct {
SubscriptionID string `json:"subscriptionID"`
}
SubscriptionKey is for driving workqueues keyed for subscriptions
func (SubscriptionKey) AddLoggerValues ¶
func (k SubscriptionKey) AddLoggerValues(logger logr.Logger) logr.Logger
func (SubscriptionKey) GetResourceID ¶
func (k SubscriptionKey) GetResourceID() *azcorearm.ResourceID
type SubscriptionSyncer ¶
type SubscriptionSyncer interface {
SyncOnce(ctx context.Context, keyObj SubscriptionKey) error
CooldownChecker() controllerutil.CooldownChecker
}
type SystemAdminCredentialRequestKey ¶
type SystemAdminCredentialRequestKey struct {
SubscriptionID string `json:"subscriptionID"`
ResourceGroupName string `json:"resourceGroupName"`
HCPClusterName string `json:"hcpClusterName"`
CredentialName string `json:"credentialName"`
}
SystemAdminCredentialRequestKey is for driving workqueues keyed for credential requests
func (SystemAdminCredentialRequestKey) AddLoggerValues ¶
func (k SystemAdminCredentialRequestKey) AddLoggerValues(logger logr.Logger) logr.Logger
func (SystemAdminCredentialRequestKey) GetClusterResourceID ¶
func (k SystemAdminCredentialRequestKey) GetClusterResourceID() *azcorearm.ResourceID
func (SystemAdminCredentialRequestKey) GetResourceID ¶
func (k SystemAdminCredentialRequestKey) GetResourceID() *azcorearm.ResourceID
func (SystemAdminCredentialRequestKey) InitialController ¶
func (k SystemAdminCredentialRequestKey) InitialController(controllerName string) *coreapi.Controller
type SystemAdminCredentialRequestSyncer ¶
type SystemAdminCredentialRequestSyncer interface {
SyncOnce(ctx context.Context, keyObj SystemAdminCredentialRequestKey) error
}
SystemAdminCredentialRequestSyncer is the interface that credential-request-watching controllers must implement. It mirrors ClusterSyncer but is keyed on SystemAdminCredentialRequestKey.
type SystemAdminCredentialRevocationKey ¶
type SystemAdminCredentialRevocationKey struct {
SubscriptionID string `json:"subscriptionID"`
ResourceGroupName string `json:"resourceGroupName"`
HCPClusterName string `json:"hcpClusterName"`
RevocationName string `json:"revocationName"`
}
SystemAdminCredentialRevocationKey is for driving workqueues keyed for revocations
func (SystemAdminCredentialRevocationKey) AddLoggerValues ¶
func (k SystemAdminCredentialRevocationKey) AddLoggerValues(logger logr.Logger) logr.Logger
func (SystemAdminCredentialRevocationKey) GetClusterResourceID ¶
func (k SystemAdminCredentialRevocationKey) GetClusterResourceID() *azcorearm.ResourceID
func (SystemAdminCredentialRevocationKey) GetResourceID ¶
func (k SystemAdminCredentialRevocationKey) GetResourceID() *azcorearm.ResourceID
func (SystemAdminCredentialRevocationKey) InitialController ¶
func (k SystemAdminCredentialRevocationKey) InitialController(controllerName string) *coreapi.Controller
type SystemAdminCredentialRevocationSyncer ¶
type SystemAdminCredentialRevocationSyncer interface {
SyncOnce(ctx context.Context, keyObj SystemAdminCredentialRevocationKey) error
}
SystemAdminCredentialRevocationSyncer is the interface that revocation-watching controllers must implement. It mirrors ClusterSyncer but is keyed on SystemAdminCredentialRevocationKey.
Source Files
¶
- cluster_watching_controller.go
- controller_metrics.go
- cooldown.go
- cosmos.go
- cs_maestro_utils.go
- external_auth_watching_controller.go
- generic_operation.go
- generic_watching_controller.go
- management_cluster_content_controller.go
- management_cluster_watching_controller.go
- nodepool_watching_controller.go
- subscription_watching_controller.go
- system_admin_credential_request_watching_controller.go
- system_admin_credential_revocation_watching_controller.go
- util.go