-
Notifications
You must be signed in to change notification settings - Fork 909
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
DataSourceEc2: use metadata's NIC ordering to determine route-metrics #342
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This exposes a bug in our code.
EC2 uses dash-separated-names, not underscore_separated_names. (It's not clear to me how this data ended up with underscores at all.)
We want to set route-metrics such that NICs are configured with the priority that they are given in the network metadata that we receive from the IMDS. (This switches away from using MAC ordering.)
mitechie
reviewed
May 1, 2020
raharper
reviewed
May 1, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good. I'd like another pass to look at some possible issues:
- get_interfaces_by_mac may vary it's output depending on platform, do we need to consistently apply a .lower() or .upper() here?
- in DataSourceEc2 (and likely others) are we dealing with mixed case mac address values?
On Fri, May 01, 2020 at 07:55:27AM -0700, Rick Harding wrote:
> for mac, nic_name in sorted(macs_to_nics.items()):
nic_metadata = macs_metadata.get(mac)
if not nic_metadata:
continue # Not a physical nic represented in metadata
+ # device-number is zero-indexed, we want it 1-indexed for the
+ # multiplication on the following line
+ nic_idx = int(nic_metadata['device-number']) + 1
is this never empty then? Should it have a default value in case it isn't?
Per
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-categories.html
this has been present since 2011, and I don't believe there are any
cases where it will be absent.
|
raharper
approved these changes
May 1, 2020
TheRealFalcon
added a commit
to TheRealFalcon/cloud-init
that referenced
this pull request
Mar 8, 2021
canonical#342 (70dbccb) introduced the ability to determine route-metrics based on the `device-number` provided by the EC2 IMDS. Not all datasources that subclass EC2 will have this attribute, so allow the old behavior if `device-number` is not present. LP: #1917875
This was referenced May 12, 2023
Closed
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We want to set route-metrics such that NICs are configured with the priority that they are given in the network metadata that we receive from the IMDS. (This switches away from using MAC ordering.)
This also required the following test changes:
NIC2_MD
(which were under_scored instead of dash-separated)TestConvertEc2MetadataNetworkConfig
LP: #1876312