rollbridge 0.1.68 → 0.1.70
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 +18 -9
- package/TODO.md +1 -0
- package/changelog.d/20261116-guardian-version-handoff.md +37 -0
- package/changelog.d/20261116-reclaim-dead-owner-mutation.md +7 -0
- package/changelog.d/20261117-activate-before-incumbent-retirement.md +1 -0
- package/changelog.d/20261117-activation-path-drain-deadline.md +35 -0
- package/changelog.d/20261117-stop-companion-after-retired-dependency.md +7 -0
- package/docs/cli.md +14 -7
- package/docs/config.md +8 -4
- package/docs/troubleshooting.md +27 -0
- package/docs/workers.md +1 -0
- package/examples/tensorbuzz.com.js +2 -1
- package/package.json +1 -1
- package/src/daemon.js +178 -48
- package/src/doctor.js +7 -0
- package/src/drain-policy.js +18 -4
- package/src/guardian-client.js +54 -6
- package/src/managed-process.js +14 -5
- package/src/process-guardian.js +76 -5
- package/src/release-group.js +40 -4
- package/tensorbuzz.yml +3 -1
- package/test/drain-policy.test.js +28 -0
- package/test/guardian-client.test.js +49 -5
- package/test/managed-process.test.js +3 -1
- package/test/owner-recovery.test.js +52 -13
- package/test/owner-replacement.test.js +97 -12
- package/test/release-group.test.js +57 -0
- package/test/rollbridge.test.js +84 -28
- package/test/shutdown-completion.test.js +52 -0
|
@@ -176,6 +176,52 @@ test("shutdown keeps daemon services alive until release-owned dependents stop",
|
|
|
176
176
|
}
|
|
177
177
|
})
|
|
178
178
|
|
|
179
|
+
test("shutdown returns after the non-blocking drain budget instead of waiting for a worker", async () => {
|
|
180
|
+
const root = await fs.mkdtemp(path.join(os.tmpdir(), "rollbridge-shutdown-non-blocking-drain-"))
|
|
181
|
+
const socketPath = path.join(root, "control.sock")
|
|
182
|
+
const readyPath = path.join(root, "ready")
|
|
183
|
+
const processCommand = `${JSON.stringify(process.execPath)} -e ${JSON.stringify(`process.on('SIGTERM', () => {}); require("node:fs").writeFileSync(${JSON.stringify(readyPath)}, "ready"); setInterval(() => {}, 1000)`)}`
|
|
184
|
+
const config = buildConfig(socketPath, {
|
|
185
|
+
companion: {command: processCommand, gracefulStopMs: "indefinite", id: "worker", nonBlockingDrain: true, policy: "companion"}
|
|
186
|
+
})
|
|
187
|
+
config.proxy.nonBlockingDrainTimeoutMs = 25
|
|
188
|
+
const daemon = new RollbridgeDaemon({config, logger: () => {}})
|
|
189
|
+
let workerPid
|
|
190
|
+
|
|
191
|
+
try {
|
|
192
|
+
await daemon.start()
|
|
193
|
+
await daemon.deploy({releaseId: "v1", releasePath: root, revision: "v1"})
|
|
194
|
+
await waitForFile(readyPath)
|
|
195
|
+
workerPid = daemon.activeRelease?.getProcess("worker")?.pid
|
|
196
|
+
|
|
197
|
+
expect(typeof workerPid).toBe("number")
|
|
198
|
+
|
|
199
|
+
let timer
|
|
200
|
+
try {
|
|
201
|
+
await Promise.race([
|
|
202
|
+
daemon.shutdown(),
|
|
203
|
+
new Promise((_, reject) => { timer = setTimeout(() => reject(new Error("shutdown waited past its retirement budget")), 1000) })
|
|
204
|
+
])
|
|
205
|
+
} finally {
|
|
206
|
+
clearTimeout(timer)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
let workerGroupAlive = true
|
|
210
|
+
try {
|
|
211
|
+
process.kill(-/** @type {number} */ (workerPid), 0)
|
|
212
|
+
} catch {
|
|
213
|
+
workerGroupAlive = false
|
|
214
|
+
}
|
|
215
|
+
expect(workerGroupAlive).toBe(true)
|
|
216
|
+
} finally {
|
|
217
|
+
if (workerPid) {
|
|
218
|
+
try { process.kill(-workerPid, "SIGKILL") } catch (_error) { /* Exact fixture process already exited. */ }
|
|
219
|
+
}
|
|
220
|
+
await daemon.shutdown().catch(() => {})
|
|
221
|
+
await fs.rm(root, {force: true, recursive: true})
|
|
222
|
+
}
|
|
223
|
+
})
|
|
224
|
+
|
|
179
225
|
test("external-owner retirement releases listeners before a long-draining companion exits", async () => {
|
|
180
226
|
const root = await fs.mkdtemp(path.join(os.tmpdir(), "rollbridge-owner-retirement-"))
|
|
181
227
|
const socketPath = path.join(root, "rollbridge.sock")
|
|
@@ -401,6 +447,12 @@ function rawConfig(socketPath) {
|
|
|
401
447
|
* @returns {Promise<void>} Resolves when the file appears.
|
|
402
448
|
*/
|
|
403
449
|
async function waitForFile(filePath) {
|
|
450
|
+
try {
|
|
451
|
+
await fs.access(filePath)
|
|
452
|
+
return
|
|
453
|
+
} catch {
|
|
454
|
+
// The file may be created after the watcher is installed.
|
|
455
|
+
}
|
|
404
456
|
const watcher = fs.watch(path.dirname(filePath))
|
|
405
457
|
|
|
406
458
|
try {
|