fix: fire onSpawn immediately on job terminal transition (FAR-14)
Prevents process_lost false positives for 2-3 minute K8s jobs by resetting the reaper clock when the keepalive loop detects the job has completed (or been deleted), rather than waiting for the next periodic refresh. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -883,6 +883,9 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
|
|||||||
if (terminal) {
|
if (terminal) {
|
||||||
keepaliveJobTerminal = true;
|
keepaliveJobTerminal = true;
|
||||||
keepaliveJobTerminalAt = Date.now();
|
keepaliveJobTerminalAt = Date.now();
|
||||||
|
if (ctx.onSpawn) {
|
||||||
|
void ctx.onSpawn({ pid: process.pid, processGroupId: null, startedAt: new Date().toISOString() }).catch(() => {});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
@@ -893,6 +896,9 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
|
|||||||
if (isK8s404(err)) {
|
if (isK8s404(err)) {
|
||||||
keepaliveJobTerminal = true;
|
keepaliveJobTerminal = true;
|
||||||
keepaliveJobTerminalAt = Date.now();
|
keepaliveJobTerminalAt = Date.now();
|
||||||
|
if (ctx.onSpawn) {
|
||||||
|
void ctx.onSpawn({ pid: process.pid, processGroupId: null, startedAt: new Date().toISOString() }).catch(() => {});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Log transient errors but leave keepaliveJobTerminal false so
|
// Log transient errors but leave keepaliveJobTerminal false so
|
||||||
|
|||||||
Reference in New Issue
Block a user