Skip to content

Commit

Permalink
avoid logging an error if synch is already running (#47)
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Ilario <[email protected]>
  • Loading branch information
filariow authored Jan 31, 2025
1 parent 3a25aa9 commit 03cc933
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/auth/cache/synchronized_access_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import (

var SynchAlreadyRunningErr error = errors.New("Synch operation already running")

func isSynchAlreadyRunningErr(err error) bool {
return err != nil && errors.Is(err, SynchAlreadyRunningErr)
}

// applies changes to cache async
type SynchronizedAccessCache struct {
*AccessCache
Expand Down Expand Up @@ -132,7 +136,7 @@ func (s *SynchronizedAccessCache) Start(ctx context.Context) {
case <-s.request:
// a new request is present
s.logger.Debug("start requested cache synchronization")
if err := s.Synch(ctx); err != nil {
if err := s.Synch(ctx); isSynchAlreadyRunningErr(err) {
s.syncErrorHandler(ctx, err, s)
}
}
Expand Down

0 comments on commit 03cc933

Please sign in to comment.