route metric on multihomed ec2 instances is based on mac address instead of device-number

Bug #1876312 reported by Mark
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
High
Dan Watkins

Bug Description

Since #114 all network interfaces get IPs and a default route, with a metric based on `nic_idx`. `nic_idx` isn't derived from the EC2 device-number, but from sorting by MAC address:

  https://github.com/canonical/cloud-init/blob/6600c642af3817fe5e0170cb7b4eeac4be3c60eb/cloudinit/sources/DataSourceEc2.py#L766

A machine with multiple interfaces, where the MAC addresses aren't in order, will end up with the wrong metric. For example, if eth0 has a MAC address that sorts before eth1, the default route for eth1 will be given metric 100, while eth0 will get 200.

This wasn't picked up in tests (e.g. https://paste.ubuntu.com/p/jw6Wws5Jhk/) because interfaces are typically assigned in MAC address order. This isn't true when creating an additional network interface in EC2, or creating an instance from pre-existing interfaces.

Revision history for this message
Mark (ms7821) wrote :

This should say "if eth0 has a MAC address that sorts *after* eth1, the default route for eth1 will be given metric 100, while eth0 will get 200"

Revision history for this message
Dan Watkins (oddbloke) wrote :

A pull request for this is open at https://github.com/canonical/cloud-init/pull/342

Changed in cloud-init:
status: New → In Progress
assignee: nobody → Dan Watkins (daniel-thewatkins)
importance: Undecided → High
Revision history for this message
Dan Watkins (oddbloke) wrote :

(That PR landed.)

Changed in cloud-init:
status: In Progress → Fix Committed
Revision history for this message
James Falcon (falcojr) wrote : Fixed in cloud-init version 20.3.

This bug is believed to be fixed in cloud-init in version 20.3. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in cloud-init:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers