Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Fix token cache issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pmahindrakar-oss committed May 22, 2024
1 parent 131d6a2 commit e7479c0
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions pkg/pkce/token_cache_keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"sync"

"github.com/flyteorg/flyte/flyteidl/clients/go/admin/cache"
"github.com/flyteorg/flyte/flytestdlib/logger"
"github.com/zalando/go-keyring"
"golang.org/x/oauth2"
Expand All @@ -29,11 +28,8 @@ func (t *TokenCacheKeyringProvider) PurgeIfEquals(existing *oauth2.Token) (bool,
if existingBytes, err := json.Marshal(existing); err != nil {
return false, fmt.Errorf("unable to marshal token to save in cache due to %w", err)
} else if tokenJSON, err := keyring.Get(t.ServiceName, t.ServiceUser); err != nil {
if err.Error() == "secret not found in keyring" {
return false, fmt.Errorf("unable to read token from cache. Error: %w", cache.ErrNotFound)
}

return false, fmt.Errorf("unable to read token from cache. Error: %w", err)
logger.Warnf(context.Background(), "unable to read token from cache but not failing the purge. Error: %v", err)
return true, nil
} else if tokenJSON != string(existingBytes) {
return false, nil
}
Expand Down

0 comments on commit e7479c0

Please sign in to comment.