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 a all-default `NM.SettingEthtool` and pass to
   NetworkManager daemon. But NetworkManager discard it.
 * 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 72b0337
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions library/network_connections.py
Expand Up @@ -976,6 +976,15 @@ def connection_create(self, connections, idx, connection_current=None):
else:
s_ethtool.option_set_uint32(nm_ring, setting)

# When user does not ask about ethtool setting, we will generate
# NM.SettingEthtool with all default values.
# When saving that to NetworkManager daemon, it got discarded.
# But 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 72b0337

Please sign in to comment.