kubernetes-sigs / aws-ebs-csi-driver

CSI driver for Amazon EBS https://aws.amazon.com/ebs/
Apache License 2.0
940 stars 774 forks source link

Greatly clarify misleading metadata logging #2049

Closed ConnorJC3 closed 1 month ago

ConnorJC3 commented 1 month ago

Is this a bug fix or adding new feature?

Bug fix

What is this PR about? / Why do we need it?

The current logging for metadata is extremely misleading and (in some cases) straight up wrong. This PR fixes that (and a few other related issues) by:

What testing is done?

Manual/CI/Updated unit tests

Examples of new output:

# Node with metadata unavailable
$ ./bin/aws-ebs-csi-driver node
I0524 17:50:13.532843    1157 main.go:157] "Initializing metadata"
I0524 17:50:13.532883    1157 metadata.go:66] "The AWS_EC2_METADATA_DISABLED environment variable disables access to EC2 IMDS" enabled="true"
E0524 17:50:13.533053    1157 metadata.go:51] "Retrieving IMDS metadata failed, falling back to Kubernetes metadata" err="could not get EC2 instance identity metadata: operation error ec2imds: GetInstanceIdentityDocument, access disabled to EC2 IMDS via client option, or \"AWS_EC2_METADATA_DISABLED\" environment variable"
E0524 17:50:13.533069    1157 metadata.go:58] "Retrieving Kubernetes metadata failed" err="unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined"
E0524 17:50:13.533087    1157 main.go:163] "Failed to initialize metadata when it is required" err="IMDS metadata and Kubernetes metadata are both unavailable"
# Controller using AWS_REGION
$ AWS_REGION="us-west-2" ./bin/aws-ebs-csi-driver controller
I0524 17:51:14.668731    4794 main.go:151] "Region provided via AWS_REGION environment variable" region="us-west-2"
I0524 17:51:14.670591    4794 driver.go:68] "Driver Information" Driver="ebs.csi.aws.com" Version="v1.31.0"
github-actions[bot] commented 1 month ago

Code Coverage Diff

File Old Coverage New Coverage Delta
github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/cloud/metadata/ec2.go 94.4% 94.3% -0.1
github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/cloud/metadata/metadata.go 96.7% 97.0% 0.3
k8s-ci-robot commented 1 month ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: torredil

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/OWNERS)~~ [torredil] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
torredil commented 1 month ago

/retest