Skip to content

Commit

Permalink
feat: longer poll interval if resource is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
renato0307 committed Mar 19, 2024
1 parent 991de68 commit a188a03
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/reconciler/managed/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"strings"
"time"

v1 "k8s.io/api/core/v1"
kerrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
Expand Down Expand Up @@ -549,7 +550,11 @@ func WithPollInterval(after time.Duration) ReconcilerOption {
// interval.
type PollIntervalHook func(managed resource.Managed, pollInterval time.Duration) time.Duration

func defaultPollIntervalHook(_ resource.Managed, pollInterval time.Duration) time.Duration {
func defaultPollIntervalHook(managed resource.Managed, pollInterval time.Duration) time.Duration {
if managed.GetCondition(xpv1.TypeSynced).Status == v1.ConditionTrue && managed.GetCondition(xpv1.TypeReady).Status == v1.ConditionTrue {
jitter := 30 * time.Minute
return time.Hour + time.Duration((rand.Float64()-0.5)*2*float64(jitter))
}
return pollInterval
}

Expand Down

0 comments on commit a188a03

Please sign in to comment.