diff --git a/pkg/runtime/reconciler.go b/pkg/runtime/reconciler.go index 535f897..4a1d886 100644 --- a/pkg/runtime/reconciler.go +++ b/pkg/runtime/reconciler.go @@ -15,7 +15,8 @@ package runtime import ( "context" - + "time" + "github.com/go-logr/logr" "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" @@ -279,15 +280,21 @@ func (r *resourceReconciler) Sync( return err } for _, condition := range latest.Conditions() { - if condition.Type == ackv1alpha1.ConditionTypeResourceSynced && - condition.Status != corev1.ConditionTrue { - rlog.Debug( - "requeueing resource after finding resource synced condition false", - ) - return requeue.NeededAfter( - ackerr.TemporaryOutOfSync, - requeue.DefaultRequeueAfterDuration, - ) + if condition.Type == ackv1alpha1.ConditionTypeResourceSynced { + if condition.Status == corev1.ConditionTrue { + if duration := r.rmf.RequeueOnSuccessSeconds(); duration > 0 { + rlog.Debug( + "requeueing resource after resource synced condition true", + ) + return requeue.NeededAfter(nil, time.Duration(duration)*time.Second) + } + } else { + rlog.Debug( + "requeueing resource after finding resource synced condition false", + ) + return requeue.NeededAfter( + ackerr.TemporaryOutOfSync, requeue.DefaultRequeueAfterDuration) + } } } return nil diff --git a/pkg/types/aws_resource_manager.go b/pkg/types/aws_resource_manager.go index d284741..620d810 100644 --- a/pkg/types/aws_resource_manager.go +++ b/pkg/types/aws_resource_manager.go @@ -70,6 +70,7 @@ type AWSResourceManager interface { // AWSResourceManagerFactory returns an AWSResourceManager that can be used to // manage AWS resources for a particular AWS account +// TODO(jaypipes): Move AWSResourceManagerFactory into its own file type AWSResourceManagerFactory interface { // ResourceDescriptor returns an AWSResourceDescriptor that can be used by // the upstream controller-runtime to introspect the CRs that the resource @@ -89,4 +90,7 @@ type AWSResourceManagerFactory interface { ) (AWSResourceManager, error) // IsAdoptable returns true if the resource is able to be adopted IsAdoptable() bool + // RequeueOnSuccessSeconds returns true if the resource should be requeued after specified seconds + // Default is false which means resource will not be requeued after success. + RequeueOnSuccessSeconds() int }