Skip to content

Commit

Permalink
fix syncer requeue
Browse files Browse the repository at this point in the history
  • Loading branch information
panshuai111 committed Jan 10, 2024
1 parent 27e91d6 commit 0cb0016
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ func (s *ResourceSyncer) processNextWorkItem(ctx context.Context) bool {
}

if err := s.sync(ctx, key); err != nil {
s.queue.AddRateLimited(key)
return fmt.Errorf("error syncing '%s/%s': %s, requeuing", s.source.SyncRule().Resource, key, err.Error())
s.queue.AddAfter(key, 5*time.Second)
return errors.Wrapf(err, "error syncing '%s/%s', requeuing", s.source.SyncRule().Resource, key)
}

s.queue.Forget(obj)
Expand Down Expand Up @@ -235,7 +235,11 @@ func (s *ResourceSyncer) sync(ctx context.Context, key string) error {
err = s.storage.Save(ctx, cluster, obj)
}
if err != nil {
return err
op := "save"
if isDeleted {
op = "delete"
}
return errors.Wrapf(err, "failed to %s from storage", op)
}

// obj was successfully processed, remove it from cache
Expand Down

0 comments on commit 0cb0016

Please sign in to comment.