Skip to content

Commit

Permalink
db_manage v1.3: Fix clean_subnet_addr_alloc method
Browse files Browse the repository at this point in the history
Don't build flatten VN/subnet list versions before stale VN were clean

Change-Id: I9247654b344fade58f3026cb5b3185cd8b044b83
Closes-Bug: #1768265
  • Loading branch information
Édouard Thuleau committed May 2, 2018
1 parent eefb4c4 commit a772013
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/config/api-server/vnc_cfg_api_server/db_manage.py
Expand Up @@ -30,12 +30,15 @@
from vnc_cfg_ifmap import VncServerCassandraClient
import schema_transformer.db

__version__ = "1.2"
__version__ = "1.3"
"""
NOTE: As that script is not self contained in a python package and as it
supports multiple Contrail releases, it brings its own version that needs to be
manually updated each time it is modified. We also maintain a change log list
in that header:
* 1.3:
- Fix issue in the VN/subnet/IP address zookeeper lock clean method
'clean_subnet_addr_alloc' which tried to clean 2 times same stale lock
* 1.2:
- Re-define the way the script recovers the route target inconsistencies.
The source of trust move from the schema transformer DB to the
Expand Down Expand Up @@ -1962,19 +1965,6 @@ def clean_subnet_addr_alloc(self):
logger.info("Deleting zk path: %s", path)
self._zk_client.delete(path, recursive=True)

zk_all_vn_sn = []
for vn_key, vn in zk_all_vns.items():
zk_all_vn_sn.extend([(vn_key, sn_key) for sn_key in vn])
cassandra_all_vn_sn = []
# ignore subnet without address and not lock in zk
for vn_key, vn in cassandra_all_vns.items():
for sn_key, addrs in vn.items():
if not addrs['addrs']:
if (vn_key not in zk_all_vns or
sn_key not in zk_all_vns[vn_key]):
continue
cassandra_all_vn_sn.extend([(vn_key, sn_key)])

# Clean extra net in zk
extra_vn = set(zk_all_vns.keys()) - set(cassandra_all_vns.keys())
for vn in extra_vn:
Expand All @@ -1988,6 +1978,19 @@ def clean_subnet_addr_alloc(self):
self._zk_client.delete(path, recursive=True)
zk_all_vns.pop(vn, None)

zk_all_vn_sn = []
for vn_key, vn in zk_all_vns.items():
zk_all_vn_sn.extend([(vn_key, sn_key) for sn_key in vn])
cassandra_all_vn_sn = []
# ignore subnet without address and not lock in zk
for vn_key, vn in cassandra_all_vns.items():
for sn_key, addrs in vn.items():
if not addrs['addrs']:
if (vn_key not in zk_all_vns or
sn_key not in zk_all_vns[vn_key]):
continue
cassandra_all_vn_sn.extend([(vn_key, sn_key)])

# Clean extra subnet in zk
extra_vn_sn = set(zk_all_vn_sn) - set(cassandra_all_vn_sn)
for vn, sn_key in extra_vn_sn:
Expand Down

0 comments on commit a772013

Please sign in to comment.