neutron/neutron/cmd
Ihar Hrachyshka da215ba3dd Make use of -w argument for iptables calls
Upstream iptables added support for -w ('wait') argument to
iptables-restore. It makes the command grab a 'xlock' that guarantees
that no two iptables calls will mess a table if called in parallel.
[This somewhat resembles what we try to achieve with a file lock we
grab in iptables manager's _apply_synchronized.]

If two processes call to iptables-restore or iptables in parallel, the
second call risks failing, returning error code = 4, and also printing
the following error:

    Another app is currently holding the xtables lock. Perhaps you want
    to use the -w option?

If we call to iptables / iptables-restore with -w though, it will wait
for the xlock release before proceeding, and won't fail.

Though the feature was added in iptables/master only and is not part of
an official iptables release, it was already backported to RHEL 7.x
iptables package, and so we need to adopt to it. At the same time, we
can't expect any underlying platform to support the argument.

A solution here is to call iptables-restore with -w when a regular call
failed. Also, the patch adds -w to all iptables calls, in the iptables
manager as well as in ipset-cleanup.

Since we don't want to lock agent in case current xlock owner doesn't
release it in reasonable time, we limit the time we wait to ~1/3 of
report_interval, to give the agent some time to recover without
triggering expensive fullsync.

In the future, we may be able to get rid of our custom synchronization
lock that we use in iptables manager. But this will require all
supported platforms to get the feature in and will take some time.

Closes-Bug: #1712185
Change-Id: I94e54935df7c6caa2480eca19e851cb4882c0f8b
(cherry picked from commit a521bf0393)
2017-09-06 15:28:11 +00:00
..
eventlet use service type constants from neutron_lib plugins 2017-06-27 15:16:05 -06:00
sanity Fix test_keepalived_ipv6_support for Keepalived v1.2.20 2017-08-24 09:02:42 +00:00
__init__.py Fix logging error for Guru Meditation Report 2016-02-08 16:52:17 -08:00
ipset_cleanup.py Make use of -w argument for iptables calls 2017-09-06 15:28:11 +00:00
keepalived_state_change.py Replace keepalived notifier bash script with Python ip monitor 2015-03-18 18:59:33 -04:00
linuxbridge_cleanup.py Make code follow log translation guideline 2017-08-14 10:53:33 -07:00
netns_cleanup.py Make code follow log translation guideline 2017-08-14 10:53:33 -07:00
ovs_cleanup.py Make code follow log translation guideline 2017-08-14 10:53:33 -07:00
pd_notify.py neutron-lib: use replace_file from neutron lib 2016-11-07 09:18:41 +00:00
runtime_checks.py Move dhcp_release6_supported to runtime checks file 2017-02-15 16:29:01 -06:00
sanity_check.py Make code follow log translation guideline 2017-08-14 10:53:33 -07:00