Documentation
¶
Index ¶
- Variables
- func DeleteRecursively(ctx context.Context, cosmosClient database.DBClient, ...) error
- func GetCondition(conditions []api.Condition, conditionType string) *api.Condition
- func GetOrCreateServiceProviderCluster(ctx context.Context, dbClient database.DBClient, ...) (*api.ServiceProviderCluster, error)
- func GetOrCreateServiceProviderNodePool(ctx context.Context, dbClient database.DBClient, ...) (*api.ServiceProviderNodePool, error)
- func IsConditionTrue(conditions []api.Condition, conditionType string) bool
- func MarkBillingDocumentDeleted(ctx context.Context, cosmosClient database.DBClient, ...) error
- func ReportSyncError(syncErr error) controllerMutationFunc
- func SetCondition(conditions *[]api.Condition, toSet api.Condition)
- func WriteController(ctx context.Context, controllerCRUD database.ResourceCRUD[api.Controller], ...) error
- type ActiveOperationBasedChecker
- type ClusterSyncer
- type Controller
- type CooldownChecker
- type HCPClusterKey
- type OperationKey
- type TimeBasedCooldownChecker
Constants ¶
This section is empty.
Variables ¶
var ( // ReconcileTotal counts the total number of reconciliations per controller. ReconcileTotal = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "backend_controller_reconcile_total", Help: "Total number of reconciliations per controller.", }, []string{"controller"}, ) )
Functions ¶
func DeleteRecursively ¶
func GetCondition ¶
GetCondition returns a copy to the condition with the given type from the list of conditions. It returns a pointer for a clear indication of "not found", it doesn't return a reference intended for mutation of the original list. If the list of conditions is nil, returns nil. If the condition with condition type conditionType is not found, returns nil. If there are multiple conditions with condition type conditionType the first one is returned.
func GetOrCreateServiceProviderCluster ¶
func GetOrCreateServiceProviderCluster( ctx context.Context, dbClient database.DBClient, clusterResourceID *azcorearm.ResourceID, ) (*api.ServiceProviderCluster, error)
GetOrCreateServiceProviderCluster gets the singleton ServiceProviderCluster instance named `default` for the given cluster resource ID. If it doesn't exist, it creates a new one.
func GetOrCreateServiceProviderNodePool ¶
func GetOrCreateServiceProviderNodePool( ctx context.Context, dbClient database.DBClient, nodePoolResourceID *azcorearm.ResourceID, ) (*api.ServiceProviderNodePool, error)
GetOrCreateServiceProviderNodePool gets the singleton ServiceProviderNodePool instance named `default` for the given node pool resource ID. If it doesn't exist, it creates a new one.
func IsConditionTrue ¶
IsConditionTrue returns true if the condition with condition type conditionType is found and its status is True. If the condition is not found or its status is not True, returns false.
func MarkBillingDocumentDeleted ¶
func MarkBillingDocumentDeleted(ctx context.Context, cosmosClient database.DBClient, clusterResourceID *azcorearm.ResourceID, deletionTime time.Time) error
MarkBillingDocumentDeleted patches a Cosmos DB document in the Billing container to add a deletion timestamp.
func ReportSyncError ¶
func ReportSyncError(syncErr error) controllerMutationFunc
func SetCondition ¶
SetCondition sets the condition with the given type in the list of conditions. If the condition with condition type conditionType is not found, it is added. If the condition with condition type conditionType is found, it is updated. When there's a transition in the condition's status, the last transition time is updated to the current time. lastTranitionTime in toSet is always ignored.
func WriteController ¶
func WriteController(ctx context.Context, controllerCRUD database.ResourceCRUD[api.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 listers.ActiveOperationLister) *ActiveOperationBasedChecker
func NewActiveOperationPrioritizingCooldown ¶
func NewActiveOperationPrioritizingCooldown(activeOperationLister listers.ActiveOperationLister, activeOperationCooldown, inactiveOperationCooldown time.Duration) *ActiveOperationBasedChecker
type ClusterSyncer ¶
type ClusterSyncer interface {
SyncOnce(ctx context.Context, keyObj HCPClusterKey) error
CooldownChecker() CooldownChecker
}
type Controller ¶
type Controller interface {
SyncOnce(ctx context.Context, keyObj any) error
Run(ctx context.Context, threadiness int)
}
func NewClusterWatchingController ¶
func NewClusterWatchingController( name string, cosmosClient database.DBClient, informers informers.BackendInformers, 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.
type CooldownChecker ¶
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) *api.Controller
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) *api.Controller
type TimeBasedCooldownChecker ¶
type TimeBasedCooldownChecker struct {
// contains filtered or unexported fields
}
func NewTimeBasedCooldownChecker ¶
func NewTimeBasedCooldownChecker(cooldownDuration time.Duration) *TimeBasedCooldownChecker