@@ -45,6 +45,7 @@ from st2common.models.db.execution import ActionExecutionDB
4545from st2common .constants .action import (
4646 LIVEACTION_COMPLETED_STATES ,
4747 LIVEACTION_STATUS_PAUSED ,
48+ LIVEACTION_STATUS_PENDING
4849)
4950
5051# 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) -
6869 res_count = ActionExecutionDB .objects (
6970 __raw__ = {
7071 "status" : {
71- "$in" : LIVEACTION_COMPLETED_STATES + [LIVEACTION_STATUS_PAUSED ],
72+ "$in" : LIVEACTION_COMPLETED_STATES + [LIVEACTION_STATUS_PAUSED , LIVEACTION_STATUS_PENDING ],
7273 },
7374 },
7475 start_timestamp__gte = start_dt ,
7576 start_timestamp__lte = end_dt ,
7677 ).as_pymongo ()
7778 for item in res_count :
78- ActionExecutionDB .objects (__raw__ = {"_id" : item ["_id" ]}).update (
79- __raw__ = {"$set" : {"liveaction_id" : item ["liveaction" ]["id" ]}}
80- )
79+ try :
80+ ActionExecutionDB .objects (__raw__ = {"_id" : item ["_id" ]}).update (
81+ __raw__ = {"$set" : {"liveaction_id" : item ["liveaction" ]["id" ]}}
82+ )
83+ except KeyError as e :
84+ pass
8185
8286 ActionExecutionDB .objects (
8387 __raw__ = {
8488 "status" : {
85- "$in" : LIVEACTION_COMPLETED_STATES + [LIVEACTION_STATUS_PAUSED ],
89+ "$in" : LIVEACTION_COMPLETED_STATES + [LIVEACTION_STATUS_PAUSED , LIVEACTION_STATUS_PENDING ],
8690 },
8791 },
8892 start_timestamp__gte = start_dt ,
0 commit comments