Merge ~smoser/cloud-init:fix/1792415-fix-ovh-dhcp-routes into cloud-init:master

Proposed by Scott Moser
Status: Merged
Approved by: Chad Smith
Approved revision: 8b8f376b1c24c9772ac0b8524c713c943701ea0e
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~smoser/cloud-init:fix/1792415-fix-ovh-dhcp-routes
Merge into: cloud-init:master
Diff against target: 55 lines (+16/-3)
3 files modified
cloudinit/net/__init__.py (+7/-0)
cloudinit/net/tests/test_init.py (+8/-3)
cloudinit/sources/helpers/openstack.py (+1/-0)
Reviewer Review Type Date Requested Status
Chad Smith Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+354881@code.launchpad.net

Commit message

EphemeralIPv4Network: Be more explicit when adding default route.

On OpenStack based OVH public cloud, we got DHCP response with
  fixed-address 54.36.113.86;
  option subnet-mask 255.255.255.255;
  option routers 54.36.112.1;

The router clearly is not on the subnet. So 'ip' would fail when
we tried to add the default route.
The solution here is to add an explicit route on that interface
to the router and then add the default route.

Also add 'bgpovs' to the list of 'physical' types for OpenStack
network configuration. That type is used on OVH public cloud.

LP: #1792415

Description of the change

see commit message

To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

https://code.launchpad.net/~tobijk/cloud-init/+git/cloud-init/+merge/354752
^ The MP above originally raised this and suggested a fix for the 'bgpovs' type.

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

PASSED: Continuous integration, rev:8b8f376b1c24c9772ac0b8524c713c943701ea0e
https://jenkins.ubuntu.com/server/job/cloud-init-ci/314/
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/314/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

LGTM!

review: Approve

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py
2index 3ffde52..5e87bca 100644
3--- a/cloudinit/net/__init__.py
4+++ b/cloudinit/net/__init__.py
5@@ -698,6 +698,13 @@ class EphemeralIPv4Network(object):
6 self.interface, out.strip())
7 return
8 util.subp(
9+ ['ip', '-4', 'route', 'add', self.router, 'dev', self.interface,
10+ 'src', self.ip], capture=True)
11+ self.cleanup_cmds.insert(
12+ 0,
13+ ['ip', '-4', 'route', 'del', self.router, 'dev', self.interface,
14+ 'src', self.ip])
15+ util.subp(
16 ['ip', '-4', 'route', 'add', 'default', 'via', self.router,
17 'dev', self.interface], capture=True)
18 self.cleanup_cmds.insert(
19diff --git a/cloudinit/net/tests/test_init.py b/cloudinit/net/tests/test_init.py
20index 8b444f1..58e0a59 100644
21--- a/cloudinit/net/tests/test_init.py
22+++ b/cloudinit/net/tests/test_init.py
23@@ -515,12 +515,17 @@ class TestEphemeralIPV4Network(CiTestCase):
24 capture=True),
25 mock.call(
26 ['ip', 'route', 'show', '0.0.0.0/0'], capture=True),
27+ mock.call(['ip', '-4', 'route', 'add', '192.168.2.1',
28+ 'dev', 'eth0', 'src', '192.168.2.2'], capture=True),
29 mock.call(
30 ['ip', '-4', 'route', 'add', 'default', 'via',
31 '192.168.2.1', 'dev', 'eth0'], capture=True)]
32- expected_teardown_calls = [mock.call(
33- ['ip', '-4', 'route', 'del', 'default', 'dev', 'eth0'],
34- capture=True)]
35+ expected_teardown_calls = [
36+ mock.call(['ip', '-4', 'route', 'del', 'default', 'dev', 'eth0'],
37+ capture=True),
38+ mock.call(['ip', '-4', 'route', 'del', '192.168.2.1',
39+ 'dev', 'eth0', 'src', '192.168.2.2'], capture=True),
40+ ]
41
42 with net.EphemeralIPv4Network(**params):
43 self.assertEqual(expected_setup_calls, m_subp.call_args_list)
44diff --git a/cloudinit/sources/helpers/openstack.py b/cloudinit/sources/helpers/openstack.py
45index e3d372b..f5d5d68 100644
46--- a/cloudinit/sources/helpers/openstack.py
47+++ b/cloudinit/sources/helpers/openstack.py
48@@ -53,6 +53,7 @@ OS_VERSIONS = (
49
50 PHYSICAL_TYPES = (
51 None,
52+ 'bgpovs', # not present in OpenStack upstream but used on OVH cloud.
53 'bridge',
54 'dvs',
55 'ethernet',

Subscribers

People subscribed via source and target branches