Skip to content

Commit c40776d

Browse files
authored
Merge pull request #5131 from RanVaknin/add-logLevel-check-to-suprass-warning
Add log level check to gate IMDSv1 fallback warning
2 parents f41238a + efcc00b commit c40776d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: CHANGELOG_PENDING.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
### SDK Enhancements
44

55
### SDK Bugs
6+
* The logging behavior in `aws/ec2metadata/token_provider.go` was updated: warnings about falling back to IMDSv1 are now logged only when LogLevel is set to `LogDebugWithDeprecated`.
7+
* This change prevents unnecessary warnings when LogLevel is set to suppress messages.

Diff for: aws/ec2metadata/token_provider.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ec2metadata
22

33
import (
44
"fmt"
5+
"github.com/aws/aws-sdk-go/aws"
56
"net/http"
67
"sync/atomic"
78
"time"
@@ -65,7 +66,9 @@ func (t *tokenProvider) fetchTokenHandler(r *request.Request) {
6566
switch requestFailureError.StatusCode() {
6667
case http.StatusForbidden, http.StatusNotFound, http.StatusMethodNotAllowed:
6768
atomic.StoreUint32(&t.disabled, 1)
68-
t.client.Config.Logger.Log(fmt.Sprintf("WARN: failed to get session token, falling back to IMDSv1: %v", requestFailureError))
69+
if t.client.Config.LogLevel.Matches(aws.LogDebugWithDeprecated) {
70+
t.client.Config.Logger.Log(fmt.Sprintf("WARN: failed to get session token, falling back to IMDSv1: %v", requestFailureError))
71+
}
6972
case http.StatusBadRequest:
7073
r.Error = requestFailureError
7174
}

0 commit comments

Comments
 (0)