Skip to content

Commit

Permalink
nm: Fix the incorrect change indication when apply the same config twice
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cathay4t committed Jun 24, 2021
1 parent 85b75b6 commit 8460d9f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions library/network_connections.py
Expand Up @@ -976,6 +976,16 @@ def connection_create(self, connections, idx, connection_current=None):
else:
s_ethtool.option_set_uint32(nm_ring, setting)

# * 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.
# * The follow up `NM.SimpleConnection.compare()` will indicate
# configuration changed as new ethtool setting found.
# * To workaround this, we just remove the all-default NM.SettingEthtool.
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)
Expand Down

0 comments on commit 8460d9f

Please sign in to comment.