RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1489270 - Cloud-init fails to set dns_servers and dns_search on RHEL 7.4 VM
Summary: Cloud-init fails to set dns_servers and dns_search on RHEL 7.4 VM
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: cloud-init
Version: 7.4
Hardware: Unspecified
OS: Linux
urgent
urgent
Target Milestone: rc
: ---
Assignee: Ryan McCabe
QA Contact: Vladimir
URL:
Whiteboard:
: 1534458 (view as bug list)
Depends On: 1473890
Blocks: 1545525
TreeView+ depends on / blocked
 
Reported: 2017-09-07 05:48 UTC by Alex
Modified: 2021-06-10 12:58 UTC (History)
18 users (show)

Fixed In Version: cloud-init-0.7.9-22.el7
Doc Type: Bug Fix
Doc Text:
Previously, the cloud-init service did not apply the DNS nameserver and DNS domain parameters if they were included in the network configuration for Red Hat Enterprise Linux 7 guest virtual machines. As a consequence, the guests were improperly configured. The nameserver and domain parameters are now applied correctly, and the applied network configuration works as expected.
Clone Of:
: 1545525 (view as bug list)
Environment:
Last Closed: 2018-04-10 14:05:07 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Launchpad 1705804 0 None None None 2017-11-13 15:34:12 UTC
Red Hat Product Errata RHEA-2018:0806 0 normal SHIPPED_LIVE cloud-init bug fix and enhancement update 2018-04-10 12:40:54 UTC

Description Alex 2017-09-07 05:48:44 UTC
Description of problem:

on latest version of cloud-init it does not apply dns_servers nor dns_search parameter on RHEL 7.4 vm created from template on oVirt 4.1.5

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

* RHEL-7.4
* cloud-init-0.7.9-9.el7.x86_64.rpm


How reproducible:

Steps to Reproduce:
1. create a base vm using RHEL 7.4 iso, install cloud-init and poweroff.
2. in oVirt start vm using 'run once', enable cloud-init and add network parameters:

Applied/working:
* IP
* netmask
* gateway

Not applied/not working:
* dns
* dns search

Actual results:


dns and dns search is empty


Additional info:

Related ticket: https://bugzilla.redhat.com/show_bug.cgi?id=1450521

Comment 2 Alex 2017-09-07 05:51:23 UTC
Since I cannot edit previous message:

this happens on a new created vm and also on a template

Comment 3 Ryan McCabe 2017-09-07 17:12:35 UTC
Could you please attach all your config files?

Comment 4 Alex 2017-09-16 15:59:45 UTC
Hi Ryan,

although I am a rhce I am not an expert on this. Could you please tell me which config files should I attach?

Cheers,

Alex

Comment 5 Ryan McCabe 2017-09-18 19:32:11 UTC
Hi,

Any instance metadata, /etc/cloud/cloud.cfg, any network configuration file (network-config), if in use, and anything in /etc/cloud/cloud.cfg.d/, if anything exists there.

Comment 6 Ryan McCabe 2017-09-27 14:08:18 UTC
Still waiting on upstream to take the fixes. The latest release (17.1) and the master branch are still broken.

Comment 7 martin 2017-10-10 18:56:36 UTC
This also is happening in RHEL 7.3.

In /var/log/cloud-init.log I see everything "normal":
--------------------------------------------------------------------
...
2017-10-10 15:43:25,930 - stages.py[DEBUG]: applying net config names for {'version': 1, 'config': [{'subnets': [{'control': 'auto', 'dns_nameservers': ['8.8.8.8'], 'dns_search': ['my.dns.local.domain.com'], '_orig_eni_name': 'eth0', 'netmask': '255.255.255.0', 'address': '192.168.13.55', 'type': 'static', 'gateway': '192.168.13.1'}], 'type': 'physical', 'name': 'eth0'}]}
2017-10-10 15:43:25,930 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.rhel.Distro'>
2017-10-10 15:43:25,931 - __init__.py[DEBUG]: no interfaces to rename
2017-10-10 15:43:25,931 - stages.py[INFO]: Applying network configuration from ds bringup=False: {'version': 1, 'config': [{'subnets': [{'control': 'auto', 'dns_nameservers': ['8.8.8.8'], 'dns_search': ['my.dns.local.domain.com'], '_orig_eni_name': 'eth0', 'netmask': '255.255.255.0', 'address': '192.168.13.55', 'type': 'static', 'gateway': '192.168.13.1'}], 'type': 'physical', 'name': 'eth0'}]}
2017-10-10 15:43:25,936 - util.py[DEBUG]: Writing to /etc/sysconfig//network-scripts/ifcfg-eth0 - wb: [420] 179 bytes
2017-10-10 15:43:25,940 - util.py[DEBUG]: Restoring selinux mode for /etc/sysconfig/network-scripts/ifcfg-eth0 (recursive=False)
2017-10-10 15:43:25,941 - util.py[DEBUG]: Restoring selinux mode for /etc/sysconfig/network-scripts/ifcfg-eth0 (recursive=False)
2017-10-10 15:43:25,951 - util.py[DEBUG]: Reading from /etc/resolv.conf (quiet=False)
2017-10-10 15:43:25,952 - util.py[DEBUG]: Read 30 bytes from /etc/resolv.conf
2017-10-10 15:43:25,952 - util.py[DEBUG]: Writing to /etc/resolv.conf - wb: [420] 101 bytes
2017-10-10 15:43:25,952 - util.py[DEBUG]: Restoring selinux mode for /etc/resolv.conf (recursive=False)
2017-10-10 15:43:25,953 - util.py[DEBUG]: Restoring selinux mode for /etc/resolv.conf (recursive=False)
...
--------------------------------------------------------------------

But the content of /etc/resolv.conf is:
--------------------------------------------------------------------
; Created by cloud-init on instance boot automatically, do not edit.
;
# Generated by NetworkManager
--------------------------------------------------------------------

Comment 12 Vladimir 2017-12-20 10:33:36 UTC
It fails to setup dns search parameter correctly

As discussed via e-mail dns search parameter ends up in nameserver

network_data: 
  "availability_zone" : "nova",
  "hostname" : "dns",
  "launch_index" : "0",
  "meta" : {
    "role" : "server",
    "dsmode" : "local",
    "essential" : "false"
  },
  "name" : "dns",
  "uuid" : "369dc0f8-c75d-48fc-9946-d16c3ab51f2c"
  "services" : [ {
    "address" : "8.8.8.8",
    "type" : "dns-nameserver"
  }, {
    "address" : "search.dns.test",
    "type" : "dns-search"
  } ]

[root@dns ~]# cat /etc/resolv.conf
; Created by cloud-init on instance boot automatically, do not edit.
;
# Generated by NetworkManager
search scl.lab.tlv.redhat.com
nameserver 8.8.8.8
nameserver search.dns.test

P.S. I wasn't able to find anyone who can tell me how to setup dns search using openstack metadata protocol

Comment 13 Ryan McCabe 2017-12-20 14:32:38 UTC
Where did you find the values "dns-nameserver" and "dns-search"? Cloud-init believes the only service that will ever show up is a nameserver, and treats every key there as a nameserver, regardless of the name.

Has anybody reached out to somebody working on nova to figure out what the correct syntax is and whether it is possible to declare dns search in this manner?

Comment 14 Ryan McCabe 2017-12-20 14:44:43 UTC
per https://git.openstack.org/cgit/openstack/nova/tree/nova/virt/netutils.py

It looks like only nameservers are configurable via the services stanza using the 'dns' key.

Comment 15 Vladimir 2017-12-21 08:05:01 UTC
That is strange, because in the docs it has mentions of dns search, maybe not in that particular way but it sure has http://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v1.html

Requirement itself comes from ovirt, and while I'm not quite sure if it's ever worked before, it surely must work.

Comment 16 Ryan McCabe 2017-12-21 14:25:33 UTC
(In reply to Vladimir from comment #15)
> That is strange, because in the docs it has mentions of dns search, maybe
> not in that particular way but it sure has
> http://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v1.
> html
> 
> Requirement itself comes from ovirt, and while I'm not quite sure if it's
> ever worked before, it surely must work.

That syntax is only valid for yaml config. The network_data.json is built to handle openstack's network_data.json, so there is not feature parity between the various ways to configure the networking.

Comment 17 Ryan McCabe 2017-12-21 14:39:48 UTC
It looks like dns_nameservers and dns_search are valid keys under subnets for network_data.json, so you'd put them there instead of inside services. As far as I can tell, the only valid service type (read: key) for services is currently 'dns' and everything you put there is treated as if it is 'dns'.

Comment 19 Ryan McCabe 2018-01-15 14:37:24 UTC
*** Bug 1534458 has been marked as a duplicate of this bug. ***

Comment 20 Vladimir 2018-01-16 16:12:40 UTC
So, it is not cloud-init problem, but how we pass config in RHEV-M, right?

Comment 21 Ryan McCabe 2018-01-16 17:05:08 UTC
Could you paste what's being passed in, just to be completely sure? What you're passing in Comment 12 is not correct for what you want cloud-init to do.

Comment 22 Vladimir 2018-01-18 13:28:27 UTC
here is the network_data 
[root@virt-nested-vm07 payload]# cat /mnt/openstack/latest/network_data.json 
{
  "services" : [ {
    "address" : "1.2.3.4",
    "type" : "dns-nameserver"
  }, {
    "address" : "dns.search.test",
    "type" : "dns-search"
  } ]
}

and here is reolv.conf on the VM

[root@dns_test ~]# cat /etc/resolv.conf
; Created by cloud-init on instance boot automatically, do not edit.
;
# Generated by NetworkManager
nameserver 1.2.3.4
nameserver dns.search.test

Comment 23 Ryan McCabe 2018-01-18 14:16:11 UTC
Yeah, that won't work. The only key cloud-init expects inside services (and the only key nova ever puts there) is 'dns' (for nameservers)

Comment 24 Vladimir 2018-01-25 12:24:25 UTC
Can you please give me an example how to setup dns_search parameter in cloud-init?

Comment 25 Ryan McCabe 2018-01-25 15:49:02 UTC
Here's an example adapted from the test config used in Bug 1519271

{
  "links" : [ {
    "name" : "eth1",
    "id" : "eth1",
    "type" : "vif"
  } ],
  "services" : [ {
    "address" : "search.foo.bar",
    "type" : "dns"
  } ],
  "networks" : [ {
    "netmask" : "255.255.255.0",
    "link" : "eth1",
    "id" : "eth1",
    "ip_address" : "10.0.0.1",
    "type" : "ipv4",
    "gateway" : "10.0.0.254",
    "dns_search": "search.example.com"
  }, {
    "link" : "eth1",
    "id" : "eth1",
    "type" : "ipv6_dhcp"
  } ]
}

Comment 26 Ryan McCabe 2018-01-25 15:50:23 UTC
The only real change is the 
    "dns_search": "search.example.com"
under networks

Comment 27 Vladimir 2018-02-08 13:04:48 UTC
Verified manually using Openstack metadata format using
cloud-init-0.7.9-22.el7.x86_64

Checked following scenarios:
1. Set DNS server
2. Set DNS search
3. Set both DNS server and DNS search

Example format 
{
  "links" : [ {
    "name" : "eth1",
    "id" : "eth1",
    "type" : "vif"
  } ],
 "services" : [ {
    "address" : "1.2.3.4",
    "type" : "dns-nameserver"
  }],
  "networks" : [ {
    "netmask" : "255.255.255.0",
    "link" : "eth1",
    "id" : "eth1",
    "ip_address" : "10.0.0.1",
    "type" : "ipv4",
    "gateway" : "10.0.0.254",
    "dns_search": "search.example.test"
  }, {
    "link" : "eth1",
    "id" : "eth1",
    "type" : "ipv6_dhcp"
  } ]

Comment 28 meital avital 2018-02-08 13:49:17 UTC
moving to verified according to comment 27

Comment 36 errata-xmlrpc 2018-04-10 14:05:07 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, 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-2018:0806


Note You need to log in before you can comment on or make changes to this bug.