Skip to content

Commit

Permalink
[v11.0.x] IDFowrarding: ignore logging context canceled errors (#86187)
Browse files Browse the repository at this point in the history
IDFowrarding: ignore logging context canceled errors (#85141)

(cherry picked from commit 2f5e302)

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
  • Loading branch information
grafana-delivery-bot[bot] and kalleep committed Apr 15, 2024
1 parent 3547c55 commit 232798e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/services/auth/idimpl/service.go
Expand Up @@ -159,8 +159,10 @@ func (s *Service) hook(ctx context.Context, identity *authn.Identity, _ *authn.R
// FIXME(kalleep): we should probably lazy load this
token, err := s.SignIdentity(ctx, identity)
if err != nil {
namespace, id := identity.GetNamespacedID()
s.logger.FromContext(ctx).Error("Failed to sign id token", "err", err, "namespace", namespace, "id", id)
if shouldLogErr(err) {
namespace, id := identity.GetNamespacedID()
s.logger.FromContext(ctx).Error("Failed to sign id token", "err", err, "namespace", namespace, "id", id)
}
// for now don't return error so we don't break authentication from this hook
return nil
}
Expand All @@ -180,3 +182,7 @@ func getSubject(namespace, identifier string) string {
func prefixCacheKey(key string) string {
return fmt.Sprintf("%s-%s", cachePrefix, key)
}

func shouldLogErr(err error) bool {
return !errors.Is(err, context.Canceled)
}

0 comments on commit 232798e

Please sign in to comment.