Bug 1998222

Summary: nmstate renames connections when applying the same configuration
Product: Red Hat Enterprise Linux 9 Reporter: Alex Schultz <aschultz>
Component: nmstateAssignee: Fernando F. Mancera <ferferna>
Status: CLOSED ERRATA QA Contact: Mingyu Shi <mshi>
Severity: unspecified Docs Contact:
Priority: high    
Version: 9.0CC: apevec, bgalvani, dcbw, dsneddon, ferferna, fge, hjensas, jiji, jishi, john.j5live, lkundrak, mclasen, mshi, network-qe, opensource, patdung100+redhat, rhughes, rstrode, sandmann, till
Target Milestone: betaKeywords: Reopened, Triaged
Target Release: 9.0 BetaFlags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: nmstate-2.0.0-0.4.alpha3.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: 1660250 Environment:
Last Closed: 2022-05-17 12:32:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1660250    
Bug Blocks: 1998218    

Description Alex Schultz 2021-08-26 16:09:34 UTC
This bug was created per request in Bug #1660250 Comment 35

Description of problem:
When applying the same configuration, nmstate will rename existing connections.

Version-Release number of selected component (if applicable):
CentOS Stream 9

How reproducible:
100%

Steps to Reproduce:
[root@multi-1 ~]# nmcli c
NAME                UUID                                  TYPE      DEVICE 
System ens3         21d47e65-8523-1a06-af22-6f121086f085  ethernet  ens3   
Wired connection 1  9e2c277a-1a39-3124-b0e2-169a0c27ac2e  ethernet  ens4   
enp1s0              2f5648d1-0a78-4bba-9b96-7f9e09d38b8c  ethernet  --     
[root@multi-1 ~]# nmstatectl show > conf.yaml
2021-08-26 12:06:58,146 root         DEBUG    NetworkManager version 1.32.6
2021-08-26 12:06:58,148 root         DEBUG    Async action: Retrieve applied config: ethernet ens3 started
2021-08-26 12:06:58,149 root         DEBUG    Async action: Retrieve applied config: ethernet ens4 started
2021-08-26 12:06:58,152 root         DEBUG    Async action: Retrieve applied config: ethernet ens3 finished
2021-08-26 12:06:58,153 root         DEBUG    Async action: Retrieve applied config: ethernet ens4 finished
2021-08-26 12:06:58,155 root         DEBUG    Interface ethernet.ens3 found. Merging the interface information.
2021-08-26 12:06:58,156 root         DEBUG    Interface ethernet.ens4 found. Merging the interface information.
[root@multi-1 ~]# nmcli c
NAME                UUID                                  TYPE      DEVICE 
System ens3         21d47e65-8523-1a06-af22-6f121086f085  ethernet  ens3   
Wired connection 1  9e2c277a-1a39-3124-b0e2-169a0c27ac2e  ethernet  ens4   
enp1s0              2f5648d1-0a78-4bba-9b96-7f9e09d38b8c  ethernet  --     
[root@multi-1 ~]# nmstatectl apply < conf.yaml
...SNIP...
[root@multi-1 ~]# nmcli c
NAME    UUID                                  TYPE      DEVICE 
ens3    21d47e65-8523-1a06-af22-6f121086f085  ethernet  ens3   
ens4    9e2c277a-1a39-3124-b0e2-169a0c27ac2e  ethernet  ens4   
enp1s0  2f5648d1-0a78-4bba-9b96-7f9e09d38b8c  ethernet  -- 

Actual results:
Connections have been renamed.

Expected results:
The existing connection names should not be updated.

Comment 1 Fernando F. Mancera 2021-09-02 10:39:50 UTC
Upstream patch: https://github.com/nmstate/nmstate/pull/1698

Comment 2 Gris Ge 2021-09-24 15:23:39 UTC
Tested on base branch(a972b09a1d42b00f4195cacc90e372ea61c50244). Nmstate will not rename existing connections.

Comment 5 Mingyu Shi 2021-11-17 06:14:05 UTC
Verified with versions:
nmstate-2.0.0-0.4.alpha3.el9.noarch
nispor-1.1.1-2.el9.x86_64
NetworkManager-1.32.10-2.el9.x86_64

The following is an example, created bond0 with nm connection name "nmbond0", then changed it with nmstate successfully, the connection name didn't change:
[14:08:09@hp-dl380pg8-13 ~]0# nmcli con add con-name nmbond0 type bond connection.interface-name bond0
Connection 'nmbond0' (300fffdf-6629-48dc-a5a0-bc6d55eceaf2) successfully added.
[14:09:36@hp-dl380pg8-13 ~]0# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether a0:d3:c1:fb:ae:98 brd ff:ff:ff:ff:ff:ff
    altname enp3s0f0
3: eno2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
    link/ether a0:d3:c1:fb:ae:99 brd ff:ff:ff:ff:ff:ff
    altname enp3s0f1
4: eno3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether a0:d3:c1:fb:ae:9a brd ff:ff:ff:ff:ff:ff
    altname enp3s0f2
5: eno4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether a0:d3:c1:fb:ae:9b brd ff:ff:ff:ff:ff:ff
    altname enp3s0f3
6: ens4f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 00:90:fa:97:48:c0 brd ff:ff:ff:ff:ff:ff
    altname enp33s0f0
7: ens1f4: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 00:07:43:2d:42:70 brd ff:ff:ff:ff:ff:ff
    altname enp4s0f4
8: ens1f4d1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 00:07:43:2d:42:78 brd ff:ff:ff:ff:ff:ff
    altname enp4s0f4d1
9: ens4f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 00:90:fa:97:48:c8 brd ff:ff:ff:ff:ff:ff
    altname enp33s0f1
10: veth0_ep@veth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether c2:5e:dd:d8:6b:16 brd ff:ff:ff:ff:ff:ff
11: veth0@veth0_ep: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master ovs-system state UP mode DEFAULT group default qlen 1000
    link/ether fe:d5:85:82:9c:1b brd ff:ff:ff:ff:ff:ff
12: veth1_ep@veth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether fe:39:bf:59:ef:5c brd ff:ff:ff:ff:ff:ff
13: veth1@veth1_ep: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master ovs-system state UP mode DEFAULT group default qlen 1000
    link/ether 1a:43:38:ad:d0:9c brd ff:ff:ff:ff:ff:ff
19: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether d2:03:de:04:7d:30 brd ff:ff:ff:ff:ff:ff
20: ovs1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether 66:78:aa:32:ba:c8 brd ff:ff:ff:ff:ff:ff
21: ovs0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether ee:90:ea:10:0d:f8 brd ff:ff:ff:ff:ff:ff
23: bond0: <NO-CARRIER,BROADCAST,MULTICAST,MASTER,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
    link/ether 5e:06:a6:fd:89:96 brd ff:ff:ff:ff:ff:ff
[14:09:39@hp-dl380pg8-13 ~]0# ip link show bond0
23: bond0: <NO-CARRIER,BROADCAST,MULTICAST,MASTER,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
    link/ether 5e:06:a6:fd:89:96 brd ff:ff:ff:ff:ff:ff
[14:09:46@hp-dl380pg8-13 ~]0# nmcli c
NAME            UUID                                  TYPE           DEVICE         
nmbond0         300fffdf-6629-48dc-a5a0-bc6d55eceaf2  bond           bond0          
eno1            9093d0bc-0ad2-4e81-abe4-da414efea0cd  ethernet       eno1           
ovs0            fb602394-f58e-42fa-b4aa-5af4d597b2b1  ovs-interface  ovs0           
ovs1            a1d23acc-9ed7-4b8a-a8d5-22a7e1bfe10d  ovs-interface  ovs1           
ovs-br0         cd4a071f-3d63-462d-b3d7-36096bf2f096  ovs-bridge     ovs-br0        
ovs-br1         4ef1d3a1-6bb6-4636-8e8a-c090d3f1749c  ovs-bridge     ovs-br1        
ovs-port-ovs0   091e491b-4606-4d92-b30d-454681de87ca  ovs-port       ovs-port-ovs0  
ovs-port-ovs1   b1e67a69-8d61-460f-80fa-745d94602ee4  ovs-port       ovs-port-ovs1  
ovs-port-veth0  19d9bb60-b83d-4094-8f6a-55901df40530  ovs-port       ovs-port-veth0 
ovs-port-veth1  fcc95d38-c561-40e9-9330-71a3df4490d3  ovs-port       ovs-port-veth1 
veth0           c9cce03e-595c-409b-bc21-8cfdac1ec6f5  ethernet       veth0          
veth1           c4335bea-b3af-4608-9f0e-203207cb9112  ethernet       veth1          
eno2            64e46e65-1ace-473e-83df-b0f793bd764d  ethernet       --             
eno3            5be7f0a5-dac1-4d1c-9124-509977dde63a  ethernet       --             
eno4            03ed342e-0ed7-41f6-9341-d8209ae08db9  ethernet       --             
ens1f4          a07c4493-3303-4167-880d-2626262197f4  ethernet       --             
ens1f4d1        c235a0f5-fa6f-497c-8d34-af7af0f1074a  ethernet       --             
ens4f0          f14476fe-a0a1-4634-9af6-9a0f6661c4b1  ethernet       --             
ens4f1          fdf7264e-daff-41c8-ad3d-af6e3c440228  ethernet       --             
[14:09:50@hp-dl380pg8-13 ~]0# nmstatectl edit nmbond0
/tmp/nmstatelog/2021-11-17-14:10:09-214677074.log
ERROR: No such interface
/tmp/nmstatelog/2021-11-17-14:10:09-214677074.64.log nmstatectl edit nmbond0 return 64
[14:10:09@hp-dl380pg8-13 ~]64# nmstatectl edit bond0
/tmp/nmstatelog/2021-11-17-14:10:13-256674233.log
Applying the following state: 
---
interfaces:
- name: bond0
  type: bond
  state: up
  ipv4:
    enabled: true
    address:
    - ip: 192.168.199.1
      prefix-length: 24
    dhcp: false
  lldp:
    enabled: true
/tmp/nmstatelog/2021-11-17-14:10:13-256674233.0.log nmstatectl edit bond0 return 0
[14:11:32@hp-dl380pg8-13 ~]0# nmcli c
NAME            UUID                                  TYPE           DEVICE         
eno1            9093d0bc-0ad2-4e81-abe4-da414efea0cd  ethernet       eno1           
ovs0            fb602394-f58e-42fa-b4aa-5af4d597b2b1  ovs-interface  ovs0           
ovs1            a1d23acc-9ed7-4b8a-a8d5-22a7e1bfe10d  ovs-interface  ovs1           
nmbond0         300fffdf-6629-48dc-a5a0-bc6d55eceaf2  bond           bond0          
ovs-br0         cd4a071f-3d63-462d-b3d7-36096bf2f096  ovs-bridge     ovs-br0        
ovs-br1         4ef1d3a1-6bb6-4636-8e8a-c090d3f1749c  ovs-bridge     ovs-br1        
ovs-port-ovs0   091e491b-4606-4d92-b30d-454681de87ca  ovs-port       ovs-port-ovs0  
ovs-port-ovs1   b1e67a69-8d61-460f-80fa-745d94602ee4  ovs-port       ovs-port-ovs1  
ovs-port-veth0  19d9bb60-b83d-4094-8f6a-55901df40530  ovs-port       ovs-port-veth0 
ovs-port-veth1  fcc95d38-c561-40e9-9330-71a3df4490d3  ovs-port       ovs-port-veth1 
veth0           c9cce03e-595c-409b-bc21-8cfdac1ec6f5  ethernet       veth0          
veth1           c4335bea-b3af-4608-9f0e-203207cb9112  ethernet       veth1          
eno2            64e46e65-1ace-473e-83df-b0f793bd764d  ethernet       --             
eno3            5be7f0a5-dac1-4d1c-9124-509977dde63a  ethernet       --             
eno4            03ed342e-0ed7-41f6-9341-d8209ae08db9  ethernet       --             
ens1f4          a07c4493-3303-4167-880d-2626262197f4  ethernet       --             
ens1f4d1        c235a0f5-fa6f-497c-8d34-af7af0f1074a  ethernet       --             
ens4f0          f14476fe-a0a1-4634-9af6-9a0f6661c4b1  ethernet       --             
ens4f1          fdf7264e-daff-41c8-ad3d-af6e3c440228  ethernet       --

Comment 9 errata-xmlrpc 2022-05-17 12:32:35 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: nmstate), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2022:2338