DuplicateError while parsing ifcfg-ethX

Bug #1448594 reported by Roopak Parikh
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Won't Fix
Undecided
Unassigned

Bug Description

I have a VirtualMachine image (Scientific Linux 6.4) which has a static IP address assigned to it. Using Openstack and using 'config-drive' we tried to boot a new VirtualMachine from that image, config-drive, the ISO contains a new 'static-ip' address. Cloud-init recognizes that and tries to read the existing /etc/sysconfig/network-scripts/ifcfg-eth0 and fails with the following error:

---

Apr 24 18:04:13 rparikh-sl6-w-cloud-init [CLOUDINIT] util.py[DEBUG]: Getting data from <class 'cloudinit.sources.DataSourceConfigDrive.DataSourceConfigDrive'> failed#012Traceback (most recent call last):#012 File "/usr/lib/python2.6/site-packages/cloudinit/sources/__init__.py", line 243, in find_source#012 if s.get_data():#012 File "/usr/lib/python2.6/site-packages/cloudinit/sources/DataSourceConfigDrive.py", line 212, in get_data#012 self.helper.on_first_boot(results)#012 File "/usr/lib/python2.6/site-packages/cloudinit/sources/DataSourceConfigDrive.py", line 54, in on_first_boot#012 self.distro.apply_network(data['network_config'])#012 File "/usr/lib/python2.6/site-packages/cloudinit/distros/__init__.py", line 116, in apply_network#012 dev_names = self._write_network(settings)#012 File "/usr/lib/python2.6/site-packages/cloudinit/distros/rhel.py", line 85, in _write_network#012 rhel_util.update_sysconfig_file(net_fn, net_cfg)#012 File "/usr/lib/python2.6/site-packages/cloudinit/distros/rhel_util.py", line 125, in update_sysconfig_file#012 (exists, contents) = read_sysconfig_file(fn)#012 File "/usr/lib/python2.6/site-packages/cloudinit/distros/rhel_util.py", line 153, in read_sysconfig_file#012 return (exists, SysConf(contents))#012 File "/usr/lib/python2.6/site-packages/cloudinit/distros/parsers/sys_conf.py", line 60, in __init__#012 write_empty_values=True)#012 File "/usr/lib/python2.6/site-packages/configobj.py", line 1219, in __init__#012 self._load(infile, configspec)#012 File "/usr/lib/python2.6/site-packages/configobj.py", line 1302, in _load#012 raise error#012DuplicateError: Duplicate keyword name at line 24.

-----

The problem seems to be duplicate keys in the ifcfg-eth0, we can try and fix this image, but there are probably others with the same settings and in general I would assume parsing should be resilient to these failures. In addition I am not sure if I understand the logic behind reading the current ifcfg and modifying it, we should be able to simplify it by overwriting (a backup can be taken for debugging purposes) the ifcfg file.

Attached is a screenshot with contents of the ifcfg file.

Revision history for this message
Roopak Parikh (rparikh) wrote :
Revision history for this message
Dan Watkins (oddbloke) wrote :

Hi Roopak,

Sorry we haven't go to this before, but we are doing bug triage now. Is this still an issue you're seeing?

Thanks!

Changed in cloud-init:
status: New → Incomplete
Revision history for this message
Roopak Parikh (rparikh) wrote :

I haven't looked at the code in the last few years, so not sure if this is fixed or not. Since no one else has complained and it was observed on the 6.x CentOS, I am ok to close it as stale entry and may not be applicable anymore.

Revision history for this message
Dan Watkins (oddbloke) wrote :

Thanks Roopak!

Changed in cloud-init:
status: Incomplete → Won't Fix
Revision history for this message
James Falcon (falcojr) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.