Fail a job when the gateway reports it could not start it
A start_print is acknowledged as soon as the gateway accepts it, and the download and transfer that follow can still fail. That late result was only logged, so the job sat in uploading until the stall reaper gave up twenty minutes later. The dispatcher now remembers which job each start command belonged to. A late failure for it fails the job with the gateway's own reason in metadata.lastDispatchError - but only while the job is still uploading, so a job the printer has since started is left to its telemetry. scripts/e2e-vendors.sh gains a phase where the proxy refuses the download and the job must fail at once with that reason.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { rememberStart, takeStart } from "../src/dispatch/late_failure";
|
||||
|
||||
describe("late start failures", () => {
|
||||
test("a remembered start is returned once, then forgotten", () => {
|
||||
rememberStart("c1", "job-1");
|
||||
expect(takeStart("c1")).toBe("job-1");
|
||||
expect(takeStart("c1")).toBeUndefined();
|
||||
});
|
||||
|
||||
test("a command nobody started is unknown", () => {
|
||||
expect(takeStart("never-sent")).toBeUndefined();
|
||||
});
|
||||
|
||||
test("an hour-old start is dropped rather than failing a job long since resolved", () => {
|
||||
const longAgo = Date.now() - 2 * 60 * 60 * 1000;
|
||||
rememberStart("old", "job-old", longAgo);
|
||||
rememberStart("new", "job-new");
|
||||
expect(takeStart("old")).toBeUndefined();
|
||||
expect(takeStart("new")).toBe("job-new");
|
||||
});
|
||||
|
||||
test("the table is bounded", () => {
|
||||
for (let i = 0; i < 1500; i++) rememberStart(`bulk-${i}`, `job-${i}`);
|
||||
expect(takeStart("bulk-0")).toBeUndefined();
|
||||
expect(takeStart("bulk-1499")).toBe("job-1499");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user