Skip to content

Commit

Permalink
If IMDSV2 Fails Log fmt.Printf Not log.Printf
Browse files Browse the repository at this point in the history
  • Loading branch information
sethAmazon committed Oct 4, 2023
1 parent 11de82c commit 34d9b7e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions internal/retryer/imdsretryer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package retryer

import (
"fmt"
"log"
"os"
"strconv"

Expand Down Expand Up @@ -44,7 +43,7 @@ func (r IMDSRetryer) ShouldRetry(req *request.Request) bool {
if awsError, ok := req.Error.(awserr.Error); r.DefaultRetryer.ShouldRetry(req) || (ok && awsError != nil && awsError.Code() == "EC2MetadataError") {
shouldRetry = true
}
log.Printf("D! should retry %t for imds error : %v", shouldRetry, req.Error)
fmt.Printf("D! should retry %t for imds error : %v", shouldRetry, req.Error)
return shouldRetry
}

Expand Down
5 changes: 2 additions & 3 deletions translator/util/ec2util/ec2util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package ec2util

import (
"fmt"
"log"
"net"
"sync"
"time"
Expand Down Expand Up @@ -113,7 +112,7 @@ func (e *ec2Util) deriveEC2MetadataFromIMDS() error {
if hostname, err := mdDisableFallback.GetMetadata("hostname"); err == nil {
e.Hostname = hostname
} else {
log.Printf("D! could not get hostname without imds v1 fallback enable thus enable fallback")
fmt.Println("D! could not get hostname without imds v1 fallback enable thus enable fallback")
hostnameInner, errInner := mdEnableFallback.GetMetadata("hostname")
if errInner == nil {
e.Hostname = hostnameInner
Expand All @@ -130,7 +129,7 @@ func (e *ec2Util) deriveEC2MetadataFromIMDS() error {
e.PrivateIP = instanceIdentityDocument.PrivateIP
e.InstanceID = instanceIdentityDocument.InstanceID
} else {
log.Printf("D! could not get instance document without imds v1 fallback enable thus enable fallback")
fmt.Println("D! could not get instance document without imds v1 fallback enable thus enable fallback")
instanceIdentityDocumentInner, errInner := mdEnableFallback.GetInstanceIdentityDocument()
if errInner == nil {
e.Region = instanceIdentityDocumentInner.Region
Expand Down

0 comments on commit 34d9b7e

Please sign in to comment.