Skip to content

Commit

Permalink
NM activator/bring_up_interfaces: reload and bring up individual netw…
Browse files Browse the repository at this point in the history
…ork conns

Reloading the network manager service is equivalent to "nmcli reload" and this
command only reloads the global .conf files and DNS config, not connections.
This means changes to connection files will not take effect. For those to take
effect, we need "nmcli conn load/reload" and then "nmcli conn up". Thus,
reloading network manager as well as reloading the connections are required to
cover all cases.

While at it, rename "reload-or-try-restart" -> "try-reload-or-restart" since
the former is legacy and the later is the officially documented sub-command.

Fixes: canonicalGH-6064
Fixes: bde913a ("fix(NetworkManager): Fix network activator")

Signed-off-by: Ani Sinha <[email protected]>
  • Loading branch information
ani-sinha committed Mar 4, 2025
1 parent aba3791 commit a6dce85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cloudinit/net/activators.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ def bring_up_interfaces(cls, device_names: Iterable[str]) -> bool:
state,
)
return _alter_interface(
["systemctl", "reload-or-try-restart", "NetworkManager.service"],
["systemctl", "try-reload-or-restart", "NetworkManager.service"],
"all",
)
) and all(cls.bring_up_interface(device) for device in device_names)


class NetplanActivator(NetworkActivator):
Expand Down
4 changes: 2 additions & 2 deletions tests/unittests/test_net_activators.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ def test_available(self, activator, available_calls, available_mocks):
),
{},
),
((["systemctl", "reload-or-try-restart", "NetworkManager.service"],), {}),
]
((["systemctl", "try-reload-or-restart", "NetworkManager.service"],), {}),
] + NETWORK_MANAGER_BRING_UP_CALL_LIST

NETWORKD_BRING_UP_CALL_LIST: list = [
((["ip", "link", "set", "dev", "eth0", "up"],), {}),
Expand Down

0 comments on commit a6dce85

Please sign in to comment.