Skip to content

Commit

Permalink
Fix credential expirability check
Browse files Browse the repository at this point in the history
Fixes a bug introduced during the refactor in
e92213c, which incorrectly inverted the
previous credential expirability checking logic. This caused errors
about being unable to cache otherwise cachable credentials.

Also changes the error log around the previous expirability check site
to no longer log the error that previously came from the `ExpiresAt()`
check; since this is now the wrong `err`, it's always `nil`.

Addresses kubernetes-sigs#776
  • Loading branch information
kanwren committed Dec 4, 2024
1 parent 7739f6c commit 1502060
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/filecache/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (p *v2) Retrieve(ctx context.Context) (aws.Credentials, error) {
// Don't have account ID
}

if expiration, err := p.creds.ExpiresAt(); err != nil {
if expiration, err := p.creds.ExpiresAt(); err == nil {
resp.CanExpire = true
resp.Expires = expiration
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/filecache/filecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func (f *FileCacheProvider) RetrieveWithContext(ctx context.Context) (credential
}
} else {
// credential doesn't support expiration time, so can't cache, but still return the credential
_, _ = fmt.Fprintf(os.Stderr, "Unable to cache credential: %v\n", err)
_, _ = fmt.Fprint(os.Stderr, "Unable to cache credential: credential doesn't support expiration\n")
err = nil
}
return V2CredentialToV1Value(credential), err
Expand Down

0 comments on commit 1502060

Please sign in to comment.