Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Greatly clarify misleading metadata logging #2049

Merged

Conversation

ConnorJC3
Copy link
Contributor

@ConnorJC3 ConnorJC3 commented May 24, 2024

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:

  • Simplify metadata handling in main.go and use clear and specific log messages
  • Log the reason that Kubernetes metadata failed (today, only the error for EC2/IMDS metadata is logged)
  • Prefer the term "IMDS metadata" over "EC2 metadata" in logs, which is more accurate and useful for the user
  • Remove logging AWS_REGION in node.go - it's already logged in main.go and always logging it there (with a confusing variable name like regionFromSession) is misleading
  • Always override region with AWS_REGION if present, even in the node service
  • Remove log entries that only log duplicate information

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"

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 24, 2024
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 24, 2024
@ConnorJC3 ConnorJC3 force-pushed the fix-misleading-metadata-logging branch from 6c2272e to a18de96 Compare May 24, 2024 17:43
Copy link

github-actions bot commented May 24, 2024

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

@ConnorJC3 ConnorJC3 force-pushed the fix-misleading-metadata-logging branch from a18de96 to dca2ff7 Compare May 24, 2024 17:53
@ConnorJC3 ConnorJC3 force-pushed the fix-misleading-metadata-logging branch from dca2ff7 to 643be5a Compare May 24, 2024 17:55
@ConnorJC3 ConnorJC3 changed the title [WIP] Greatly clarify misleading metadata logging Greatly clarify misleading metadata logging May 24, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 24, 2024
Copy link
Member

@torredil torredil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 24, 2024
@k8s-ci-robot
Copy link
Contributor

[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:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 24, 2024
@torredil
Copy link
Member

/retest

@k8s-ci-robot k8s-ci-robot merged commit a402256 into kubernetes-sigs:master May 24, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants