rollbridge 0.1.56 → 0.1.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/TODO.md +12 -0
- package/changelog.d/20261013-recover-dead-guardian-state.md +1 -0
- package/changelog.d/20261025-guardian-re-register-dead-generation.md +13 -0
- package/changelog.d/20261026-stale-committed-generation-transition-recovery.md +1 -0
- package/changelog.d/20261104-compose-service-units.md +21 -0
- package/changelog.d/20261105-owner-mutation-lease-diagnostics.md +20 -0
- package/docs/cli.md +70 -1
- package/docs/compose-services.md +220 -0
- package/docs/config.md +55 -0
- package/docs/troubleshooting.md +24 -0
- package/package.json +1 -1
- package/src/cli.js +82 -4
- package/src/compose-unit.js +725 -0
- package/src/config.js +201 -2
- package/src/daemon.js +23 -8
- package/src/doctor.js +67 -0
- package/src/guardian-client.js +13 -2
- package/src/process-guardian.js +137 -17
- package/src/recover.js +128 -8
- package/test/completion.test.js +5 -2
- package/test/compose-config.test.js +158 -0
- package/test/compose-docker.test.js +297 -0
- package/test/compose-unit.test.js +415 -0
- package/test/fixtures/gated-app.js +50 -0
- package/test/guardian-client.test.js +70 -0
- package/test/recover.test.js +119 -0
- package/test/rollbridge.test.js +106 -6
package/src/cli.js
CHANGED
|
@@ -10,6 +10,7 @@ import RollbridgeDaemon, {ownerConfigDigest} from "./daemon.js"
|
|
|
10
10
|
import {loadDaemonRuntimeIdentity, prepareDaemonRuntime} from "./daemon-runtime.js"
|
|
11
11
|
import {loadConfig, parseConfigFile, resolveConfigPath, validateConfig} from "./config.js"
|
|
12
12
|
import {runEnvironmentChecks, runReleaseChecks} from "./doctor.js"
|
|
13
|
+
import {composeUnitStatus, rollComposeUnit, rollbackComposeUnit} from "./compose-unit.js"
|
|
13
14
|
import {predeployCleanup} from "./predeploy-cleanup.js"
|
|
14
15
|
import {recoverOrphans} from "./recover.js"
|
|
15
16
|
import {sendControlCommand} from "./control-client.js"
|
|
@@ -247,6 +248,49 @@ export async function runCli(argv) {
|
|
|
247
248
|
console.log(JSON.stringify(response, null, 2))
|
|
248
249
|
})
|
|
249
250
|
|
|
251
|
+
program
|
|
252
|
+
.command("compose-roll")
|
|
253
|
+
.description("Drain-first roll of one Docker Compose service: quiesce it, wait for in-flight work, recreate it with the target image, gate on activation, and roll back on failure.")
|
|
254
|
+
.option("-c, --config <path>", "Config file path (defaults to rollbridge.js)")
|
|
255
|
+
.requiredOption("--unit <id>", "Compose unit id declared in the config")
|
|
256
|
+
.option("--image <reference>", "Target image reference (defaults to the unit's configured image)")
|
|
257
|
+
.action(async (options) => {
|
|
258
|
+
const configPath = await resolveConfigPath(options.config)
|
|
259
|
+
const config = await loadConfig(configPath)
|
|
260
|
+
const result = await rollComposeUnit({config, image: options.image, unit: requireComposeUnit(config, options.unit, configPath)})
|
|
261
|
+
|
|
262
|
+
console.log(JSON.stringify(result, null, 2))
|
|
263
|
+
if (result.status === "failed") process.exitCode = 1
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
program
|
|
267
|
+
.command("compose-rollback")
|
|
268
|
+
.description("Roll one Compose unit back to its retained previous image through the same drain-first path.")
|
|
269
|
+
.option("-c, --config <path>", "Config file path (defaults to rollbridge.js)")
|
|
270
|
+
.requiredOption("--unit <id>", "Compose unit id declared in the config")
|
|
271
|
+
.option("--image <reference>", "Earlier image reference (defaults to the retained previous one)")
|
|
272
|
+
.action(async (options) => {
|
|
273
|
+
const configPath = await resolveConfigPath(options.config)
|
|
274
|
+
const config = await loadConfig(configPath)
|
|
275
|
+
const result = await rollbackComposeUnit({config, image: options.image, unit: requireComposeUnit(config, options.unit, configPath)})
|
|
276
|
+
|
|
277
|
+
console.log(JSON.stringify(result, null, 2))
|
|
278
|
+
if (result.status === "failed") process.exitCode = 1
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
program
|
|
282
|
+
.command("compose-status")
|
|
283
|
+
.description("Report a Compose unit's retained image generations and its live container state.")
|
|
284
|
+
.option("-c, --config <path>", "Config file path (defaults to rollbridge.js)")
|
|
285
|
+
.requiredOption("--unit <id>", "Compose unit id declared in the config")
|
|
286
|
+
.action(async (options) => {
|
|
287
|
+
const configPath = await resolveConfigPath(options.config)
|
|
288
|
+
const config = await loadConfig(configPath)
|
|
289
|
+
const status = await composeUnitStatus({config, unit: requireComposeUnit(config, options.unit, configPath)})
|
|
290
|
+
|
|
291
|
+
console.log(JSON.stringify(status, null, 2))
|
|
292
|
+
})
|
|
293
|
+
|
|
250
294
|
program
|
|
251
295
|
.command("ensure-daemon")
|
|
252
296
|
.description("Start the daemon if the control socket is not already accepting commands.")
|
|
@@ -367,7 +411,7 @@ export async function runCli(argv) {
|
|
|
367
411
|
const valid = issues.length === 0
|
|
368
412
|
|
|
369
413
|
if (options.json) {
|
|
370
|
-
const summary = valid ? {application: config.application, processes: config.processes.length, proxy: {host: config.proxy.host, port: config.proxy.port}} : null
|
|
414
|
+
const summary = valid ? {application: config.application, composeUnits: config.compose?.length ?? 0, processes: config.processes.length, proxy: {host: config.proxy.host, port: config.proxy.port}} : null
|
|
371
415
|
|
|
372
416
|
console.log(JSON.stringify({config: summary, issues, path: configPath, valid}, null, 2))
|
|
373
417
|
if (!valid) process.exitCode = 1
|
|
@@ -376,8 +420,10 @@ export async function runCli(argv) {
|
|
|
376
420
|
|
|
377
421
|
if (valid) {
|
|
378
422
|
const processCount = config.processes.length
|
|
423
|
+
const composeCount = config.compose?.length ?? 0
|
|
424
|
+
const composeSummary = composeCount > 0 ? `, ${composeCount} Compose unit${composeCount === 1 ? "" : "s"}` : ""
|
|
379
425
|
|
|
380
|
-
console.log(`${configPath} is valid: ${processCount} ${processCount === 1 ? "process" : "processes"}, proxy on ${config.proxy.host}:${config.proxy.port}.`)
|
|
426
|
+
console.log(`${configPath} is valid: ${processCount} ${processCount === 1 ? "process" : "processes"}${composeSummary}, proxy on ${config.proxy.host}:${config.proxy.port}.`)
|
|
381
427
|
return
|
|
382
428
|
}
|
|
383
429
|
|
|
@@ -559,6 +605,26 @@ export async function runCli(argv) {
|
|
|
559
605
|
await program.parseAsync(argv)
|
|
560
606
|
}
|
|
561
607
|
|
|
608
|
+
/**
|
|
609
|
+
* Resolves a Compose unit by id, naming the configured units when the id is unknown.
|
|
610
|
+
* @param {import("./config.js").RollbridgeConfig} config - Loaded config.
|
|
611
|
+
* @param {string} unitId - Requested Compose unit id.
|
|
612
|
+
* @param {string} configPath - Config path shown in the error.
|
|
613
|
+
* @returns {import("./config.js").ComposeUnitConfig} The configured unit.
|
|
614
|
+
*/
|
|
615
|
+
function requireComposeUnit(config, unitId, configPath) {
|
|
616
|
+
const units = config.compose ?? []
|
|
617
|
+
const unit = units.find((candidate) => candidate.id === unitId)
|
|
618
|
+
|
|
619
|
+
if (unit) return unit
|
|
620
|
+
|
|
621
|
+
if (units.length === 0) {
|
|
622
|
+
throw new Error(`${configPath} declares no compose units. Add a compose: [{id: "${unitId}", ...}] entry to roll it drain-first.`)
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
throw new Error(`No compose unit "${unitId}" in ${configPath}. Configured units: ${units.map((candidate) => candidate.id).join(", ")}.`)
|
|
626
|
+
}
|
|
627
|
+
|
|
562
628
|
/**
|
|
563
629
|
* @param {import("./predeploy-cleanup.js").PredeployCleanupResult} result - Cleanup result.
|
|
564
630
|
* @returns {string} Human-readable summary.
|
|
@@ -588,12 +654,22 @@ function formatPredeployCleanupResult(result) {
|
|
|
588
654
|
|
|
589
655
|
/**
|
|
590
656
|
* Formats the result of a recover run (the report case, not the error case).
|
|
591
|
-
* @param {{cleared: boolean, forced: boolean, orphans: OrphanProcess[], remaining: OrphanProcess[]}} result - Recover report.
|
|
657
|
+
* @param {{archived: boolean, archivePath?: string, cleared: boolean, deadGuardianState: boolean, forced: boolean, orphans: OrphanProcess[], remaining: OrphanProcess[]}} result - Recover report.
|
|
592
658
|
* @returns {string} Human-readable summary.
|
|
593
659
|
*/
|
|
594
660
|
export function formatRecoverResult(result) {
|
|
661
|
+
const deadGuardianNote = result.deadGuardianState
|
|
662
|
+
? result.archived
|
|
663
|
+
? `Archived the state naming a dead guardian at ${result.archivePath}; the next deploy boots a fresh generation.`
|
|
664
|
+
: "The state names a conclusively dead guardian, which dead-ends every boot path; re-run with --force to archive it (bytes preserved) so a later deploy can boot a fresh generation."
|
|
665
|
+
: undefined
|
|
666
|
+
|
|
595
667
|
if (result.orphans.length === 0) {
|
|
596
|
-
|
|
668
|
+
if (result.archived) return deadGuardianNote ?? "No orphaned processes found."
|
|
669
|
+
|
|
670
|
+
const base = result.forced ? "No orphaned processes found; cleared the state file." : "No orphaned processes found."
|
|
671
|
+
|
|
672
|
+
return deadGuardianNote ? `${base}\n${deadGuardianNote}` : base
|
|
597
673
|
}
|
|
598
674
|
|
|
599
675
|
if (!result.forced) {
|
|
@@ -618,6 +694,8 @@ export function formatRecoverResult(result) {
|
|
|
618
694
|
)
|
|
619
695
|
}
|
|
620
696
|
|
|
697
|
+
if (result.archived && deadGuardianNote) lines.push(deadGuardianNote)
|
|
698
|
+
|
|
621
699
|
return lines.join("\n")
|
|
622
700
|
}
|
|
623
701
|
|