rollbridge 0.1.42 → 0.1.44
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/package.json +1 -1
- package/src/daemon.js +13 -3
- package/src/release-group.js +14 -2
- package/test/rollbridge.test.js +8 -0
package/package.json
CHANGED
package/src/daemon.js
CHANGED
|
@@ -505,7 +505,10 @@ export default class RollbridgeDaemon {
|
|
|
505
505
|
if (!transfer?.config || !transfer.snapshot) throw new Error("Committed owner published incomplete replacement state")
|
|
506
506
|
const unresolvedTransition = transfer.snapshot.generationTransition
|
|
507
507
|
|
|
508
|
-
|
|
508
|
+
const transferredTransitionConfigDigest = transfer.config ? ownerConfigDigest(transfer.config) : undefined
|
|
509
|
+
if (unresolvedTransition && unresolvedTransition.phase !== "committed" &&
|
|
510
|
+
unresolvedTransition.configDigest !== this.ownerRecoveryConfigDigest() &&
|
|
511
|
+
unresolvedTransition.configDigest !== transferredTransitionConfigDigest) {
|
|
509
512
|
throw new Error(`Owner replacement cannot change config authority while unresolved generation transition ${unresolvedTransition.candidateReleaseId} remains at ${unresolvedTransition.phase}`)
|
|
510
513
|
}
|
|
511
514
|
const registeredProcesses = new Map((await this.guardian.inventory()).map(({key, provenance}) => [key, provenance]))
|
|
@@ -1814,7 +1817,7 @@ export default class RollbridgeDaemon {
|
|
|
1814
1817
|
}
|
|
1815
1818
|
|
|
1816
1819
|
if (transition.phase === "restoring_previous") {
|
|
1817
|
-
if (candidate.state !== "draining") throw new Error(`Failed candidate ${candidate.releaseId} is not retired before incumbent restoration`)
|
|
1820
|
+
if (candidate.state !== "draining" && candidate.state !== "stopped") throw new Error(`Failed candidate ${candidate.releaseId} is not retired before incumbent restoration`)
|
|
1818
1821
|
try {
|
|
1819
1822
|
await previous.reactivateGeneration()
|
|
1820
1823
|
} catch (error) {
|
|
@@ -1914,7 +1917,14 @@ export default class RollbridgeDaemon {
|
|
|
1914
1917
|
* @param {{config: import("./config.js").RollbridgeConfig, releaseId: string, releasePath: string, revision: string}} candidate - Requested identity.
|
|
1915
1918
|
*/
|
|
1916
1919
|
assertExactGenerationTransition(transition, candidate) {
|
|
1917
|
-
|
|
1920
|
+
const retainedCandidate = this.releases.get(transition.candidateReleaseId)
|
|
1921
|
+
const retainedAuthorityMatches = transition.phase !== "committed" &&
|
|
1922
|
+
retainedCandidate?.releasePath === transition.candidateReleasePath &&
|
|
1923
|
+
retainedCandidate.revision === transition.candidateRevision &&
|
|
1924
|
+
ownerConfigDigest(retainedCandidate.config) === transition.configDigest
|
|
1925
|
+
const requestedAuthorityMatches = ownerConfigDigest(candidate.config) === transition.configDigest
|
|
1926
|
+
|
|
1927
|
+
if (transition.candidateReleaseId !== candidate.releaseId || transition.candidateReleasePath !== candidate.releasePath || transition.candidateRevision !== candidate.revision || (!requestedAuthorityMatches && !retainedAuthorityMatches)) {
|
|
1918
1928
|
throw new Error(`Release generation transition for ${transition.candidateReleaseId} is unresolved at ${transition.phase}; only the exact same release, path, revision, and config authority may resume it`)
|
|
1919
1929
|
}
|
|
1920
1930
|
}
|
package/src/release-group.js
CHANGED
|
@@ -290,10 +290,22 @@ export default class ReleaseGroup extends EventEmitter {
|
|
|
290
290
|
if (!coordinator) throw new Error(`Generation activation process ${processConfig.id} is not retained for release ${this.releaseId}`)
|
|
291
291
|
const generationIds = new Set([...this.handoffServiceIds, ...this.nonBlockingDrainIds])
|
|
292
292
|
|
|
293
|
+
/** @param {import("./managed-process.js").default} processInstance - Retained generation process. */
|
|
294
|
+
const reactivate = async (processInstance) => {
|
|
295
|
+
const {pid, state} = processInstance.status()
|
|
296
|
+
|
|
297
|
+
if (state === "failed") {
|
|
298
|
+
await processInstance.stop()
|
|
299
|
+
await processInstance.start("crash", "active")
|
|
300
|
+
} else if (pid !== undefined) await processInstance.reactivateStrict()
|
|
301
|
+
else if (state === "stopped") await processInstance.start("crash", "active")
|
|
302
|
+
else throw new Error(`Generation process is ${state}; refusing active-role restoration`)
|
|
303
|
+
}
|
|
304
|
+
|
|
293
305
|
for (const [id, processInstance] of this.processes) {
|
|
294
|
-
if (generationIds.has(id) && processInstance !== coordinator.process) await processInstance
|
|
306
|
+
if (generationIds.has(id) && processInstance !== coordinator.process) await reactivate(processInstance)
|
|
295
307
|
}
|
|
296
|
-
await coordinator.process
|
|
308
|
+
await reactivate(coordinator.process)
|
|
297
309
|
this.state = "active"
|
|
298
310
|
this.activatedAt = new Date().toISOString()
|
|
299
311
|
this.drainStartedAt = undefined
|
package/test/rollbridge.test.js
CHANGED
|
@@ -696,8 +696,16 @@ test("candidate activation failure reports restoration failure and exact recover
|
|
|
696
696
|
assert.match(String(restorationEvent?.data.error), /incumbent restoration rejected/)
|
|
697
697
|
assert.deepEqual(await lifecycleEvents(fixture.lifecycleLogPath), ["activate:v1", "retire:v1", "retire:v2"])
|
|
698
698
|
await assert.rejects(() => daemon.deploy({releaseId: "v3", releasePath: fixture.root, revision: "v3"}), /transition.*v2.*unresolved/i)
|
|
699
|
+
const failedCandidate = daemon.releases.get("v2")
|
|
699
700
|
|
|
701
|
+
assert.ok(failedCandidate)
|
|
702
|
+
await failedCandidate.stop()
|
|
700
703
|
incumbentCoordinator.reactivateStrict = reactivate
|
|
704
|
+
await incumbentCoordinator.stop()
|
|
705
|
+
assert.equal(failedCandidate.state, "stopped")
|
|
706
|
+
assert.equal(incumbentCoordinator.status().state, "stopped")
|
|
707
|
+
daemon.config = structuredClone(daemon.config)
|
|
708
|
+
daemon.config.processes[0].lifecycle.activateTimeoutMs = (daemon.config.processes[0].lifecycle.activateTimeoutMs ?? 30000) + 1
|
|
701
709
|
const recovery = await sendControlCommand({
|
|
702
710
|
command: {
|
|
703
711
|
command: "recover-generation-transition",
|