Bug 1984277

Summary: [RFE] Allow user to change DNS search only and preserving existing DNS nameservers
Product: Red Hat Enterprise Linux 8 Reporter: Ales Musil <amusil>
Component: nmstateAssignee: Gris Ge <fge>
Status: CLOSED ERRATA QA Contact: Mingyu Shi <mshi>
Severity: medium Docs Contact: Mayur Patil <maypatil>
Priority: high    
Version: 8.4CC: ferferna, fge, jiji, jishi, maypatil, mburman, mperina, network-qe, till
Target Milestone: betaKeywords: FutureFeature, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: nmstate-1.2.1-0.1.alpha1.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 13:34:46 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:    
Bug Blocks: 1983171, 2006093    

Description Ales Musil 2021-07-21 06:45:40 UTC
Description of problem:
Allow user to define static DNS search in a simple apply e.g.:
---
dns-resolver:
  config:
    search:
    - server1
    - server2

It would make sense if this is possible only for default route nics with static IP or auto-dns false.

Comment 2 Gris Ge 2021-09-18 08:45:37 UTC
Hi Ales,

What is nmstate expected to do with name servers for this desire state?

Comment 3 Ales Musil 2021-09-30 09:10:49 UTC
Hi Gris,

the specified search should be added to resolv.conf.

Thanks,
Ales

Comment 4 Gris Ge 2021-10-12 06:31:29 UTC
Hi Ales,

With above desire state, nmstate might think you want EMPTY nameserver and only want to search config which seems incorrect to me.

Are you requesting nmstate to set only the dns server and use nameserver from DHCP?

Comment 5 Ales Musil 2021-10-12 09:00:10 UTC
(In reply to Gris Ge from comment #4)
> Hi Ales,

Hi,
> 
> With above desire state, nmstate might think you want EMPTY nameserver and
> only want to search config which seems incorrect to me.

It would be better if nmstate could apply only search if nameservers are empty but it depends how 
complex it would be to implement. 

> 
> Are you requesting nmstate to set only the dns server and use nameserver
> from DHCP?

This configuration to me makes sense only for static ip or dhcp with "auto-dns=false".

Comment 6 Gris Ge 2021-10-18 06:33:11 UTC
After check with Ales, confirmed customer is expecting to change DNS server only in desire state with existing DNS nameserver persevered.

To test this feature:
 * Applied a state with static DNS setting.
 * Apply below state:

---
dns-resolver:
  config:
    search:
      - example.com
      - example.org

Comment 9 Mingyu Shi 2022-01-24 09:19:42 UTC
Hi Gris,

I understand I can change `search` and don't touch `server`.
But if there is **NO ANY** configured dns server, I cannot configure `search` alone, it that right? For example:

# there is nothing in dns-resolver.config in the beginning:
[17:01:45@dell-per740-80 ~/repo-nmstate/libnmstate]0# nmstatectl show | head -10
---
dns-resolver:
  config: {}
  running:
    search:
    - rhts.eng.pek2.redhat.com
    server:
    - 10.73.2.107
    - 10.73.2.108
    - 10.66.127.10

# then I try adding `search` WITHOUT `server`
echo "
dns-resolver:
  config:
    search:
    - usersys.redhat.com
routes:
  config:
  - destination: 0.0.0.0/0
    metric: 1000
    next-hop-address: 192.168.199.254
    next-hop-interface: veth0
    table-id: 199
interfaces:
- name: veth0
  type: veth
  state: up
  ipv4:
    enabled: true
    address:
    - ip: 192.168.199.1
      prefix-length: 24
  veth:
    peer: veth0_ep
" | nmstatectl apply -

it fails.

Comment 10 Mingyu Shi 2022-01-24 10:40:25 UTC
(In reply to Mingyu Shi from comment #9)
> Hi Gris,
> 
> I understand I can change `search` and don't touch `server`.
> But if there is **NO ANY** configured dns server, I cannot configure
> `search` alone, it that right? For example:
> 
> # there is nothing in dns-resolver.config in the beginning:
> [17:01:45@dell-per740-80 ~/repo-nmstate/libnmstate]0# nmstatectl show | head
> -10
> ---
> dns-resolver:
>   config: {}
>   running:
>     search:
>     - rhts.eng.pek2.redhat.com
>     server:
>     - 10.73.2.107
>     - 10.73.2.108
>     - 10.66.127.10
> 
> # then I try adding `search` WITHOUT `server`
> echo "
> dns-resolver:
>   config:
>     search:
>     - usersys.redhat.com
> routes:
>   config:
>   - destination: 0.0.0.0/0
>     metric: 1000
>     next-hop-address: 192.168.199.254
>     next-hop-interface: veth0
>     table-id: 199
> interfaces:
> - name: veth0
>   type: veth
>   state: up
>   ipv4:
>     enabled: true
>     address:
>     - ip: 192.168.199.1
>       prefix-length: 24
>   veth:
>     peer: veth0_ep
> " | nmstatectl apply -
> 
> it fails.

Discussed with Fernando, let me retell: 
the current situation meets the tile "change DNS search only and preserving existing DNS nameservers" (the `servers` exists).
The current problem is that I cannot add `search` when there is NO any `servers`.
I'm marking the current bug as verified and opening a new BZ for tracking the issue

Comment 11 Mingyu Shi 2022-01-24 11:00:36 UTC
Verified with versions:
nmstate-1.2.1-0.1.alpha1.el8.x86_64
nispor-1.2.3-1.el8.x86_64
NetworkManager-1.36.0-0.4.el8.x86_64

Comment 16 errata-xmlrpc 2022-05-10 13:34:46 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/RHEA-2022:1772