File tree Expand file tree Collapse file tree
apps/supervisor/src/workloadServer
packages/core/src/v3/serverOnly Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ const checkpointDeleteRequests = new Counter({
6363const checkpointCancelRequests = new Counter ( {
6464 name : "checkpoint_cancel_requests_total" ,
6565 help : "Checkpoint cancel requests attempted when a run continues, by outcome" ,
66- labelNames : [ "result" ] , // "sent" | "no_client" | "not_applicable" | "http_error"
66+ labelNames : [ "result" ] ,
6767 registers : [ register ] ,
6868} ) ;
6969
@@ -306,16 +306,22 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
306306 return ;
307307 }
308308
309- const [ error , accepted ] = await tryCatch (
309+ const [ error , outcome ] = await tryCatch (
310310 this . checkpointClient . cancelCheckpoints ( { runFriendlyId } )
311311 ) ;
312312
313- if ( error || ! accepted ) {
313+ if ( error || outcome === "failed" ) {
314314 checkpointCancelRequests . inc ( { result : "http_error" } ) ;
315315 this . logger . error ( "Failed to request checkpoint cancel" , { runFriendlyId, error } ) ;
316316 return ;
317317 }
318318
319+ if ( outcome === "unsupported" ) {
320+ checkpointCancelRequests . inc ( { result : "unsupported" } ) ;
321+ this . logger . debug ( "Checkpoint cancel not supported" , { runFriendlyId } ) ;
322+ return ;
323+ }
324+
319325 checkpointCancelRequests . inc ( { result : "sent" } ) ;
320326 }
321327
Original file line number Diff line number Diff line change @@ -158,20 +158,32 @@ export class CheckpointClient {
158158 return true ;
159159 }
160160
161- async cancelCheckpoints ( { runFriendlyId } : { runFriendlyId : string } ) : Promise < boolean > {
161+ /**
162+ * cancelCheckpoints returns "unsupported" when the route is absent, which is expected while a
163+ * newer caller runs against an older checkpoint service.
164+ */
165+ async cancelCheckpoints ( {
166+ runFriendlyId,
167+ } : {
168+ runFriendlyId : string ;
169+ } ) : Promise < "ok" | "unsupported" | "failed" > {
162170 const res = await fetch (
163171 new URL ( `/api/v1/runs/${ runFriendlyId } /checkpoints/cancel` , this . opts . apiUrl ) ,
164172 { method : "POST" }
165173 ) ;
166174
175+ if ( res . status === 404 ) {
176+ return "unsupported" ;
177+ }
178+
167179 if ( ! res . ok ) {
168180 this . logger . error ( "[CheckpointClient] Cancel checkpoints request failed" , {
169181 runFriendlyId,
170182 status : res . status ,
171183 } ) ;
172- return false ;
184+ return "failed" ;
173185 }
174186
175- return true ;
187+ return "ok" ;
176188 }
177189}
You can’t perform that action at this time.
0 commit comments