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