Fix problem when switch provider from initscript to nm

Problem:

After `tests_bridge_initscripts.yml` passed, the `tests_bridge_nm.yml`
will fail with NetworkManager 1.18.

Root cause:

 1. The `absent` and `down` action of initscript provider will not
    remove the bridge interface which fail the assertion in
    `tests_bridge_nm.yml`.
 2. In initscript mode, network role will create ifcfg file with
    `NM_CONTROLLED=no` instructing NetworkManager to mark the bridge as
    unmanaged. The follow up `down` and `absent` action of initscript
    provider will not change the NetworkManager's understanding on
    unmanaged state of this interface.

Fixes:
 1. We cannot change existing behaviour of initscript on not deleting
    interface in `down` and `absent` action. So we change the test
    function `tests/playbooks/down_profile.yml` to delete the interface
    manually via `ip link del <ifname>` command.

 2. Use `NM.Client.reload_connections_async()` to reload the
    configuration for nm provider on NetworkManager 1.18.

Previous test infrastructure is running each test file in a brand new VM
or container which cause this problem not been found before.

Dedicate test case `tests/tests_switch_provider.yml` included.

Signed-off-by: Gris Ge <fge@redhat.com>
This commit is contained in:
Gris Ge 2022-01-21 18:24:54 +08:00 committed by Fernando Fernández Mancera
parent f508c27674
commit c98c17a236
7 changed files with 126 additions and 0 deletions

View file

@ -2055,6 +2055,16 @@ class Cmd_nm(Cmd):
len(self.connections) * DEFAULT_ACTIVATION_TIMEOUT
)
# On NetworkManger 1.18, If user switch from initscripts provider where
# NM_CONTROLLED=no defined in ifcfg-ethX file, NetworkManager daemon will treat
# that interface as strictly unmanaged, even the follow up deletion of
# ifcfg-ethX file cannot change the NetworManager's unmanaged state of this
# interface. This will prevent any follow up "nm" provider action on this
# interface. To solve that, we instruct NetworkManager to reload the
# configuration.
if self._nm_provider.get_client_version().startswith("1.18."):
self._nm_provider.reload_configuration()
def rollback_transaction(self, idx, action, error):
Cmd.rollback_transaction(self, idx, action, error)
self.on_failure()