diff --git a/vmaas_sync/vmaas_sync.py b/vmaas_sync/vmaas_sync.py index 59892adfb..4d10f8b32 100644 --- a/vmaas_sync/vmaas_sync.py +++ b/vmaas_sync/vmaas_sync.py @@ -81,6 +81,7 @@ def _delete_old_recalc_events(conn): """delete from recalc_event where created < now() - interval '30 days' returning id""", ) deleted = cur.fetchall() + conn.commit() LOGGER.info("Deleted %s old recalc events older than 30 days", len(deleted)) @@ -92,6 +93,7 @@ def _save_recalc_event(conn, repos: dict[str, list[str]]): (json.dumps(repos),), ) ret = cur.fetchone() + conn.commit() return ret[0] @@ -316,10 +318,10 @@ def re_evaluate_systems(): LOGGER.info("Fetched 0 repos from VMaaS, skipping repo-based re-evaluation") return + LOGGER.info("Re-evaluating in repo-based mode") + _delete_old_recalc_events(conn) + event_id = _save_recalc_event(conn, updated_repos) with NamedCursor(conn) as cur: - LOGGER.info("Re-evaluating in repo-based mode") - _delete_old_recalc_events(conn) - event_id = _save_recalc_event(conn, updated_repos) _select_repo_based_inventory_ids(cur, list(updated_repos)) loop = asyncio.get_event_loop()