Bug 1850698

Summary: [Regression] Cannot remove static DNS configure
Product: Red Hat Enterprise Linux 8 Reporter: Gris Ge <fge>
Component: nmstateAssignee: Gris Ge <fge>
Status: CLOSED ERRATA QA Contact: Mingyu Shi <mshi>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 8.4CC: dholler, ferferna, jiji, jishi, mburman, mshi, network-qe, till
Target Milestone: rcKeywords: Regression
Target Release: 8.3Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: nmstate-0.3.2-2.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 03:08:54 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:

Description Gris Ge 2020-06-24 18:12:01 UTC
Description of problem:

Cannot apply this state:

---
dns-resolver:
  config:
    server: []



Version-Release number of selected component (if applicable):
nmstate-0.3.2-1.el8

How reproducible:
100%

Steps to Reproduce:
echo '---
dns-resolver:
  config:
    server: []' | sudo nmstatectl set

Actual results:

libnmstate.error.NmstateVerificationError:

Expected results:

No error

Additional info:

Workaround would be using

---
dns-resolver:
  config:
    search: []
    server: []

Comment 2 Mingyu Shi 2020-06-28 07:23:57 UTC
ACKed

Comment 5 Mingyu Shi 2020-07-06 11:11:15 UTC
Hi Gris, I got this error, can you have a look?

[19:02:52@ibm-x3650m4-01-vm-05 ~]0# echo '---
> dns-resolver:
>   config:
>     server: []' | sudo nmstatectl set
2020-07-06 19:07:33,603 root         DEBUG    Async action: Create checkpoint started
2020-07-06 19:07:33,607 root         DEBUG    Checkpoint None created for all devices
2020-07-06 19:07:33,607 root         DEBUG    Async action: Create checkpoint finished
2020-07-06 19:07:38,834 root         DEBUG    Checkpoint /org/freedesktop/NetworkManager/Checkpoint/1 rollback executed
2020-07-06 19:07:38,834 root         DEBUG    Async action: Rollback to checkpoint /org/freedesktop/NetworkManager/Checkpoint/1 started
2020-07-06 19:07:38,837 root         DEBUG    Checkpoint /org/freedesktop/NetworkManager/Checkpoint/1 rollback executed
2020-07-06 19:07:38,837 root         DEBUG    Interface lo rollback succeeded
2020-07-06 19:07:38,838 root         DEBUG    Interface ens3 rollback succeeded
2020-07-06 19:07:38,838 root         DEBUG    Async action: Rollback to checkpoint /org/freedesktop/NetworkManager/Checkpoint/1 finished
Traceback (most recent call last):
  File "/bin/nmstatectl", line 11, in <module>
    load_entry_point('nmstate==0.3.2', 'console_scripts', 'nmstatectl')()
  File "/usr/lib/python3.6/site-packages/nmstatectl/nmstatectl.py", line 67, in main
    return args.func(args)
  File "/usr/lib/python3.6/site-packages/nmstatectl/nmstatectl.py", line 265, in apply
    args.save_to_disk,
  File "/usr/lib/python3.6/site-packages/nmstatectl/nmstatectl.py", line 287, in apply_state
    save_to_disk=save_to_disk,
  File "/usr/lib/python3.6/site-packages/libnmstate/netapplier.py", line 71, in apply
    _apply_ifaces_state(plugins, net_state, verify_change, save_to_disk)
  File "/usr/lib/python3.6/site-packages/libnmstate/netapplier.py", line 115, in _apply_ifaces_state
    _verify_change(plugins, net_state)
  File "/usr/lib/python3.6/site-packages/libnmstate/netapplier.py", line 120, in _verify_change
    net_state.verify(current_state)
  File "/usr/lib/python3.6/site-packages/libnmstate/net_state.py", line 64, in verify
    self._dns.verify(current_state.get(DNS.KEY))
  File "/usr/lib/python3.6/site-packages/libnmstate/dns.py", line 189, in verify
    {DNS.KEY: self.config}, {DNS.KEY: cur_dns.config},
libnmstate.error.NmstateVerificationError: 
desired
=======
---
dns-resolver:
  server: []

current
=======
---
dns-resolver:
  search: []
  server: []

difference
==========
--- desired
+++ current
@@ -1,3 +1,4 @@
 ---
 dns-resolver:
+  search: []
   server: []


Versions:
nmstate-0.3.2-6.el8.noarch
NetworkManager-1.26.0-0.2.el8.x86_64

Comment 6 Gris Ge 2020-07-06 11:56:06 UTC
Thanks. I will work on a new patch.

Comment 8 Mingyu Shi 2020-07-17 07:09:11 UTC
Verified with versions:
nmstate-0.3.3-2.el8.noarch
NetworkManager-1.26.0-1.el8.x86_64
DISTRO=RHEL-8.3.0-20200716.n.0
Linux hp-dl388g8-04.rhts.eng.pek2.redhat.com 4.18.0-226.el8.x86_64 #1 SMP Wed Jul 15 07:40:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

An RFE is opened for this result: #bz1858187

[15:05:36@hp-dl388g8-04 ~]0# cat temp.yaml 
---
dns-resolver:
  config:
    search:
    - veth0.lan
    - veth0.lan0
    server:
    - 10.68.5.26
    - 10.72.17.5
    - 8.8.8.8
    - 8.8.8.9
interfaces:
- name: veth0
  state: up
  ipv4:
    address:
    - ip: 1.0.0.1
      prefix-length: 24
    enabled: true
routes:
  config:
  - destination: 0.0.0.0/0
    next-hop-address: 1.0.0.254
    next-hop-interface: veth0
[15:05:38@hp-dl388g8-04 ~]0# nmstatectl set temp.yaml 
2020-07-17 15:05:51,595 root         DEBUG    Async action: Create checkpoint started
2020-07-17 15:05:51,598 root         DEBUG    Checkpoint None created for all devices
2020-07-17 15:05:51,598 root         DEBUG    Async action: Create checkpoint finished
2020-07-17 15:05:51,600 root         DEBUG    Async action: Add profile: veth0 started
2020-07-17 15:05:51,605 root         DEBUG    Async action: Add profile: veth0 finished
2020-07-17 15:05:51,607 root         DEBUG    Async action: Activate profile: veth0 started
2020-07-17 15:05:51,609 root         DEBUG    Connection activation initiated: dev=veth0, con-state=<enum NM_ACTIVE_CONNECTION_STATE_ACTIVATING of type NM.ActiveConnectionState>
2020-07-17 15:05:51,630 root         DEBUG    Connection activation succeeded: dev=veth0, con-state=<enum NM_ACTIVE_CONNECTION_STATE_ACTIVATED of type NM.ActiveConnectionState>, dev-state=<enum NM_DEVICE_STATE_ACTIVATED of type NM.DeviceState>, state-flags=<flags NM_ACTIVATION_STATE_FLAG_LAYER2_READY | NM_ACTIVATION_STATE_FLAG_IP4_READY | NM_ACTIVATION_STATE_FLAG_IP6_READY of type NM.ActivationStateFlags>
2020-07-17 15:05:51,630 root         DEBUG    Async action: Activate profile: veth0 finished
2020-07-17 15:05:51,670 root         DEBUG    Async action: Destroy checkpoint /org/freedesktop/NetworkManager/Checkpoint/45 started
2020-07-17 15:05:51,673 root         DEBUG    Checkpoint /org/freedesktop/NetworkManager/Checkpoint/45 destroyed
2020-07-17 15:05:51,673 root         DEBUG    Async action: Destroy checkpoint /org/freedesktop/NetworkManager/Checkpoint/45 finished
Desired state applied: 
---
dns-resolver:
  config:
    search:
    - veth0.lan
    - veth0.lan0
    server:
    - 10.68.5.26
    - 10.72.17.5
    - 8.8.8.8
    - 8.8.8.9
routes:
  config:
  - destination: 0.0.0.0/0
    next-hop-address: 1.0.0.254
    next-hop-interface: veth0
interfaces:
- name: veth0
  state: up
  ipv4:
    enabled: true
    address:
    - ip: 1.0.0.1
      prefix-length: 24
[15:05:51@hp-dl388g8-04 ~]0# cat no-server.yaml 
---
dns-resolver:
  config:
    server: []
[15:06:07@hp-dl388g8-04 ~]0# nmstatectl set no-server.yaml 
2020-07-17 15:06:12,491 root         DEBUG    Async action: Create checkpoint started
2020-07-17 15:06:12,495 root         DEBUG    Checkpoint None created for all devices
2020-07-17 15:06:12,495 root         DEBUG    Async action: Create checkpoint finished
2020-07-17 15:06:12,498 root         DEBUG    Async action: Update profile: veth0 started
2020-07-17 15:06:12,502 root         DEBUG    Async action: Update profile: veth0 finished
2020-07-17 15:06:12,503 root         DEBUG    Async action: Reapply device config: veth0 started
2020-07-17 15:06:12,507 root         DEBUG    Async action: Reapply device config: veth0 finished
2020-07-17 15:06:12,544 root         DEBUG    Async action: Destroy checkpoint /org/freedesktop/NetworkManager/Checkpoint/46 started
2020-07-17 15:06:12,547 root         DEBUG    Checkpoint /org/freedesktop/NetworkManager/Checkpoint/46 destroyed
2020-07-17 15:06:12,547 root         DEBUG    Async action: Destroy checkpoint /org/freedesktop/NetworkManager/Checkpoint/46 finished
Desired state applied: 
---
dns-resolver:
  config:
    server: []

# all the static dns configs were removed:
[15:06:12@hp-dl388g8-04 ~]0# nmstatectl show | head -30
---
dns-resolver:
  config:
    search: []
    server: []
  running:
    search:
    - rhts.eng.pek2.redhat.com
    server:
    - 10.73.2.107
    - 10.73.2.108
    - 10.66.127.10
route-rules:
  config: []
routes:
  config:
  - destination: 0.0.0.0/0
    metric: -1
    next-hop-address: 1.0.0.254
    next-hop-interface: veth0
    table-id: 0
  running:
  - destination: 0.0.0.0/0
    metric: 100
    next-hop-address: 10.73.131.254
    next-hop-interface: eno1
    table-id: 254
  - destination: 10.73.130.0/23
    metric: 100
    next-hop-address: ''
[15:06:25@hp-dl388g8-04 ~]0# cat /etc/resolv.conf 
# Generated by NetworkManager
search rhts.eng.pek2.redhat.com
nameserver 10.73.2.107
nameserver 10.73.2.108
nameserver 10.66.127.10

Comment 11 errata-xmlrpc 2020-11-04 03:08:54 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 (nmstate bug fix and enhancement update), 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/RHBA-2020:4696