@@ -137,11 +137,12 @@ async def initialize_staging_steps(self, staging_run: StagingRun, db: Session):
137
137
138
138
steps .extend (
139
139
[
140
- {"type" : StagingStepType .KERNEL_TREE_UPDATE , "order" : order_counter },
141
140
{
142
141
"type" : StagingStepType .API_PIPELINE_UPDATE ,
143
- "order" : order_counter + 1 ,
142
+ "order" : order_counter ,
144
143
},
144
+ {"type" : StagingStepType .KERNEL_TREE_UPDATE , "order" : order_counter + 1 },
145
+ {"type" : StagingStepType .TRIGGER_RESTART , "order" : order_counter + 2 },
145
146
]
146
147
)
147
148
@@ -221,6 +222,8 @@ async def process_step(
221
222
await self .process_kernel_tree_step (staging_run , step , db )
222
223
elif step .step_type == StagingStepType .API_PIPELINE_UPDATE :
223
224
await self .process_api_pipeline_step (staging_run , step , db )
225
+ elif step .step_type == StagingStepType .TRIGGER_RESTART :
226
+ await self .process_trigger_restart_step (staging_run , step , db )
224
227
225
228
async def process_github_workflow_step (
226
229
self , staging_run : StagingRun , step : StagingRunStep , db : Session
@@ -441,6 +444,36 @@ async def process_api_pipeline_step(
441
444
step .end_time = datetime .utcnow ()
442
445
db .commit ()
443
446
447
+ async def process_trigger_restart_step (
448
+ self , staging_run : StagingRun , step : StagingRunStep , db : Session
449
+ ):
450
+ """Process trigger restart step - restart the trigger service in pipeline"""
451
+ if step .status == StagingStepStatus .PENDING :
452
+ step .status = StagingStepStatus .RUNNING
453
+ step .start_time = datetime .utcnow ()
454
+ staging_run .current_step = "trigger_restart"
455
+ db .commit ()
456
+
457
+ try :
458
+ # Restart the trigger service in the pipeline
459
+ result = await self .deployment_manager .restart_trigger_service ()
460
+
461
+ step .end_time = datetime .utcnow ()
462
+ if result ["success" ]:
463
+ step .status = StagingStepStatus .COMPLETED
464
+ step .details = json .dumps (result )
465
+ else :
466
+ step .status = StagingStepStatus .FAILED
467
+ step .error_message = result .get ("error" , "Unknown error" )
468
+
469
+ db .commit ()
470
+
471
+ except Exception as e :
472
+ step .status = StagingStepStatus .FAILED
473
+ step .error_message = str (e )
474
+ step .end_time = datetime .utcnow ()
475
+ db .commit ()
476
+
444
477
async def complete_staging_run (
445
478
self , staging_run : StagingRun , db : Session , success : bool
446
479
):
@@ -508,6 +541,8 @@ async def recover_stuck_steps(self, staging_run: StagingRun, db: Session):
508
541
timeout_minutes = 15 # Git operations
509
542
elif step .step_type == StagingStepType .SELF_UPDATE :
510
543
timeout_minutes = 10 # Quick git pull
544
+ elif step .step_type == StagingStepType .TRIGGER_RESTART :
545
+ timeout_minutes = 5 # Quick docker restart
511
546
512
547
if running_duration .total_seconds () > (timeout_minutes * 60 ):
513
548
print (
@@ -576,6 +611,7 @@ async def startup_recovery(self):
576
611
StagingStepType .API_PIPELINE_UPDATE ,
577
612
StagingStepType .KERNEL_TREE_UPDATE ,
578
613
StagingStepType .SELF_UPDATE ,
614
+ StagingStepType .TRIGGER_RESTART ,
579
615
]:
580
616
print (
581
617
f"Recovering stuck local step: { step .step_type .value } "
0 commit comments