From 34d9b7e75b4bb27d46e253d81c3b5484ed7576b9 Mon Sep 17 00:00:00 2001 From: Seth Levine Date: Wed, 4 Oct 2023 16:51:10 -0400 Subject: [PATCH] If IMDSV2 Fails Log fmt.Printf Not log.Printf --- internal/retryer/imdsretryer.go | 3 +-- translator/util/ec2util/ec2util.go | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/internal/retryer/imdsretryer.go b/internal/retryer/imdsretryer.go index d03bcba407..29dec2976f 100644 --- a/internal/retryer/imdsretryer.go +++ b/internal/retryer/imdsretryer.go @@ -5,7 +5,6 @@ package retryer import ( "fmt" - "log" "os" "strconv" @@ -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 } diff --git a/translator/util/ec2util/ec2util.go b/translator/util/ec2util/ec2util.go index b2af3fac74..6b3ce5e37b 100644 --- a/translator/util/ec2util/ec2util.go +++ b/translator/util/ec2util/ec2util.go @@ -5,7 +5,6 @@ package ec2util import ( "fmt" - "log" "net" "sync" "time" @@ -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 @@ -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