Documentation
¶
Index ¶
- Constants
- Variables
- func DegradedControllerPanicHandler(ctx context.Context, ...) func(any)
- func SetRegistrationCondition(conditions *[]metav1.Condition, conditionType string, syncErr error)
- func WriteController(ctx context.Context, ...) error
- type Controller
- type ControllerMutationFunc
- type InitialControllerFunc
- type ManagementClusterKey
- type ManagementClusterSyncer
- type RegistrationAwareCooldown
- type StampKey
- type StampSyncer
- type StampWatchingControllerConfig
Constants ¶
const ( DefaultRegisteredCooldown = 5 * time.Minute DefaultUnregisteredCooldown = 10 * time.Second )
const DefaultInformerResyncPeriod = 5 * time.Minute
const DefaultStampCooldownPeriod = 10 * time.Minute
Variables ¶
var ErrStampNotApproved = errors.New("parent stamp is not approved")
var ( ReconcileTotal = promauto.With(legacyregistry.Registerer()).NewCounterVec( prometheus.CounterOpts{ Name: "fleet_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(any)
DegradedControllerPanicHandler returns a panic handler that writes a Degraded condition to the controller document with the panic stack trace.
func SetRegistrationCondition ¶
SetRegistrationCondition updates a registration condition based on the reconcile result. Once True, the condition never regresses to False — errors after a successful registration are recorded as True/CheckFailed so operators can observe the problem without losing the registration state.
When the condition already carries the target Status and Reason, the update is skipped even if the Message differs. External API errors embed per-request fields (operation IDs, timestamps) that change on every call; writing a new Message each retry would bump the Cosmos etag, trigger an informer update event, and enqueue the key via Add() — bypassing the workqueue rate limiter and creating a hot retry loop. The full error is still logged by the workqueue error handler, so no debugging information is lost.
func WriteController ¶
func WriteController(ctx context.Context, controllerCRUD cosmosstorageutils.ResourceCRUD[coreapi.Controller, *coreapi.Controller], controllerName string, initialControllerFn InitialControllerFunc, mutationFns ...ControllerMutationFunc) error
WriteController reads the existing controller document (creating it if missing), applies mutations in order, and writes back the result. It only tries once — on conflict the control loop will re-run.
Types ¶
type Controller ¶
type Controller interface {
QueueForInformers(resyncDuration time.Duration, notifiers ...controllerutils.Notifier) error
Run(ctx context.Context, threadiness int)
EnqueueAfter(keyObj any, duration time.Duration)
}
Controller is the common interface for all fleet controllers.
func NewManagementClusterWatchingController ¶
func NewManagementClusterWatchingController( name string, fleetDBClient fleetcosmosstorage.FleetDBClient, managementClusterInformer cache.SharedIndexInformer, resyncDuration time.Duration, syncer ManagementClusterSyncer, ) Controller
NewManagementClusterWatchingController creates a controller that watches management cluster informers and automatically writes a controller document under the management cluster after each sync.
func NewStampWatchingController ¶
func NewStampWatchingController( name string, syncer StampSyncer, cfg StampWatchingControllerConfig, ) Controller
NewStampWatchingController creates a controller and delegates reconciliation to the syncer. Call QueueForInformers to register informers.
type ControllerMutationFunc ¶
type ControllerMutationFunc func(controller *coreapi.Controller)
ControllerMutationFunc mutates a controller document in place. It should only perform short calls, not long lookups. It must not fail.
func ReportSyncError ¶
func ReportSyncError(syncErr error) ControllerMutationFunc
ReportSyncError returns a mutation that sets the Degraded condition based on whether a sync error occurred.
type InitialControllerFunc ¶
type InitialControllerFunc func(controllerName string) *coreapi.Controller
InitialControllerFunc builds a new coreapi.Controller for the given logical controller name.
type ManagementClusterKey ¶
type ManagementClusterKey struct {
StampIdentifier string
}
ManagementClusterKey identifies a management cluster in the workqueue.
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() controllerutils.CooldownChecker
}
ManagementClusterSyncer is the interface that concrete management cluster controllers implement.
type RegistrationAwareCooldown ¶
type RegistrationAwareCooldown struct {
// contains filtered or unexported fields
}
RegistrationAwareCooldown uses a shorter cooldown for management clusters that are not yet Ready, mirroring the backend's ActiveOperationBasedChecker pattern for clusters with active operations.
func DefaultRegistrationAwareCooldown ¶
func DefaultRegistrationAwareCooldown( managementClusterLister fleetlisters.ManagementClusterLister, ) *RegistrationAwareCooldown
func NewRegistrationAwareCooldown ¶
func NewRegistrationAwareCooldown( managementClusterLister fleetlisters.ManagementClusterLister, registeredCooldown, unregisteredCooldown time.Duration, ) *RegistrationAwareCooldown
func (*RegistrationAwareCooldown) CanSync ¶
func (c *RegistrationAwareCooldown) CanSync(ctx context.Context, key any) bool
func (*RegistrationAwareCooldown) SetClock ¶
func (c *RegistrationAwareCooldown) SetClock(clock utilsclock.PassiveClock)
type StampKey ¶
type StampKey struct {
StampIdentifier string
}
StampKey identifies a Stamp in the workqueue.
func (StampKey) GetResourceID ¶
func (k StampKey) GetResourceID() *azcorearm.ResourceID
type StampSyncer ¶
StampSyncer is the interface that concrete stamp controllers implement.
type StampWatchingControllerConfig ¶
type StampWatchingControllerConfig struct {
// Cooldown overrides the default time-based cooldown checker.
// When set, CooldownPeriod and Clock are ignored.
Cooldown controllerutils.CooldownChecker
CooldownPeriod time.Duration
Clock utilsclock.PassiveClock
}
StampWatchingControllerConfig tunes the controller's cooldown behavior.