Documentation
¶
Index ¶
Constants ¶
const ( ConfigControllerName = "UsageConfigController" EventActionReconcile = "Reconcile" EventReasonWatchStarted = "WatchStarted" EventReasonWatchStopped = "WatchStopped" )
const (
GarbageCollectorName = "GarbageCollector"
)
const (
NamespaceControllerName = "NamespaceController"
)
const (
TrackedResourceControllerName = "TrackedResource"
)
Variables ¶
This section is empty.
Functions ¶
func RequeueAtTrackingPeriodEnd ¶ added in v1.0.0
func RequeueAtTrackingPeriodEnd(usage *usagev1alpha1.ResourceUsage) reconcile.Result
RequeueAtTrackingPeriodEnd returns a reconcile.Result that will requeue the reconciliation at the end of the tracking period of the given ResourceUsage object. If the ResourceUsage is nil, or its tracking period has no end time, or the end time is in the past, it returns an empty reconcile.Result (no requeue). An offset of one second is added to the requeue time to ensure that the tracking period has ended when the next reconciliation is triggered.
Types ¶
type ConfigController ¶ added in v1.0.0
type ConfigController struct {
PlatformCluster *clusters.Cluster
OnboardingCluster *clusters.Cluster
ProviderName string
// contains filtered or unexported fields
}
func NewConfigController ¶ added in v1.0.0
func NewConfigController(platformCluster, onboardingCluster *clusters.Cluster, providerName string, er events.EventRecorder) *ConfigController
func (*ConfigController) SetupWithManager ¶ added in v1.0.0
func (c *ConfigController) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type GarbageCollector ¶ added in v1.0.0
type GarbageCollector struct {
OnboardingCluster *clusters.Cluster
// contains filtered or unexported fields
}
GarbageCollector runs periodically and checks for ResourceUsage objects that should be deleted according to the configured garbage collection policy.
func NewGarbageCollector ¶ added in v1.0.0
func NewGarbageCollector(onboardingCluster *clusters.Cluster) *GarbageCollector
func (*GarbageCollector) CollectGarbage ¶ added in v1.0.0
func (c *GarbageCollector) CollectGarbage(ctx context.Context, now time.Time)
CollectGarbage runs the garbage collection process. It checks for ResourceUsage objects which are completed and obsolete (according to the garbage collection config) and deletes them. Errors are simply logged, as the garbage collection will be retried on the next run. The 'now' argument is mainly for testing, it should always be set to time.Now() in production code.
func (*GarbageCollector) GetTrigger ¶ added in v1.0.0
func (c *GarbageCollector) GetTrigger() chan struct{}
GetTrigger returns the channel that triggers the garbage collector to check for a new configuration, potentially triggering a garbage collection run. Mainly exposed for testing purposes, should not required to be called in production code, as the garbage collector will inject this into the shared information on startup.
type NamespaceController ¶ added in v1.0.0
NamespaceController is a small controller that watches namespaces and triggers reconciliations for tracked resources within a changed namespace (if changes to the namespace could be relevant for the tracked resources).
func NewNamespaceController ¶ added in v1.0.0
func NewNamespaceController(onboardingCluster *clusters.Cluster) *NamespaceController
func (*NamespaceController) SetupWithManager ¶ added in v1.0.0
func (c *NamespaceController) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type TrackedResourceController ¶ added in v1.0.0
type TrackedResourceController struct {
OnboardingCluster *clusters.Cluster
// contains filtered or unexported fields
}
func NewTrackedResourceController ¶ added in v1.0.0
func NewTrackedResourceController(onboardingCluster *clusters.Cluster) *TrackedResourceController
func (*TrackedResourceController) Reconcile ¶ added in v1.0.0
func (c *TrackedResourceController) Reconcile(ctx context.Context, req TypedRequest) (reconcile.Result, error)
func (*TrackedResourceController) SetupWithManager ¶ added in v1.0.0
func (c *TrackedResourceController) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the given manager. As a side effect, this also registers the manual reconciliation trigger and the function to start informers for specific GVKs in the shared information instance.
func (*TrackedResourceController) StartupReconciliation ¶ added in v1.0.0
func (c *TrackedResourceController) StartupReconciliation(ctx context.Context) error
StartupReconciliation is meant to trigger a reconciliation for all resources with non-completed ResourceUsage objects at the startup of the operator. This includes especially those, which are not watched anymore due to a config change. Their corresponding ResourceUsage objects would otherwise never be completed. Note that this function IS NOT MEANT TO BE CALLED MANUALLY. Instead, it should be passed into mgr.Add(manager.RunnableFunc(<here>)) to be executed at the startup of the operator. The controller's SetupWithManager function must be called before this function, so that the manual reconciliation trigger is set up in the shared information instance.
type TypedRequest ¶ added in v1.0.0
type TypedRequest struct {
types.NamespacedName
schema.GroupVersionKind
}
TypedRequest is like reconcile.Request, but includes the GVK of the resource being reconciled.