From 605447b085e2e55b592048407bd01838e13bd510 Mon Sep 17 00:00:00 2001 From: guzzijones Date: Tue, 10 Oct 2023 17:55:33 +0000 Subject: [PATCH] add pending actions to cover inquiries to migration --- .../v3.9/st2-migrate-liveaction-executiondb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/st2common/bin/migrations/v3.9/st2-migrate-liveaction-executiondb b/st2common/bin/migrations/v3.9/st2-migrate-liveaction-executiondb index 74a9858edc..0fea53a29b 100755 --- a/st2common/bin/migrations/v3.9/st2-migrate-liveaction-executiondb +++ b/st2common/bin/migrations/v3.9/st2-migrate-liveaction-executiondb @@ -45,6 +45,7 @@ from st2common.models.db.execution import ActionExecutionDB from st2common.constants.action import ( LIVEACTION_COMPLETED_STATES, LIVEACTION_STATUS_PAUSED, + LIVEACTION_STATUS_PENDING ) # NOTE: To avoid unnecessary mongoengine object churn when retrieving only object ids (aka to avoid @@ -68,21 +69,24 @@ def migrate_executions(start_dt: datetime.datetime, end_dt: datetime.datetime) - res_count = ActionExecutionDB.objects( __raw__={ "status": { - "$in": LIVEACTION_COMPLETED_STATES + [LIVEACTION_STATUS_PAUSED], + "$in": LIVEACTION_COMPLETED_STATES + [LIVEACTION_STATUS_PAUSED, LIVEACTION_STATUS_PENDING], }, }, start_timestamp__gte=start_dt, start_timestamp__lte=end_dt, ).as_pymongo() for item in res_count: - ActionExecutionDB.objects(__raw__={"_id": item["_id"]}).update( - __raw__={"$set": {"liveaction_id": item["liveaction"]["id"]}} - ) + try: + ActionExecutionDB.objects(__raw__={"_id": item["_id"]}).update( + __raw__={"$set": {"liveaction_id": item["liveaction"]["id"]}} + ) + except KeyError as e: + pass ActionExecutionDB.objects( __raw__={ "status": { - "$in": LIVEACTION_COMPLETED_STATES + [LIVEACTION_STATUS_PAUSED], + "$in": LIVEACTION_COMPLETED_STATES + [LIVEACTION_STATUS_PAUSED, LIVEACTION_STATUS_PENDING], }, }, start_timestamp__gte=start_dt,