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

Misleading 404 logs in IMDS mode when querying EC2 Metadata without a public IP #1058

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

xabinapal
Copy link
Contributor

Description of changes:

While running NTH in IMDS mode on instances without an assigned public IP, I noticed that requests to certain EC2 Metadata endpoints, specifically public-hostname and public-ipv4, return a 404 status code. This is the expected behavior, as documented here. Although NTH does not fail and works as expected in this scenario, some log messages about these 404 status codes are displayed:

2024/08/29 13:42:34 INF Metadata response status code: 404. Body: <?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>404 - Not Found</title>
 </head>
 <body>
  <h1>404 - Not Found</h1>
 </body>
</html>

These messages don't clarify the reason for the 404 codes, which can mislead users (like myself!) into thinking something is wrong. To address this, I've added an allowMissing parameter to the GetMetadataInfo function. When this flag is enabled, no message will be logged for 404 responses, and no error will be returned.

While this might not be the most elegant solution, I felt like any other alternative, such as implementing the options pattern, would be overkill and too complex for the limited scope of the function.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Signed-off-by: Xabier Napal <xabier.napal@dvzr.io>
Signed-off-by: Xabier Napal <xabier.napal@dvzr.io>
@xabinapal xabinapal requested a review from a team as a code owner August 29, 2024 20:43
Copy link

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want this PR to never become stale, please ask a maintainer to apply the "stalebot-ignore" label.

@github-actions github-actions bot added the stale Issues / PRs with no activity label Sep 14, 2024
@LikithaVemulapalli LikithaVemulapalli removed the stale Issues / PRs with no activity label Sep 15, 2024
Copy link

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want this PR to never become stale, please ask a maintainer to apply the "stalebot-ignore" label.

@github-actions github-actions bot added the stale Issues / PRs with no activity label Sep 30, 2024
Copy link

github-actions bot commented Oct 6, 2024

This PR was closed because it has become stale with no activity.

@github-actions github-actions bot closed this Oct 6, 2024
@Lu-David Lu-David removed the stale Issues / PRs with no activity label Oct 7, 2024
@Lu-David Lu-David reopened this Oct 7, 2024
Copy link

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want this PR to never become stale, please ask a maintainer to apply the "stalebot-ignore" label.

@github-actions github-actions bot added the stale Issues / PRs with no activity label Oct 23, 2024
Copy link

This PR was closed because it has become stale with no activity.

@github-actions github-actions bot closed this Oct 29, 2024
@xabinapal
Copy link
Contributor Author

xabinapal commented Nov 1, 2024

Could this be reviewed so it's not marked as stale by the bot?

@LikithaVemulapalli @Lu-David @steveshidev

@LikithaVemulapalli
Copy link
Contributor

Hello @xabinapal, will take a look at this PR. Thanks for your contribution :)

@LikithaVemulapalli LikithaVemulapalli requested review from LikithaVemulapalli and removed request for steveshidev November 14, 2024 22:31
@github-actions github-actions bot removed the stale Issues / PRs with no activity label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants