Skip to content

Commit

Permalink
fix(vmaas-sync): make sure event row is commited before sending it in…
Browse files Browse the repository at this point in the history
… kafka messages
  • Loading branch information
jdobes committed Aug 19, 2024
1 parent 9b36033 commit c1f4017
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions vmaas_sync/vmaas_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand All @@ -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]


Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit c1f4017

Please sign in to comment.