Skip to content

Fix bug where transient IMDS failure could revert secondary ip addres… - #162

Merged
joeysk2012 merged 1 commit into
amazonlinux:mainfrom
joeysk2012:fix-local-ipv4
Jul 14, 2026
Merged

joeysk2012 merged 1 commit into
amazonlinux:mainfrom
joeysk2012:fix-local-ipv4

Conversation

@joeysk2012

Copy link
Copy Markdown
Contributor

Fixes a bug where if transient IMDS call fails during mid execution of refresh-policy-routes then, a the secondary ip config ec2_alias.conf will be removed. This happens because there get_imds fails and the shell $(..) will swallow the error and addresses will be returned as a empty string. This could also happen for subnets in create_if_overrides and we do a best effort to fix this as well.

Issue #, if available: #161

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…ses.

Modify subnet calls in  create_if_overrides function and add http failure logging.
@joeysk2012

Copy link
Copy Markdown
Contributor Author

Reviewed offline, merging.

@joeysk2012
joeysk2012 merged commit 06cef47 into amazonlinux:main Jul 14, 2026
4 checks passed
mjnowen added a commit to mjnowen/amazon-ec2-net-utils that referenced this pull request Sep 30, 2026
Since v2.7.5 (amazonlinux#162), get_meta() forwards curl's stderr to syslog at err
priority on every attempt. Single-attempt callers query keys that may
legitimately be absent (ipv4-prefix when no prefix is delegated,
network-card on single-card instance types), so each refresh of a
secondary interface now logs 'curl: (22) The requested URL returned
error: 404' as an error.

get_meta() already suppresses its own summary error for max_tries=1 for
exactly this reason. Apply the same rule to curl's stderr, and keep
forwarding it at err priority for retrying callers.

Add regression tests in tests/imds.bats covering both paths.

Fixes amazonlinux#175
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.

2 participants