honker: row 194 b8 r2 (sage-2289): a fire stop stopRun can't confirm (unknown) reads as lifecycle.end.alive with reason unknown, never killed, and the Console flags it; cli T9a no-runtime-record test, bus T9a reason checks, M56; notes
This commit is contained in:
1 parent
0583569b74
commit
899e30a808
5 files changed
+59
-8
No files matched your search
@@ -2317,7 +2317,8 @@ export class Broker {
|
||||
// The close of a taken request, with the run it started, the delete's transaction or the code
|
||||
// that stopped it. A delete also names the agent's Vikunja bot (sage-1610 b). A fire's end
|
||||
// (kill: true) also reports each run row 191's stop killed or left alive (D2.2, S6), and each is
|
||||
// written as lifecycle.end.killed or lifecycle.end.alive against the instance.
|
||||
// written as lifecycle.end.killed or lifecycle.end.alive against the instance. An alive stop
|
||||
// whose kill stopRun couldn't confirm carries reason unknown (sage-2289).
|
||||
lifecycleDone(record) {
|
||||
keys(record, ['business', 'request', 'run', 'transaction', 'refusal', 'bot', 'stops'], ['business', 'request']);
|
||||
if ('bot' in record && (typeof record.bot !== 'string' || !BOT_NAME.test(record.bot))) fail('invalid-request');
|
||||
@@ -2328,9 +2329,11 @@ export class Broker {
|
||||
if ('stops' in record) {
|
||||
if (!Array.isArray(record.stops) || record.stops.length > 64) fail('invalid-request');
|
||||
for (const x of record.stops) {
|
||||
keys(x, ['run', 'pid', 'outcome'], ['run', 'pid', 'outcome']);
|
||||
keys(x, ['run', 'pid', 'outcome', 'reason'], ['run', 'pid', 'outcome']);
|
||||
identifier(x.run);
|
||||
if (!FIRE_STOPS.includes(x.outcome) || !(x.pid === null || (Number.isSafeInteger(x.pid) && x.pid > 1))) fail('invalid-request');
|
||||
// sage-2289: only an alive stop carries a reason, and only unknown.
|
||||
if ('reason' in x && !(x.reason === 'unknown' && x.outcome === 'alive')) fail('invalid-request');
|
||||
}
|
||||
}
|
||||
return this.#store.transaction(() => {
|
||||
@@ -2339,7 +2342,7 @@ export class Broker {
|
||||
const { business, stops = [], ...body } = record;
|
||||
if (stops.length > 0 && !(r.action === 'lifecycle.end' && r.kill === true)) fail('invalid-request');
|
||||
for (const x of stops)
|
||||
this.#event({ business, role: null, run: null }, 'action.allowed', { action: `lifecycle.end.${x.outcome}`, request: r.request, run: x.run, pid: x.pid }, r.instance);
|
||||
this.#event({ business, role: null, run: null }, 'action.allowed', { action: `lifecycle.end.${x.outcome}`, request: r.request, run: x.run, pid: x.pid, ...('reason' in x ? { reason: x.reason } : {}) }, r.instance);
|
||||
this.#lifecycleStep(business, 'lifecycle.done', body);
|
||||
return lifecycleView(this.#lifecycle(business, r.request));
|
||||
});
|
||||
|
||||
@@ -896,7 +896,7 @@ test('row 194 T9: a fire revokes the claim, cancels open requests, asks the laun
|
||||
|
||||
// S6 (D2.2): the launcher closes a fire's end with the runs row 191's stop killed or left alive, and
|
||||
// each becomes its own event against the instance. Only a fire's end carries them.
|
||||
test('row 194 T9a (bus): a fire end\'s done writes lifecycle.end.killed and lifecycle.end.alive with run and pid; a terminate\'s done or a bad stop refuses', (t) => {
|
||||
test('row 194 T9a (bus): a fire end\'s done writes lifecycle.end.killed and lifecycle.end.alive with run and pid, and an unknown stop\'s reason; a terminate\'s done or a bad stop refuses', (t) => {
|
||||
const { b, call, allowed } = hireSetup(t);
|
||||
call('chief', 'instance.fire', FIRE);
|
||||
const [end] = allowed('lifecycle.end');
|
||||
@@ -904,12 +904,16 @@ test('row 194 T9a (bus): a fire end\'s done writes lifecycle.end.killed and life
|
||||
assert.equal(b.lifecycleTake({ business: 'demo', request }).go, true);
|
||||
const done = (stops) => b.lifecycleDone({ business: 'demo', request, stops });
|
||||
for (const bad of [[{ run: 'coder-run', pid: 4242, outcome: 'stopped' }], [{ run: 'coder-run', pid: 1, outcome: 'killed' }],
|
||||
[{ run: 'coder-run', outcome: 'killed' }], [{ run: 'coder-run', pid: 4242, outcome: 'killed', signals: [] }], 'killed'])
|
||||
[{ run: 'coder-run', outcome: 'killed' }], [{ run: 'coder-run', pid: 4242, outcome: 'killed', signals: [] }], 'killed',
|
||||
// sage-2289: only an alive stop carries a reason, and only unknown.
|
||||
[{ run: 'coder-run', pid: 4242, outcome: 'killed', reason: 'unknown' }], [{ run: 'coder-run', pid: null, outcome: 'alive', reason: 'stuck' }]])
|
||||
assert.throws(() => done(bad), { code: 'invalid-request' }, JSON.stringify(bad));
|
||||
const closed = done([{ run: 'coder-run', pid: 4242, outcome: 'killed' }, { run: 'coder-other', pid: null, outcome: 'alive' }]);
|
||||
const closed = done([{ run: 'coder-run', pid: 4242, outcome: 'killed' }, { run: 'coder-other', pid: null, outcome: 'alive' },
|
||||
{ run: 'coder-unknown', pid: null, outcome: 'alive', reason: 'unknown' }]);
|
||||
assert.equal(closed.state, 'closed');
|
||||
assert.deepEqual(allowed('lifecycle.end.killed').map((e) => [e.subject, e.body]), [['coder', { action: 'lifecycle.end.killed', request, run: 'coder-run', pid: 4242 }]]);
|
||||
assert.deepEqual(allowed('lifecycle.end.alive').map((e) => [e.subject, e.body]), [['coder', { action: 'lifecycle.end.alive', request, run: 'coder-other', pid: null }]]);
|
||||
assert.deepEqual(allowed('lifecycle.end.alive').map((e) => [e.subject, e.body]), [['coder', { action: 'lifecycle.end.alive', request, run: 'coder-other', pid: null }],
|
||||
['coder', { action: 'lifecycle.end.alive', request, run: 'coder-unknown', pid: null, reason: 'unknown' }]]);
|
||||
// A terminate's end sends SIGTERM only, so its done has no stops.
|
||||
const term = call('human', 'instance.end', { instance: 'pm' }).request;
|
||||
assert.equal(b.lifecycleTake({ business: 'demo', request: term }).go, true);
|
||||
|
||||
Reference in new issue
Block a user