@@ -188,8 +188,8 @@ class ManagedRunController {
188
188
189
189
console . debug ( "[ManagedRunController] Polling for latest snapshot" ) ;
190
190
191
- this . httpClient . sendDebugLog ( this . runFriendlyId , {
192
- time : new Date ( ) ,
191
+ this . sendDebugLog ( {
192
+ runId : this . runFriendlyId ,
193
193
message : `snapshot poll: started` ,
194
194
properties : {
195
195
snapshotId : this . snapshotFriendlyId ,
@@ -201,8 +201,8 @@ class ManagedRunController {
201
201
if ( ! response . success ) {
202
202
console . error ( "[ManagedRunController] Snapshot poll failed" , { error : response . error } ) ;
203
203
204
- this . httpClient . sendDebugLog ( this . runFriendlyId , {
205
- time : new Date ( ) ,
204
+ this . sendDebugLog ( {
205
+ runId : this . runFriendlyId ,
206
206
message : `snapshot poll: failed` ,
207
207
properties : {
208
208
snapshotId : this . snapshotFriendlyId ,
@@ -269,8 +269,8 @@ class ManagedRunController {
269
269
// This should only be used when we're already executing a run. Attempt number changes are not allowed.
270
270
private updateRunPhase ( run : Run , snapshot : Snapshot ) {
271
271
if ( this . state . phase !== "RUN" ) {
272
- this . httpClient . sendDebugLog ( run . friendlyId , {
273
- time : new Date ( ) ,
272
+ this . sendDebugLog ( {
273
+ runId : run . friendlyId ,
274
274
message : `updateRunPhase: Invalid phase for updating snapshot: ${ this . state . phase } ` ,
275
275
properties : {
276
276
currentPhase : this . state . phase ,
@@ -282,8 +282,8 @@ class ManagedRunController {
282
282
}
283
283
284
284
if ( this . state . run . friendlyId !== run . friendlyId ) {
285
- this . httpClient . sendDebugLog ( run . friendlyId , {
286
- time : new Date ( ) ,
285
+ this . sendDebugLog ( {
286
+ runId : run . friendlyId ,
287
287
message : `updateRunPhase: Mismatched run IDs` ,
288
288
properties : {
289
289
currentRunId : this . state . run . friendlyId ,
@@ -299,8 +299,8 @@ class ManagedRunController {
299
299
if ( this . state . snapshot . friendlyId === snapshot . friendlyId ) {
300
300
logger . debug ( "updateRunPhase: Snapshot not changed" , { run, snapshot } ) ;
301
301
302
- this . httpClient . sendDebugLog ( run . friendlyId , {
303
- time : new Date ( ) ,
302
+ this . sendDebugLog ( {
303
+ runId : run . friendlyId ,
304
304
message : `updateRunPhase: Snapshot not changed` ,
305
305
properties : {
306
306
snapshotId : snapshot . friendlyId ,
@@ -311,8 +311,8 @@ class ManagedRunController {
311
311
}
312
312
313
313
if ( this . state . run . attemptNumber !== run . attemptNumber ) {
314
- this . httpClient . sendDebugLog ( run . friendlyId , {
315
- time : new Date ( ) ,
314
+ this . sendDebugLog ( {
315
+ runId : run . friendlyId ,
316
316
message : `updateRunPhase: Attempt number changed` ,
317
317
properties : {
318
318
oldAttemptNumber : this . state . run . attemptNumber ?? undefined ,
@@ -418,9 +418,9 @@ class ManagedRunController {
418
418
snapshotId : this . snapshotFriendlyId ,
419
419
} ) ;
420
420
421
- this . httpClient . sendDebugLog ( run . friendlyId , {
422
- time : new Date ( ) ,
423
- message : ` snapshot change: missing snapshot ID` ,
421
+ this . sendDebugLog ( {
422
+ runId : run . friendlyId ,
423
+ message : " snapshot change: missing snapshot ID" ,
424
424
properties : {
425
425
newSnapshotId : snapshot . friendlyId ,
426
426
newSnapshotStatus : snapshot . executionStatus ,
@@ -433,9 +433,9 @@ class ManagedRunController {
433
433
if ( this . snapshotFriendlyId === snapshot . friendlyId ) {
434
434
console . debug ( "handleSnapshotChange: snapshot not changed, skipping" , { snapshot } ) ;
435
435
436
- this . httpClient . sendDebugLog ( run . friendlyId , {
437
- time : new Date ( ) ,
438
- message : ` snapshot change: skipping, no change` ,
436
+ this . sendDebugLog ( {
437
+ runId : run . friendlyId ,
438
+ message : " snapshot change: skipping, no change" ,
439
439
properties : {
440
440
snapshotId : this . snapshotFriendlyId ,
441
441
snapshotStatus : snapshot . executionStatus ,
@@ -452,8 +452,8 @@ class ManagedRunController {
452
452
completedWaitpoints : completedWaitpoints . length ,
453
453
} ) ;
454
454
455
- this . httpClient . sendDebugLog ( run . friendlyId , {
456
- time : new Date ( ) ,
455
+ this . sendDebugLog ( {
456
+ runId : run . friendlyId ,
457
457
message : `snapshot change: ${ snapshot . executionStatus } ` ,
458
458
properties : {
459
459
oldSnapshotId : this . snapshotFriendlyId ,
@@ -471,6 +471,15 @@ class ManagedRunController {
471
471
error,
472
472
} ) ;
473
473
474
+ this . sendDebugLog ( {
475
+ runId : run . friendlyId ,
476
+ message : "snapshot change: failed to update run phase" ,
477
+ properties : {
478
+ currentPhase : this . state . phase ,
479
+ error : error instanceof Error ? error . message : String ( error ) ,
480
+ } ,
481
+ } ) ;
482
+
474
483
this . waitForNextRun ( ) ;
475
484
return ;
476
485
}
@@ -545,8 +554,8 @@ class ManagedRunController {
545
554
error : suspendResult . error ,
546
555
} ) ;
547
556
548
- this . httpClient . sendDebugLog ( run . friendlyId , {
549
- time : new Date ( ) ,
557
+ this . sendDebugLog ( {
558
+ runId : run . friendlyId ,
550
559
message : "checkpoint: suspend request failed" ,
551
560
properties : {
552
561
snapshotId : snapshot . friendlyId ,
@@ -562,8 +571,8 @@ class ManagedRunController {
562
571
suspendResult : suspendResult . data ,
563
572
} ) ;
564
573
565
- this . httpClient . sendDebugLog ( run . friendlyId , {
566
- time : new Date ( ) ,
574
+ this . sendDebugLog ( {
575
+ runId : run . friendlyId ,
567
576
message : "checkpoint: failed to suspend run" ,
568
577
properties : {
569
578
snapshotId : snapshot . friendlyId ,
@@ -651,9 +660,9 @@ class ManagedRunController {
651
660
} catch ( error ) {
652
661
console . error ( "handleSnapshotChange: unexpected error" , { error } ) ;
653
662
654
- this . httpClient . sendDebugLog ( run . friendlyId , {
655
- time : new Date ( ) ,
656
- message : ` snapshot change: unexpected error` ,
663
+ this . sendDebugLog ( {
664
+ runId : run . friendlyId ,
665
+ message : " snapshot change: unexpected error" ,
657
666
properties : {
658
667
snapshotId : snapshot . friendlyId ,
659
668
error : error instanceof Error ? error . message : String ( error ) ,
@@ -868,8 +877,8 @@ class ManagedRunController {
868
877
} ) ;
869
878
870
879
if ( previousRunId ) {
871
- this . httpClient . sendDebugLog ( previousRunId , {
872
- time : new Date ( ) ,
880
+ this . sendDebugLog ( {
881
+ runId : previousRunId ,
873
882
message : "warm start: received config" ,
874
883
properties : {
875
884
connectionTimeoutMs,
@@ -931,8 +940,8 @@ class ManagedRunController {
931
940
this . socket . on ( "run:notify" , async ( { version, run } ) => {
932
941
console . log ( "[ManagedRunController] Received run notification" , { version, run } ) ;
933
942
934
- this . httpClient . sendDebugLog ( run . friendlyId , {
935
- time : new Date ( ) ,
943
+ this . sendDebugLog ( {
944
+ runId : run . friendlyId ,
936
945
message : "run:notify received by runner" ,
937
946
} ) ;
938
947
@@ -951,6 +960,16 @@ class ManagedRunController {
951
960
currentRunId : this . runFriendlyId ,
952
961
currentSnapshotId : this . snapshotFriendlyId ,
953
962
} ) ;
963
+
964
+ this . sendDebugLog ( {
965
+ runId : run . friendlyId ,
966
+ message : "run:notify: ignoring notification for different run" ,
967
+ properties : {
968
+ currentRunId : this . runFriendlyId ,
969
+ currentSnapshotId : this . snapshotFriendlyId ,
970
+ notificationRunId : run . friendlyId ,
971
+ } ,
972
+ } ) ;
954
973
return ;
955
974
}
956
975
@@ -961,6 +980,16 @@ class ManagedRunController {
961
980
962
981
if ( ! latestSnapshot . success ) {
963
982
console . error ( "Failed to get latest snapshot data" , latestSnapshot . error ) ;
983
+
984
+ this . sendDebugLog ( {
985
+ runId : this . runFriendlyId ,
986
+ message : "run:notify: failed to get latest snapshot data" ,
987
+ properties : {
988
+ currentRunId : this . runFriendlyId ,
989
+ currentSnapshotId : this . snapshotFriendlyId ,
990
+ error : latestSnapshot . error ,
991
+ } ,
992
+ } ) ;
964
993
return ;
965
994
}
966
995
@@ -1126,6 +1155,28 @@ class ManagedRunController {
1126
1155
assertExhaustive ( attemptStatus ) ;
1127
1156
}
1128
1157
1158
+ sendDebugLog ( {
1159
+ runId,
1160
+ message,
1161
+ date,
1162
+ properties,
1163
+ } : {
1164
+ runId : string ;
1165
+ message : string ;
1166
+ date ?: Date ;
1167
+ properties ?: WorkloadDebugLogRequestBody [ "properties" ] ;
1168
+ } ) {
1169
+ this . httpClient . sendDebugLog ( runId , {
1170
+ message,
1171
+ time : date ?? new Date ( ) ,
1172
+ properties : {
1173
+ ...properties ,
1174
+ runnerId : this . runnerId ,
1175
+ workerName : this . workerInstanceName ,
1176
+ } ,
1177
+ } ) ;
1178
+ }
1179
+
1129
1180
async cancelAttempt ( runId : string ) {
1130
1181
logger . log ( "cancelling attempt" , { runId } ) ;
1131
1182
0 commit comments