Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1534458

Summary: Cloud-init fails in our cluster with KeyError: 'dns_search' and doesn't assign an IP to instance
Product: Red Hat Enterprise Linux 7 Reporter: cristi falcas <cristi.falcas>
Component: cloud-initAssignee: Ryan McCabe <rmccabe>
Status: CLOSED DUPLICATE QA Contact: Vratislav Hutsky <vhutsky>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: jbadiapa, jgreguske, lars, mmagr, mrunge
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-01-15 14:37:24 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 cristi falcas 2018-01-15 10:02:15 UTC
Description of problem:
Cloud-init fails in our cluster with KeyError: 'dns_search' and doesn't assign an IP to instance


Version-Release number of selected component (if applicable):
cloud-init-0.7.9-20.el7.x86_64
openstack-glance-2014.2.3-1.el7.noarch
openstack-keystone-2014.2.2-1.el7.noarch
openstack-nova-console-2014.2.2-1.el7.noarch
openstack-neutron-ml2-2014.2.3-1.el7.noarch
openstack-cinder-2014.2.3-3.el7.noarch
openstack-nova-objectstore-2014.2.2-1.el7.noarch
openstack-neutron-vpn-agent-2014.2.3-1.el7.noarch
openstack-nova-api-2014.2.2-1.el7.noarch
openstack-dashboard-2014.2.2-1.el7.noarch
openstack-neutron-metering-agent-2014.2.3-1.el7.noarch
openstack-nova-scheduler-2014.2.2-1.el7.noarch
openstack-nova-compute-2014.2.2-1.el7.noarch
openstack-nova-common-2014.2.2-1.el7.noarch
openstack-nova-novncproxy-2014.2.2-1.el7.noarch
openstack-utils-2014.2-1.el7.centos.noarch
openstack-nova-conductor-2014.2.2-1.el7.noarch
openstack-neutron-openvswitch-2014.2.3-1.el7.noarch
openstack-neutron-2014.2.3-1.el7.noarch
openstack-nova-cert-2014.2.2-1.el7.noarch


How reproducible:
Always

Steps to Reproduce:
1. boot a new machine
2. wait to finish boot
3. try to login

Actual results:
During boot, this exception is thrown:
2018-01-15 11:44:01,750 - util.py[WARNING]: failed stage init-local
failed run of stage init-local
------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cloudinit/cmd/main.py", line 513, in status_wrapper
    ret = functor(name, args)
  File "/usr/lib/python2.7/site-packages/cloudinit/cmd/main.py", line 269, in main_init
    init.apply_network_config(bring_up=bool(mode != sources.DSMODE_LOCAL))
  File "/usr/lib/python2.7/site-packages/cloudinit/stages.py", line 642, in apply_network_config
    return self.distro.apply_network_config(netcfg, bring_up=bring_up)
  File "/usr/lib/python2.7/site-packages/cloudinit/distros/__init__.py", line 150, in apply_network_config
    dev_names = self._write_network_config(netconfig)
  File "/usr/lib/python2.7/site-packages/cloudinit/distros/rhel.py", line 60, in _write_network_config
    self._net_renderer.render_network_state("/", ns)
  File "/usr/lib/python2.7/site-packages/cloudinit/net/sysconfig.py", line 556, in render_network_state
    network_state).items():
  File "/usr/lib/python2.7/site-packages/cloudinit/net/sysconfig.py", line 535, in _render_sysconfig
    cls._render_physical_interfaces(network_state, iface_contents)
  File "/usr/lib/python2.7/site-packages/cloudinit/net/sysconfig.py", line 447, in _render_physical_interfaces
    cls._render_subnets(iface_cfg, iface_subnets)
  File "/usr/lib/python2.7/site-packages/cloudinit/net/sysconfig.py", line 368, in _render_subnets
    if isinstance(subnet['dns_search'], (list, tuple)):
KeyError: 'dns_search'
------------------------------------------------------------


Expected results:
Instance should have an IP assigned

Additional info:
I now that our openstack instance is very old, but the fix is really simple:
in /usr/lib/python2.7/site-packages/cloudinit/net/sysconfig.py, line 368, just check if the key exists first:

if 'dns_search' in subnet and isinstance(subnet['dns_search'], (list, tuple)):

Comment 2 Ryan McCabe 2018-01-15 14:37:24 UTC
Thanks for catching this. This looks like a typo introduced as part of the fix for Bug 1489270, so I am going to dupe it into that.

*** This bug has been marked as a duplicate of bug 1489270 ***