Skip to content

Commit

Permalink
added logLevel check
Browse files Browse the repository at this point in the history
  • Loading branch information
Ran Vaknin committed Jan 3, 2024
1 parent 394d04f commit 3ae0e3f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion aws/ec2metadata/token_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ec2metadata

import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"net/http"
"sync/atomic"
"time"
Expand Down Expand Up @@ -65,7 +66,9 @@ func (t *tokenProvider) fetchTokenHandler(r *request.Request) {
switch requestFailureError.StatusCode() {
case http.StatusForbidden, http.StatusNotFound, http.StatusMethodNotAllowed:
atomic.StoreUint32(&t.disabled, 1)
t.client.Config.Logger.Log(fmt.Sprintf("WARN: failed to get session token, falling back to IMDSv1: %v", requestFailureError))
if t.client.Config.LogLevel.Matches(aws.LogDebugWithDeprecated) {
t.client.Config.Logger.Log(fmt.Sprintf("WARN: failed to get session token, falling back to IMDSv1: %v", requestFailureError))
}
case http.StatusBadRequest:
r.Error = requestFailureError
}
Expand Down

0 comments on commit 3ae0e3f

Please sign in to comment.