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:
Kiran Pawar
2025-09-16 11:23:01 +00:00
parent 34c6a73350
commit f57e4307c4
2 changed files with 12 additions and 1 deletions

View File

@@ -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

View File

@@ -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>`_