← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~chad.smith/cloud-init:feature/ec2-secondary-nics into cloud-init:master

 

Inline comment asking for clarification on AWS DHCP lease contents, requirements for routing traffic to IMDS, DNS, and off-box, as with Azure.  Let's document what's needed; we may need to add secondary ips with a metric.  See

https://github.com/aws/ec2-net-utils/blob/master/ec2net-functions

For AmazonLinux net implementation;  I do see some setting of source_ip and route table/metrics in use.

Diff comments:

> diff --git a/tests/unittests/test_datasource/test_ec2.py b/tests/unittests/test_datasource/test_ec2.py
> index 20d59bf..8ed4c18 100644
> --- a/tests/unittests/test_datasource/test_ec2.py
> +++ b/tests/unittests/test_datasource/test_ec2.py
> @@ -302,21 +385,45 @@ class TestEc2(test_helpers.HttprettyTestCase):
>              platform_data=self.valid_platform_data,
>              sys_cfg={'datasource': {'Ec2': {'strict_id': True}}},
>              md={'md': DEFAULT_METADATA})
> -        find_fallback_path = (
> -            'cloudinit.sources.DataSourceEc2.net.find_fallback_nic')
> +        find_fallback_path = M_PATH_NET + 'find_fallback_nic'
>          with mock.patch(find_fallback_path) as m_find_fallback:
>              m_find_fallback.return_value = 'eth9'
>              ds.get_data()
>  
>          mac1 = '06:17:04:d7:26:0A'  # IPv4 only in DEFAULT_METADATA
> -        expected = {'version': 1, 'config': [
> -            {'mac_address': '06:17:04:d7:26:0A', 'name': 'eth9',
> -             'subnets': [{'type': 'dhcp4'}],
> -             'type': 'physical'}]}
> -        patch_path = (
> -            'cloudinit.sources.DataSourceEc2.net.get_interfaces_by_mac')
> -        get_interface_mac_path = (
> -            'cloudinit.sources.DataSourceEc2.net.get_interface_mac')
> +        expected = {'version': 2, 'ethernets': {'eth9': {
> +            'match': {'macaddress': mac1.lower()}, 'set-name': 'eth9',
> +            'dhcp4': True}}}
> +        patch_path = M_PATH_NET + 'get_interfaces_by_mac'
> +        get_interface_mac_path = M_PATH_NET + 'get_interface_mac'
> +        with mock.patch(patch_path) as m_get_interfaces_by_mac:
> +            with mock.patch(find_fallback_path) as m_find_fallback:
> +                with mock.patch(get_interface_mac_path) as m_get_mac:
> +                    m_get_interfaces_by_mac.return_value = {mac1: 'eth9'}
> +                    m_find_fallback.return_value = 'eth9'
> +                    m_get_mac.return_value = mac1
> +                    self.assertEqual(expected, ds.network_config)
> +
> +    def test_network_config_property_secondary_private_ips(self):
> +        """network_config property configures any secondary ipv4 addresses.
> +
> +        Only one device is configured even when multiple exist in metadata.
> +        """
> +        ds = self._setup_ds(
> +            platform_data=self.valid_platform_data,
> +            sys_cfg={'datasource': {'Ec2': {'strict_id': True}}},
> +            md={'md': SECONDARY_IP_METADATA_2018_09_24})
> +        find_fallback_path = M_PATH_NET + 'find_fallback_nic'
> +        with mock.patch(find_fallback_path) as m_find_fallback:
> +            m_find_fallback.return_value = 'eth9'
> +            ds.get_data()
> +
> +        mac1 = '0a:07:84:3d:6e:38'  # IPv4 with 1 secondary IP
> +        expected = {'version': 2, 'ethernets': {'eth9': {
> +            'match': {'macaddress': mac1}, 'set-name': 'eth9',
> +            'addresses': ['172.31.45.70/20'], 'dhcp4': True}}}

Do we know if:

1) dhcp response from AWS DHCP server includes classless static routes?
2) if the secondary IPs have to be from the same subnet as the primary interface (DHCP)?
3) if the IMDS, DNS, or off-box routing requires the source-ip to be the value from DHCP  (Note, I think we know that IMDS requires the source-ip to be from the DHCP response, IIRC).

> +        patch_path = M_PATH_NET + 'get_interfaces_by_mac'
> +        get_interface_mac_path = M_PATH_NET + 'get_interface_mac'
>          with mock.patch(patch_path) as m_get_interfaces_by_mac:
>              with mock.patch(find_fallback_path) as m_find_fallback:
>                  with mock.patch(get_interface_mac_path) as m_get_mac:


-- 
https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/369792
Your team cloud-init commiters is requested to review the proposed merge of ~chad.smith/cloud-init:feature/ec2-secondary-nics into cloud-init:master.


References