Merge ~oddbloke/cloud-init/+git/cloud-init:macvtap into cloud-init:master

Proposed by Dan Watkins
Status: Merged
Approved by: Dan Watkins
Approved revision: 8527e3d86c150997407722aeccaaf894e9ada42b
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~oddbloke/cloud-init/+git/cloud-init:macvtap
Merge into: cloud-init:master
Diff against target: 78 lines (+29/-6)
2 files modified
cloudinit/sources/helpers/openstack.py (+6/-6)
tests/unittests/test_datasource/test_configdrive.py (+23/-0)
Reviewer Review Type Date Requested Status
Ryan Harper Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+363421@code.launchpad.net

Commit message

helpers/openstack: Treat unknown link types as physical

Some deployments of OpenStack expose link types to the guest which
cloud-init doesn't recognise. These will almost always be physical, so
we can operate more robustly if we assume that they are (whilst warning
the user that we're seeing something unexpected).

LP: #1639263

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:e356bb117e48f6497d4e747c131c738c5d4a41ec
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~daniel-thewatkins/cloud-init/+git/cloud-init/+merge/363421/+edit-commit-message

https://jenkins.ubuntu.com/server/job/cloud-init-ci/566/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/566/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:e356bb117e48f6497d4e747c131c738c5d4a41ec
https://jenkins.ubuntu.com/server/job/cloud-init-ci/567/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/567/rebuild

review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:5b041496005975cbaf63c1c996814901bb0d6894
https://jenkins.ubuntu.com/server/job/cloud-init-ci/568/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/568/rebuild

review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

If we're going to touch this, maybe we could get a wider list from whatever openstack has there now?

https://github.com/openstack/nova/blob/c6218428e9b29a2c52808ec7d27b4b21aadc0299/nova/network/model.py

Revision history for this message
Ryan Harper (raharper) wrote :

This looks good.

You can see the existing openstack network_data.json samples in:

tests/unittests/test_net.py line 426 of 4185 OS_SAMPLES

That shows the general structure. Another one is in

tests/unittests/test_datasource/test_configdrive.py

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:8527e3d86c150997407722aeccaaf894e9ada42b
https://jenkins.ubuntu.com/server/job/cloud-init-ci/579/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/579/rebuild

review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/cloudinit/sources/helpers/openstack.py b/cloudinit/sources/helpers/openstack.py
index 9c29cea..8f06911 100644
--- a/cloudinit/sources/helpers/openstack.py
+++ b/cloudinit/sources/helpers/openstack.py
@@ -67,7 +67,7 @@ OS_VERSIONS = (
67 OS_ROCKY,67 OS_ROCKY,
68)68)
6969
70PHYSICAL_TYPES = (70KNOWN_PHYSICAL_TYPES = (
71 None,71 None,
72 'bgpovs', # not present in OpenStack upstream but used on OVH cloud.72 'bgpovs', # not present in OpenStack upstream but used on OVH cloud.
73 'bridge',73 'bridge',
@@ -600,9 +600,7 @@ def convert_net_json(network_json=None, known_macs=None):
600 subnet['ipv6'] = True600 subnet['ipv6'] = True
601 subnets.append(subnet)601 subnets.append(subnet)
602 cfg.update({'subnets': subnets})602 cfg.update({'subnets': subnets})
603 if link['type'] in PHYSICAL_TYPES:603 if link['type'] in ['bond']:
604 cfg.update({'type': 'physical', 'mac_address': link_mac_addr})
605 elif link['type'] in ['bond']:
606 params = {}604 params = {}
607 if link_mac_addr:605 if link_mac_addr:
608 params['mac_address'] = link_mac_addr606 params['mac_address'] = link_mac_addr
@@ -641,8 +639,10 @@ def convert_net_json(network_json=None, known_macs=None):
641 curinfo.update({'mac': link['vlan_mac_address'],639 curinfo.update({'mac': link['vlan_mac_address'],
642 'name': name})640 'name': name})
643 else:641 else:
644 raise ValueError(642 if link['type'] not in KNOWN_PHYSICAL_TYPES:
645 'Unknown network_data link type: %s' % link['type'])643 LOG.warning('Unknown network_data link type (%s); treating as'
644 ' physical', link['type'])
645 cfg.update({'type': 'physical', 'mac_address': link_mac_addr})
646646
647 config.append(cfg)647 config.append(cfg)
648 link_id_info[curinfo['id']] = curinfo648 link_id_info[curinfo['id']] = curinfo
diff --git a/tests/unittests/test_datasource/test_configdrive.py b/tests/unittests/test_datasource/test_configdrive.py
index dcdabea..664f354 100644
--- a/tests/unittests/test_datasource/test_configdrive.py
+++ b/tests/unittests/test_datasource/test_configdrive.py
@@ -604,6 +604,9 @@ class TestNetJson(CiTestCase):
604604
605605
606class TestConvertNetworkData(CiTestCase):606class TestConvertNetworkData(CiTestCase):
607
608 with_logs = True
609
607 def setUp(self):610 def setUp(self):
608 super(TestConvertNetworkData, self).setUp()611 super(TestConvertNetworkData, self).setUp()
609 self.tmp = self.tmp_dir()612 self.tmp = self.tmp_dir()
@@ -730,6 +733,26 @@ class TestConvertNetworkData(CiTestCase):
730 'enp0s2': 'fa:16:3e:d4:57:ad'}733 'enp0s2': 'fa:16:3e:d4:57:ad'}
731 self.assertEqual(expected, config_name2mac)734 self.assertEqual(expected, config_name2mac)
732735
736 def test_unknown_device_types_accepted(self):
737 # If we don't recognise a link, we should treat it as physical for a
738 # best-effort boot
739 my_netdata = deepcopy(NETWORK_DATA)
740 my_netdata['links'][0]['type'] = 'my-special-link-type'
741
742 ncfg = openstack.convert_net_json(my_netdata, known_macs=KNOWN_MACS)
743 config_name2mac = {}
744 for n in ncfg['config']:
745 if n['type'] == 'physical':
746 config_name2mac[n['name']] = n['mac_address']
747
748 expected = {'nic0': 'fa:16:3e:05:30:fe', 'enp0s1': 'fa:16:3e:69:b0:58',
749 'enp0s2': 'fa:16:3e:d4:57:ad'}
750 self.assertEqual(expected, config_name2mac)
751
752 # We should, however, warn the user that we don't recognise the type
753 self.assertIn('Unknown network_data link type (my-special-link-type)',
754 self.logs.getvalue())
755
733756
734def cfg_ds_from_dir(base_d, files=None):757def cfg_ds_from_dir(base_d, files=None):
735 run = os.path.join(base_d, "run")758 run = os.path.join(base_d, "run")

Subscribers

People subscribed via source and target branches