feat(process): bound a finalization interval before forced capture timeout
Add optional finalization_ms to keep observing a captured root after SIGTERM, record the actual finalizer exit and each signal attempt, and escalate once when needed. Bind the initial root identity to captured ownership and preserve observations through cleanup uncertainty. Fixes #1253. Co-authored-by: Mykola Dementiev <16836724+nikolay-dementiev@users.noreply.github.com> Co-authored-by: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com>
This commit is contained in:
co-authored by
Mykola Dementiev
N0zoM1z0
parent
1e51c732bb
commit
c1efa6467d
@@ -37,6 +37,54 @@ describe("process start identity lease", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("does not adopt a replacement PID's first identity for an owned launch", async () => {
|
||||
const replacement: ProcessOwnershipHost = {
|
||||
...host("replacement-start"),
|
||||
environment: async () => ({ REA_PROCESS_RUN_ID: "another-run" }),
|
||||
};
|
||||
await expect(
|
||||
observeProcessStartIdentity(42, replacement, "captured-run"),
|
||||
).resolves.toMatchObject({
|
||||
state: "unavailable",
|
||||
reason: expect.stringContaining("ownership"),
|
||||
});
|
||||
});
|
||||
|
||||
it("does not establish an owned launch when its token is unreadable", async () => {
|
||||
const unreadable: ProcessOwnershipHost = {
|
||||
...host("start-1"),
|
||||
runTokens: async () =>
|
||||
new Map([
|
||||
[42, { state: "unavailable", reason: "environment_errno_EACCES" }],
|
||||
]),
|
||||
};
|
||||
await expect(
|
||||
observeProcessStartIdentity(42, unreadable, "captured-run"),
|
||||
).resolves.toMatchObject({
|
||||
state: "unavailable",
|
||||
reason: expect.stringContaining("environment_errno_EACCES"),
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects an identity that changes while the captured run token is read", async () => {
|
||||
let identity = "start-1";
|
||||
const changing: ProcessOwnershipHost = {
|
||||
...host("start-1"),
|
||||
processIdentities: async () =>
|
||||
new Map([[42, { state: "readable", identity }]]),
|
||||
environment: async () => {
|
||||
identity = "replacement-start";
|
||||
return { REA_PROCESS_RUN_ID: "captured-run" };
|
||||
},
|
||||
};
|
||||
await expect(
|
||||
observeProcessStartIdentity(42, changing, "captured-run"),
|
||||
).resolves.toMatchObject({
|
||||
state: "unavailable",
|
||||
reason: expect.stringContaining("identity changed"),
|
||||
});
|
||||
});
|
||||
|
||||
it("signals the PID when its launch identity still matches", async () => {
|
||||
const sendSignal = vi.fn();
|
||||
await expect(
|
||||
|
||||
Reference in New Issue
Block a user