Documentation
¶
Index ¶
- func DeleteResource[orcObjectPT interface{ ... }, orcObjectT any, resourceSpecT any, filterT any, ...](ctx context.Context, log logr.Logger, controller ResourceController, ...) (bool, *osResourceT, progress.ReconcileStatus)
- func GetOrCreateOSResource[orcObjectPT interface{ ... }, orcObjectT any, resourceSpecT any, filterT any, ...](ctx context.Context, log logr.Logger, controller ResourceController, ...) (*osResourceT, progress.ReconcileStatus)
- func ShouldReconcile(obj orcv1alpha1.ObjectWithConditions, lastSyncTime *metav1.Time, ...) bool
- type Controller
- type ResourceController
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteResource ¶
func DeleteResource[
orcObjectPT interface {
*orcObjectT
client.Object
orcv1alpha1.ObjectWithConditions
}, orcObjectT any,
resourceSpecT any, filterT any,
osResourceT any,
](
ctx context.Context, log logr.Logger, controller ResourceController,
objAdapter interfaces.APIObjectAdapter[orcObjectPT, resourceSpecT, filterT],
actuator interfaces.DeleteResourceActuator[orcObjectPT, orcObjectT, osResourceT],
) (bool, *osResourceT, progress.ReconcileStatus)
func GetOrCreateOSResource ¶
func GetOrCreateOSResource[
orcObjectPT interface {
*orcObjectT
client.Object
orcv1alpha1.ObjectWithConditions
}, orcObjectT any,
resourceSpecT any, filterT any,
osResourceT any,
](
ctx context.Context, log logr.Logger, controller ResourceController,
objAdapter interfaces.APIObjectAdapter[orcObjectPT, resourceSpecT, filterT],
actuator interfaces.CreateResourceActuator[orcObjectPT, orcObjectT, filterT, osResourceT],
) (*osResourceT, progress.ReconcileStatus)
func ShouldReconcile ¶
func ShouldReconcile(obj orcv1alpha1.ObjectWithConditions, lastSyncTime *metav1.Time, resyncPeriod time.Duration) bool
ShouldReconcile filters events when the object status is up to date, and its status indicates that no further reconciliation is required.
Specifically it looks at the Progressing condition. It has the following behaviour: - Progressing condition is not present -> reconcile - Progressing condition is present and True -> reconcile - Progressing condition is present and False, but observedGeneration is old -> reconcile - Progressing condition is false and observedGeneration is up to date -> do not reconcile
If resyncPeriod > 0, periodic resync is also considered:
- If lastSyncTime is nil (never synced), reconcile immediately.
- If time.Since(lastSyncTime) >= resyncPeriod, a resync is due: reconcile.
- If time.Since(lastSyncTime) < resyncPeriod, the next resync is not yet due: do not reconcile (unless condition-based logic above requires it).
When resyncPeriod <= 0 (disabled), resync logic is not applied and the existing condition-based behaviour is unchanged.
The resync check uses the persisted lastSyncTime so that controller restarts respect the time already elapsed, preventing a thundering herd.
If ShouldReconcile is preventing an object from being reconciled which should be reconciled, consider if that object's actuator is correctly returning a ProgressStatus indicating that the reconciliation should continue.
Types ¶
type Controller ¶
type Controller[
orcObjectPT interface {
*orcObjectT
client.Object
orcv1alpha1.ObjectWithConditions
},
orcObjectT any,
resourceSpecT any,
filterT any,
objectApplyPT interfaces.ORCApplyConfig[objectApplyPT, statusApplyPT],
statusApplyPT interface {
*statusApplyT
interfaces.ORCStatusApplyConfigWithID[statusApplyPT]
},
statusApplyT any,
osResourceT any,
] struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController[
orcObjectPT interface {
*orcObjectT
client.Object
orcv1alpha1.ObjectWithConditions
}, orcObjectT any,
resourceSpecT any, filterT any,
objectApplyPT interfaces.ORCApplyConfig[objectApplyPT, statusApplyPT],
statusApplyPT interface {
*statusApplyT
interfaces.ORCStatusApplyConfigWithID[statusApplyPT]
}, statusApplyT any,
osResourceT any,
](
name string, k8sClient client.Client, scopeFactory scope.Factory,
helperFactory interfaces.ResourceHelperFactory[orcObjectPT, orcObjectT, resourceSpecT, filterT, osResourceT],
statusWriter interfaces.ResourceStatusWriter[orcObjectPT, *osResourceT, objectApplyPT, statusApplyPT],
defaultResyncPeriod time.Duration,
) Controller[orcObjectPT, orcObjectT, resourceSpecT, filterT, objectApplyPT, statusApplyPT, statusApplyT, osResourceT]
func (*Controller[_, _, _, _, _, _, _, _]) GetK8sClient ¶
func (c *Controller[_, _, _, _, _, _, _, _]) GetK8sClient() client.Client
func (*Controller[_, _, _, _, _, _, _, _]) GetName ¶
func (c *Controller[_, _, _, _, _, _, _, _]) GetName() string
func (*Controller[_, _, _, _, _, _, _, _]) GetScopeFactory ¶
func (c *Controller[_, _, _, _, _, _, _, _]) GetScopeFactory() scope.Factory