Skip to content

Commit

Permalink
fix: ignored conflicts and watch updates (#1472)
Browse files Browse the repository at this point in the history
- Reset the retry backoff when syncing is skipped due to
  prior successful sync and there are no conflicts or watch updates.
  This ensures the retry event will still fire to check for new
  conflicts and watch update requests from the remediator.
- Add logging with more details for debugging, but at level 3, to
  avoid spamming customer logs.
  • Loading branch information
karlkfi authored Nov 1, 2024
1 parent ba11b47 commit 24d9f4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions pkg/parse/event_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ func (s *EventHandler) Handle(event events.Event) events.Result {
} else if opts.needToUpdateWatch() {
trigger = triggerWatchUpdate
} else {
// No RunFunc call
// Skip RunFunc and reset the backoff to keep checking for conflicts & watch updates.
klog.V(3).Info("Sync retry skipped; resetting retry backoff")
eventResult.ResetRetryBackoff = true
break
}

Expand All @@ -139,7 +141,11 @@ func (s *EventHandler) Handle(event events.Event) events.Result {
}

// If the run succeeded or source changed, reset the retry backoff.
if runResult.Success || runResult.SourceChanged {
if runResult.Success {
klog.V(3).Info("Sync attempt succeeded; resetting retry backoff")
eventResult.ResetRetryBackoff = true
} else if runResult.SourceChanged {
klog.V(3).Info("Source change detected; resetting retry backoff")
eventResult.ResetRetryBackoff = true
}
return eventResult
Expand Down
2 changes: 1 addition & 1 deletion pkg/parse/events/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (s *RetrySyncPublisher) Publish(subscriber Subscriber) Result {

retryDuration := s.currentBackoff.Step()
retries := s.retryLimit - s.currentBackoff.Steps
klog.Infof("a retry is triggered (retries: %v/%v)", retries, s.retryLimit)
klog.V(3).Infof("Sending retry event (step: %v/%v)", retries, s.retryLimit)

result := subscriber.Handle(Event{Type: s.EventType})

Expand Down

0 comments on commit 24d9f4e

Please sign in to comment.