db purge: raise on missing tables
If running with invalid db config, we get no tables and the command silently finished. Change that and raise some suspicion instead. Closes-bug: #2124043 Co-authored-by: Maurice Escher <maurice.escher@sap.com> Change-Id: Ie26b05bdd13a4c54ca958056352fab04ceaa9140 Signed-off-by: Kiran Pawar <kinpaa@gmail.com>
This commit is contained in:
@@ -6437,6 +6437,11 @@ def purge_deleted_records(context, age_in_days):
|
||||
|
||||
metadata = MetaData()
|
||||
metadata.reflect(get_engine())
|
||||
tables = metadata.sorted_tables
|
||||
if not tables:
|
||||
msg = 'No tables found, check database connection'
|
||||
raise exception.InvalidResults(msg)
|
||||
|
||||
deleted_age = timeutils.utcnow() - datetime.timedelta(days=age_in_days)
|
||||
|
||||
# Deleting rows in share_network_security_service_association
|
||||
@@ -6451,7 +6456,7 @@ def purge_deleted_records(context, age_in_days):
|
||||
with context.session.begin_nested():
|
||||
context.session.delete(assoc)
|
||||
|
||||
for table in reversed(metadata.sorted_tables):
|
||||
for table in reversed(tables):
|
||||
if 'deleted' not in table.columns.keys():
|
||||
continue
|
||||
|
||||
|
@@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Purge DB records is fixed to raise error in case of missing or invalid
|
||||
db config. For more details, please check
|
||||
`launchpad bug #2124043 <https://bugs.launchpad.net/manila/+bug/2124043>`_
|
Reference in New Issue
Block a user