Skip to content

Commit acb9328

Browse files
committed
Initial Commit: Infinite Requeue
1 parent 8191f60 commit acb9328

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

pkg/errors/error.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ var (
4949
// after some wait time
5050
TemporaryOutOfSync = fmt.Errorf(
5151
"temporary out of sync, reconcile after some time")
52+
// TemporaryOutOfSync is to indicate the error isn't really an error
53+
// but more of a marker that the status check will be performed
54+
// after some wait time
55+
RequeueOnSuccess = fmt.Errorf(
56+
"resource creation successful but reconcile after some time")
5257
// Terminal is returned with resource is in Terminal Condition
5358
Terminal = fmt.Errorf(
5459
"resource is in terminal condition")

pkg/requeue/requeue.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ const (
2121
DefaultRequeueAfterDuration time.Duration = 30 * time.Second
2222
)
2323

24+
// GetDurationInSeconds converts an integer into a time duration in seconds
25+
func GetDurationInSeconds(duration int) time.Duration {
26+
return time.Duration(duration) * time.Second
27+
}
28+
2429
// Needed returns a new RequeueNeeded to instruct the ACK runtime to requeue
2530
// the processing item without been logged as error.
2631
func Needed(err error) *RequeueNeeded {

pkg/runtime/reconciler.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,17 @@ func (r *resourceReconciler) Sync(
271271
return err
272272
}
273273
for _, condition := range latest.Conditions() {
274-
if condition.Type == ackv1alpha1.ConditionTypeResourceSynced &&
275-
condition.Status != corev1.ConditionTrue {
276-
return requeue.NeededAfter(
277-
ackerr.TemporaryOutOfSync, requeue.DefaultRequeueAfterDuration)
274+
if condition.Type == ackv1alpha1.ConditionTypeResourceSynced {
275+
if condition.Status == corev1.ConditionTrue {
276+
duration, status := r.rmf.GetRequeueOnSuccessSeconds()
277+
if status {
278+
return requeue.NeededAfter(
279+
ackerr.RequeueOnSuccess, requeue.GetDurationInSeconds(duration))
280+
}
281+
} else {
282+
return requeue.NeededAfter(
283+
ackerr.TemporaryOutOfSync, requeue.DefaultRequeueAfterDuration)
284+
}
278285
}
279286
}
280287
return nil

pkg/types/aws_resource_manager.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,7 @@ type AWSResourceManagerFactory interface {
8989
) (AWSResourceManager, error)
9090
// IsAdoptable returns true if the resource is able to be adopted
9191
IsAdoptable() bool
92+
// GetRequeueOnSuccessSeconds returns true if the resource should be requeued after specified seconds
93+
// Default is false which means resource will not be requeued after success.
94+
GetRequeueOnSuccessSeconds() (int, bool)
9295
}

0 commit comments

Comments
 (0)