mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-11-18 01:54:23 +01:00
fix: retain loss evidence and fail interrupted deployments
This commit is contained in:
1 parent
0f9d8c657a
commit
d99a9587f7
5 files changed
+48
-10
No files matched your search
@@ -28,7 +28,7 @@ if (args[0] === "inspect") {
|
||||
finish(state.unhealthy ? "unhealthy" : "healthy");
|
||||
}
|
||||
if (args[0] === "compose") {
|
||||
if (args[1] === "build") { if (state.buildFails) finish("", 1); state.built = true; finish(); }
|
||||
if (args[1] === "build") { if (state.signal) { process.kill(process.ppid, state.signal); finish(); } if (state.buildFails) finish("", 1); state.built = true; finish(); }
|
||||
if (args[1] === "stop") { state.stopped = true; finish(); }
|
||||
if (args[1] === "run" && args.at(-1).endsWith("check-github-app-key.js")) { finish("", args.includes(state.preflightFails) ? 1 : 0); }
|
||||
if (args[1] === "run") { if (state.reconcileFails) finish("", 1); state.reconciled = true; finish(); }
|
||||
@@ -60,6 +60,12 @@ finish("unexpected docker call", 2);
|
||||
expect(new Set(events.map(row=>row.deploymentId)).size).equal(1);
|
||||
expect(events.at(-1).restartMs).at.least(0);
|
||||
});
|
||||
for (const [signal, code] of [["SIGHUP",129],["SIGINT",130],["SIGTERM",143]]) it(`records ${signal} termination as failed`, () => {
|
||||
const result=deploy({signal,operation:"rollback"});
|
||||
expect(result.status,result.stderr).equal(code);
|
||||
const events=result.stdout.split("\n").filter(line=>line.startsWith("{")).map(JSON.parse);
|
||||
expect(events.at(-1)).include({deploymentPhase:"finish",deploymentOutcome:"failed",exitCode:code});
|
||||
});
|
||||
it("records failure when API or streamers fail health checks", () => {
|
||||
const result=deploy({unhealthy:true});
|
||||
expect(result.status).not.equal(0);
|
||||
|
||||
@@ -121,12 +121,29 @@ describe('structured logging privacy and context', function () {
|
||||
reportOutputDrops(fields=>logger.info('process heartbeat',fields));
|
||||
blocked=false;
|
||||
reportOutputDrops(fields=>{assert.equal(fields.droppedLogsInterval,3);logger.info('process heartbeat',fields);});
|
||||
reportOutputDrops(fields=>{assert.equal(fields.droppedLogsInterval,0);assert.equal(fields.droppedLogs,3);logger.info('process heartbeat',fields);});
|
||||
setImmediate(()=>reportOutputDrops(fields=>{assert.equal(fields.droppedLogsInterval,0);assert.equal(fields.droppedLogs,3);logger.info('process heartbeat',fields);}));
|
||||
`],{env:{...process.env,LOG_REDIS_MIRROR:'off'},encoding:'utf8',timeout:10000});
|
||||
expect(child.status,child.stderr).equal(0);
|
||||
const rows=child.stdout.trim().split('\n').map(JSON.parse);
|
||||
expect(rows.map(r=>r.droppedLogsInterval)).deep.equal([3,0]);
|
||||
});
|
||||
it('retains earlier losses when a report write fails asynchronously', () => {
|
||||
const child=spawnSync(process.execPath,['-r','ts-node/register/transpile-only','-e',`
|
||||
const assert=require('node:assert/strict');
|
||||
const {createLogger,reportOutputDrops}=require('./src/core/logger');
|
||||
const logger=createLogger('process');let blocked=true;
|
||||
Object.defineProperty(process.stdout,'writableLength',{get:()=>blocked?300000:0});
|
||||
logger.info('request');logger.info('request');blocked=false;
|
||||
process.stdout.write=(line,callback)=>{setImmediate(()=>callback(new Error('EPIPE')));return true;};
|
||||
reportOutputDrops(fields=>logger.info('process heartbeat',fields));
|
||||
setImmediate(()=>{
|
||||
reportOutputDrops(fields=>{assert.equal(fields.droppedLogsInterval,3);logger.info('process heartbeat',fields);});
|
||||
setImmediate(()=>reportOutputDrops(fields=>{assert.equal(fields.droppedLogsInterval,0);logger.info('process heartbeat',fields);}));
|
||||
});
|
||||
`],{env:{...process.env,LOG_REDIS_MIRROR:'off'},encoding:'utf8',timeout:10000});
|
||||
expect(child.status,child.stderr).equal(0);
|
||||
expect(child.stderr.trim().split('\n').filter(line=>line.startsWith('{')).map(JSON.parse).map(r=>r.droppedLogsInterval)).deep.equal([3,0]);
|
||||
});
|
||||
it('writes JSON without Redis and bounds a blocked stdout pipe', () => {
|
||||
const child = spawnSync(process.execPath, ['-r', 'ts-node/register/transpile-only', '-e', `
|
||||
const { createLogger, getDroppedOutput } = require('./src/core/logger');
|
||||
|
||||
Reference in new issue
Block a user