mirror of
https://github.com/linux-system-roles/network.git
synced 2026-07-28 13:33:57 +00:00
nm: Fix the incorrect change indication when apply the same config twice
When applying the same network connections twice, the second apply still shows `changed: true`. The root cause: * When user never asked about ethtool configuration, network-role will generate an all-default `NM.SettingEthtool` and pass it to NetworkManager daemon. But NetworkManager discard it when saving to ifcfg plugin as ifcfg plugin will not keep empty ethtool option. * During second apply, the `NM.SimpleConnection.compare` will return False indicating configuration changed because of on-disk connection has no ethtool setting while pending connection does. To fix it, we just remove the all-default `NM.SettingEthtool`. Signed-off-by: Gris Ge <fge@redhat.com>
This commit is contained in:
parent
833b6f3075
commit
f538865c68
2 changed files with 60 additions and 0 deletions
|
|
@ -976,6 +976,16 @@ class NMUtil:
|
|||
else:
|
||||
s_ethtool.option_set_uint32(nm_ring, setting)
|
||||
|
||||
# * When users did not specify any ethtool configuration, this module
|
||||
# will generate an default `NM.SettingEthtool` object and pass it to
|
||||
# NetworkManager. But NetworkManager cannot serialize this when using the
|
||||
# ifcfg plugin but treats this as no `NM.SettingEthtool` object.
|
||||
# * The following `NM.SimpleConnection.compare()` will therefore identify a
|
||||
# difference in the configuration.
|
||||
# * To workaround this, remove the default NM.SettingEthtool object.
|
||||
if s_ethtool.compare(NM.SettingEthtool.new(), NM.SettingCompareFlags.EXACT):
|
||||
con.remove_setting(NM.SettingEthtool)
|
||||
|
||||
if connection["mtu"]:
|
||||
if connection["type"] == "infiniband":
|
||||
s_infiniband = self.connection_ensure_setting(con, NM.SettingInfiniband)
|
||||
|
|
|
|||
50
tests/tests_change_indication_on_repeat_run.yml
Normal file
50
tests/tests_change_indication_on_repeat_run.yml
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# This file was generated by ensure_provider_tests.py
|
||||
---
|
||||
- hosts: all
|
||||
vars:
|
||||
interface: testnic1
|
||||
type: veth
|
||||
name: Test change indication on repeat run
|
||||
tasks:
|
||||
- include_tasks: tasks/manage_test_interface.yml
|
||||
vars:
|
||||
state: present
|
||||
- include_tasks: tasks/assert_device_present.yml
|
||||
- block:
|
||||
- block:
|
||||
- include_role:
|
||||
name: linux-system-roles.network
|
||||
register: __network_connections_result
|
||||
- name: Assert change:true
|
||||
assert:
|
||||
that: __network_connections_result is changed
|
||||
- include_role:
|
||||
name: linux-system-roles.network
|
||||
register: __network_connections_result
|
||||
- name: Assert change:false
|
||||
assert:
|
||||
that: not __network_connections_result is changed
|
||||
vars:
|
||||
network_connections:
|
||||
- name: "{{ interface }}"
|
||||
state: up
|
||||
type: ethernet
|
||||
ip:
|
||||
address:
|
||||
- 192.0.2.2/24
|
||||
always:
|
||||
- block:
|
||||
- include_role:
|
||||
name: linux-system-roles.network
|
||||
vars:
|
||||
network_connections:
|
||||
- name: "{{ interface }}"
|
||||
persistent_state: absent
|
||||
state: down
|
||||
ignore_errors: true
|
||||
- include_tasks: tasks/manage_test_interface.yml
|
||||
vars:
|
||||
state: absent
|
||||
tags:
|
||||
- "tests::cleanup"
|
||||
Loading…
Add table
Add a link
Reference in a new issue