Skip to content

net: ubuntu focal prioritize netplan over eni even if both present#267

Merged
blackboxsw merged 4 commits into
canonical:masterfrom
blackboxsw:bug/focal-prioritize-netplan
Mar 31, 2020
Merged

net: ubuntu focal prioritize netplan over eni even if both present#267
blackboxsw merged 4 commits into
canonical:masterfrom
blackboxsw:bug/focal-prioritize-netplan

Conversation

@blackboxsw
Copy link
Copy Markdown
Collaborator

On Focal and later, Ubuntu will prioritize netplan renderer before eni, even if ifupdown

and netplan are both installed. ENI on Bionic and later is considered an unsupported
configuration and so cloud-init should generally prefer netplan to eni rendering because
/etc/network/interfaces config file on many cloud images disables including cloud-init's
/etc/network/interfaces.d/50-cloud-init.cfg file.

Ubuntu series-specific changes may be applied to Bionic and Eoan, but further
discussion is warranted about the best approach on released series.

LP: #1867029

@blackboxsw blackboxsw force-pushed the bug/focal-prioritize-netplan branch 2 times, most recently from 50a78c3 to ab0f955 Compare March 23, 2020 16:57
Comment thread cloudinit/distros/__init__.py Outdated
@blackboxsw blackboxsw force-pushed the bug/focal-prioritize-netplan branch from ab0f955 to 93b1152 Compare March 25, 2020 04:30
@blackboxsw blackboxsw requested a review from raharper March 26, 2020 22:19
@blackboxsw blackboxsw force-pushed the bug/focal-prioritize-netplan branch 2 times, most recently from 3a39691 to 9d94e73 Compare March 27, 2020 17:24
Copy link
Copy Markdown
Collaborator

@raharper raharper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a unittest for this.

+    @mock.patch("cloudinit.net.renderers.netplan.available")
+    @mock.patch("cloudinit.net.renderers.sysconfig.available")
+    @mock.patch("cloudinit.net.renderers.sysconfig.available_sysconfig")
+    @mock.patch("cloudinit.net.renderers.sysconfig.available_nm")
+    @mock.patch("cloudinit.net.renderers.eni.available")
+    @mock.patch("cloudinit.net.renderers.sysconfig.util.get_linux_distro")
+    def test_netplan_selected_with_ifupdown_installed(self, m_distro,
+                                                            m_eni, m_sys_nm,
+                                                            m_sys_scfg,
+                                                            m_sys_avail,
+                                                            m_netplan):
+        """default policy selects netplan over eni when both installed."""
+
+        # Ubuntu with eni and netplan installed
+        m_netplan.return_value = True     # netplan is installed
+        m_eni.return_value = True         # ifupdown is installed
+        m_sys_scfg.return_value = False   # no sysconfig/ifup/ifdown
+        m_sys_nm.return_value = False     # no network-manager
+        m_sys_avail.return_value = False  # no sysconfig on Ubuntu
+        m_distro.return_value = ('ubuntu', None, None)
+        priority = renderers.DEFAULT_PRIORITY
+        self.assertEqual('netplan', renderers.select(priority=priority)[0])
+

@blackboxsw blackboxsw force-pushed the bug/focal-prioritize-netplan branch from 3bc8c19 to 365efb6 Compare March 27, 2020 21:47
@blackboxsw blackboxsw force-pushed the bug/focal-prioritize-netplan branch from 83a31e6 to 896782e Compare March 28, 2020 02:47
@blackboxsw blackboxsw requested a review from raharper March 28, 2020 19:52
@blackboxsw
Copy link
Copy Markdown
Collaborator Author

Added some pytests for both renderers.select() and ./tools/render-cloudcfg

@powersj
Copy link
Copy Markdown
Contributor

powersj commented Mar 30, 2020

@blackboxsw land and upload please

@blackboxsw blackboxsw changed the title net: ubuntu focal to prioritize netplan over eni even if both are avail net: ubuntu focal prioritize netplan over eni even if both present Mar 31, 2020
@blackboxsw blackboxsw merged commit 4fb6fd8 into canonical:master Mar 31, 2020
takumin added a commit to takumin/mitamae-cloud-image that referenced this pull request Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants