Skip to content

Commit

Permalink
feat(dhcp): Make dhcpcd the default dhcp client (#4912)
Browse files Browse the repository at this point in the history
isc-dhcp-client is no longer supported by upstream

BREAKING CHANGE: dhcpcd has been promoted to the default dhcp client.
Previous behavior can be configured in cloud.cfg via the dhcp_client_priority
key.
  • Loading branch information
holmanb authored Feb 20, 2024
1 parent 5fd3fc7 commit 6d61b63
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cloudinit/net/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,4 +967,4 @@ def parse_static_routes(routes: str) -> List[Tuple[str, str]]:
return []


ALL_DHCP_CLIENTS = [IscDhclient, Dhcpcd, Udhcpc]
ALL_DHCP_CLIENTS = [Dhcpcd, IscDhclient, Udhcpc]
2 changes: 1 addition & 1 deletion config/cloud.cfg.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ system_info:
{% elif variant in ["ubuntu", "unknown"] %}
{# SRU_BLOCKER: do not ship network renderers on Xenial, Bionic or Eoan #}
network:
dhcp_client_priority: [dhclient, dhcpcd, udhcpc]
dhcp_client_priority: [dhcpcd, dhclient, udhcpc]
renderers: ['netplan', 'eni', 'sysconfig']
activators: ['netplan', 'eni', 'network-manager', 'networkd']
{% elif is_rhel %}
Expand Down
4 changes: 2 additions & 2 deletions tests/unittests/distros/test__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,10 @@ def test_get_tmp_exec_path(
id="first_client_is_found_from_config_udhcpc",
),
pytest.param(
IscDhclient,
Dhcpcd,
{"network": {"dhcp_client_priority": []}},
None,
id="first_client_is_found_no_config_dhclient",
id="first_client_is_found_no_config_dhcpcd",
),
pytest.param(
Dhcpcd,
Expand Down
4 changes: 2 additions & 2 deletions tests/unittests/net/test_dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class TestDHCPDiscoveryClean(CiTestCase):
@mock.patch("cloudinit.net.dhcp.os.remove")
@mock.patch("cloudinit.net.dhcp.subp.subp")
@mock.patch("cloudinit.net.dhcp.subp.which")
def test_dhclient_exits_with_error(
def test_dhcpcd_exits_with_error(
self, m_which, m_subp, m_remove, m_fallback
):
"""Log and do nothing when nic is absent and no fallback is found."""
Expand All @@ -394,7 +394,7 @@ def test_dhclient_exits_with_error(
maybe_perform_dhcp_discovery(Distro("fake but not", {}, None))

self.assertIn(
"DHCP client selected: dhclient",
"DHCP client selected: dhcpcd",
self.logs.getvalue(),
)

Expand Down
22 changes: 14 additions & 8 deletions tests/unittests/sources/test_cloudstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,23 @@ def test_get_hostname_fqdn_fallback(self):
)
)

lease = {
"interface": "eth0",
"fixed-address": "192.168.0.1",
"subnet-mask": "255.255.255.0",
"routers": "192.168.0.1",
"renew": "4 2017/07/27 18:02:30",
"expire": "5 2017/07/28 07:08:15",
}
self.patches.enter_context(
mock.patch(
DHCP_MOD_PATH + ".IscDhclient.get_newest_lease",
return_value={
"interface": "eth0",
"fixed-address": "192.168.0.1",
"subnet-mask": "255.255.255.0",
"routers": "192.168.0.1",
"renew": "4 2017/07/27 18:02:30",
"expire": "5 2017/07/28 07:08:15",
},
return_value=lease,
)
)
self.patches.enter_context(
mock.patch(
DHCP_MOD_PATH + ".Dhcpcd.get_newest_lease", return_value=lease
)
)

Expand Down

0 comments on commit 6d61b63

Please sign in to comment.