Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1406651

Summary: setupNetworks fails if there is an empty line in the ifcfg files
Product: Red Hat Enterprise Virtualization Manager Reporter: nijin ashok <nashok>
Component: vdsmAssignee: Edward Haas <edwardh>
Status: CLOSED CURRENTRELEASE QA Contact: Michael Burman <mburman>
Severity: low Docs Contact:
Priority: high    
Version: 4.0.5CC: amarchuk, bazulay, danken, gklein, lsurette, nashok, srevivo, ycui, ykaul, ylavi
Target Milestone: ovirt-4.0.6   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-01-16 15:37:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Network RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description nijin ashok 2016-12-21 06:49:56 UTC
Description of problem:

setupNetworks will fail with below error when an empty line is in ifcfg* files before "DEVICE" option. 

==
MainProcess|jsonrpc.Executor/1::ERROR::2016-12-21 04:46:32,278::supervdsmServer::96::SuperVdsm.ServerCallback::(wrapper) Error in setupNetworks
Traceback (most recent call last):
  File "/usr/share/vdsm/supervdsmServer", line 94, in wrapper
    res = func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/vdsm/network/api.py", line 249, in setupNetworks
    _setup_networks(networks, bondings, options)
  File "/usr/lib/python2.7/site-packages/vdsm/network/api.py", line 277, in _setup_networks
    netswitch.setup(networks, bondings, options, in_rollback)
  File "/usr/lib/python2.7/site-packages/vdsm/network/netswitch.py", line 132, in setup
    _setup_legacy(legacy_nets, legacy_bonds, options, in_rollback)
  File "/usr/lib/python2.7/site-packages/vdsm/network/netswitch.py", line 153, in _setup_legacy
    bondings, _netinfo)
  File "/usr/lib/python2.7/site-packages/vdsm/network/legacy_switch.py", line 475, in add_missing_networks
    _netinfo=_netinfo, **attrs)
  File "/usr/lib/python2.7/site-packages/vdsm/network/legacy_switch.py", line 183, in wrapped
    return func(network, configurator, **kwargs)
  File "/usr/lib/python2.7/site-packages/vdsm/network/legacy_switch.py", line 254, in _add_network
    net_ent_to_configure.configure(**options)
  File "/usr/lib/python2.7/site-packages/vdsm/network/models.py", line 187, in configure
    self.configurator.configureBridge(self, **opts)
  File "/usr/lib/python2.7/site-packages/vdsm/network/configurators/ifcfg.py", line 110, in configureBridge
  File "/usr/lib/python2.7/site-packages/vdsm/network/configurators/ifcfg.py", line 342, in normalize_device_filename
    key, value = line.rstrip().split('=', 1)
ValueError: need more than 1 value to unpack
==

We are iterating through all ifcfg-* files and this will fails if there is a blank line before "DEVICE" in the configuration.

with open(ifcfg_file) as f:
   for line in f:
     if line.startswith('#'):
       continue
     key, value = line.rstrip().split('=', 1)  



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

vdsm-4.18.15.3-1.el7ev.x86_64

How reproducible:

100%

Steps to Reproduce:

1. Add a blank line before "DEVICE=" option in any of the ifcfg-* files.

2. Add a network from RHEV-M and setupNetworks will fail with mentioned error.

Actual results:

setupNetworks fails if there is an empty line in the ifcfg files 

Expected results:

setupNetworks should run good by ignoring the empty lines. 

Additional info:

Comment 2 Dan Kenigsberg 2016-12-21 07:23:49 UTC
Any background who created the empty ifcfg file and why?

Comment 3 nijin ashok 2016-12-21 07:39:54 UTC
(In reply to Dan Kenigsberg from comment #2)
> Any background who created the empty ifcfg file and why?

It's an empty line in the ifcfg file and not a complete empty file. 

For the customer case, he was having a zip file named as "ifcfg-scripts.zip" which contains backup of the ifcfg file and hence this was failing with the mentioned error. After removing zip file, it was working good.

The issue can also happen if there is an empty line in any of the NICs configuration file. Attached log is from my test environment where I manually add a empty line in one of the configuration file to simulate the issue.

Comment 4 Dan Kenigsberg 2016-12-21 07:58:02 UTC
This is a 4.0.5 regression, solved by https://gerrit.ovirt.org/#/c/66159/ in 4.0.6.

Comment 6 Michael Burman 2016-12-21 13:52:26 UTC
Verified on - vdsm-4.18.21-1.el7ev.x86_64

Comment 7 Anton Marchukov 2017-01-16 15:37:24 UTC
Fixed in https://rhn.redhat.com/errata/RHBA-2017-0044.html