1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

addons: address: catching and logging exception coming from ip batch execution

Ticket: CM-8610
Reviewed By: Roopa, Nikhil G
Testing Done:

It used to be a silent exception, but not anymore because we catch it and log
accordingly (error) and flag the ifaceobj so that ifupdown2 returns 1.

$ cat /etc/network/interfaces
auto tap0
iface tap0
      mtu 9000
            address 172.17.28.0/31

$ ifreload -a
$ echo "address 2002:17:27:17/120" >> /etc/network/interfaces
$ ifreload -a
$ echo $?
0
$ # applying this patch
$ ifreload -a
error: tap0: cmd 'ip -force -batch - [addr add 172.17.28.0/31 dev tap0
addr add 2002:17:27:17/120 dev tap0
]' failed: returned 1 (RTNETLINK answers: File exists
Command failed -:1
Error: an inet prefix is expected rather than "2002:17:27:17/120".
)
$ echo $?
1
$

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
Julien Fortin
2016-08-10 15:08:38 +02:00
parent 9d3f53c6c9
commit 093ffa0028

View File

@ -332,7 +332,11 @@ class address(moduleBase):
alias = ifaceobj.get_attr_value_first('alias')
if alias:
self.ipcmd.link_set_alias(ifaceobj.name, alias)
self.ipcmd.batch_commit()
try:
self.ipcmd.batch_commit()
except Exception as e:
self.logger.error('%s: %s' % (ifaceobj.name, str(e)))
ifaceobj.set_status(ifaceStatus.ERROR)
hwaddress = self._get_hwaddress(ifaceobj)
if hwaddress: