More info on rollback during transaction error

27 views
Skip to first unread message

Anoop Joseph Babu

unread,
Jul 4, 2017, 2:53:29 PM7/4/17
to pyroute2-dev
Hi,

I have below transaction with addition of three IP addresses to eth0 interface. One of them is an invalid IP address to force error during commit.

>>>from pyroute2 import IPDB
>>>ipdb = IPDB()

>>>ipdb.interfaces.eth0.add_ip('2.1.1.1/24')
>>>ipdb.interfaces.eth0.add_ip('1.1.1/24')  # wrong ip address to raise error
>>>ipdb.interfaces.eth0.add_ip('1.1.1.1/24')

>>> ipdb.interfaces.eth0.review()
{'map': None, '-vlans': set([]), 'stats': None, '-ports': set([]), 'protinfo': None, '-ipaddr': set([]), '+ports': set([]), 'stats64': None, 'af_spec': None, '+vlans': set([]), '+ipaddr': (('2.1.1.1', 24), ('1.1.1', 24), ('1.1.1.1', 24)), 'linkinfo': None}

>>>
ipdb.interfaces.eth0.commit()
Traceback (most recent call last):
 
File "<stdin>", line 1, in <module>
 
File "/usr/lib/python2.7/site-packages/pyroute2/ipdb/interfaces.py", line 1040, in commit
   
raise error
socket
.error: illegal IP address string passed to inet_pton



The commit fails as expected, but 2.1.1.1/24 is added to eth0 and is not rolled back.
[root@localhost ~]# ip a s eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:cb:d7:ff brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0
       valid_lft 80635sec preferred_lft 80635sec
    inet 2.1.1.1/24 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::ce02:a084:585f:b8/64 scope link
       valid_lft forever preferred_lft forever


From the documentation http://docs.pyroute2.org/ipdb.html, I understands that "One failed operation during commit() rolls back all the changes, has been made so far."
Please provide more information on roll back during failure.

Peter Saveliev

unread,
Jul 4, 2017, 4:04:17 PM7/4/17
to Anoop Joseph Babu, pyroute2-dev
Yes, it's correct — all added addresses should be rolled back, and that's how it works in the test I run now. Which library version do you use?

Just in case I run the test in a loop now, maybe it's a race condition… How often it's reproduced? Always, sometimes?

--
You received this message because you are subscribed to the Google Groups "pyroute2-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyroute2-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anoop Joseph Babu

unread,
Jul 4, 2017, 10:04:08 PM7/4/17
to pyroute2-dev, manoop...@gmail.com
This is consistently happening in my system.

I am using pyroute2 version 0.4.17 running on CentOS Linux release 7.3.1611 (Core)


[root@localhost ~]# pip show pyroute2
---
Metadata-Version: 1.1
Name: pyroute2
Version: 0.4.17
Summary: Python Netlink library
Author: Peter V. Saveliev
Author-email: pe...@svinota.eu
License: dual license GPLv2+ and Apache v2
Location: /usr/lib/python2.7/site-packages
Requires:
Classifiers:
  License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
  License :: OSI Approved :: Apache Software License
  Programming Language :: Python
  Topic :: Software Development :: Libraries :: Python Modules
  Topic :: System :: Networking
  Topic :: System :: Systems Administration
  Operating System :: POSIX :: Linux
  Intended Audience :: Developers
  Intended Audience :: System Administrators
  Intended Audience :: Telecommunications Industry
  Programming Language :: Python :: 2.6
  Programming Language :: Python :: 2.7
  Programming Language :: Python :: 3
  Development Status :: 4 - Beta


To unsubscribe from this group and stop receiving emails from it, send an email to pyroute2-dev...@googlegroups.com.

Peter Saveliev

unread,
Jul 5, 2017, 6:17:38 AM7/5/17
to Anoop Joseph Babu, pyroute2-dev
> This is consistently happening in my system.

That's good, easier to debug. Ok, give me some time, I try to reproduce it on the same platform locally.

To unsubscribe from this group and stop receiving emails from it, send an email to pyroute2-dev+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages