fffleet-orchestrator 2.7.0 → 2.9.0
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 +1 -1
- package/package.json +2 -2
- package/src/job-store.js +14 -3
- package/src/orchestrator.js +11 -5
package/README.md
CHANGED
|
@@ -48,4 +48,4 @@ The orchestrator serves a small dashboard at `/ui/` (set `ui: false` in the libr
|
|
|
48
48
|
|
|
49
49
|
Callers need not set `workerPreference` on every job: the config file's `placement` list orders workers by job `type`,
|
|
50
50
|
`kind`, `class` or required capability (first matching rule wins; `others: true` lets unlisted workers serve after the
|
|
51
|
-
listed ones; a job's own `workerPreference` overrides).
|
|
51
|
+
listed ones; a job's own `workerPreference` overrides). Deployment configs live in the piecosystem repository (`deploy/fleet-pi/`).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fffleet-orchestrator",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "fffleet orchestrator: schedules ffmpeg jobs across a pool of fffleet workers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/orchestrator.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"test": "node --test test/*.test.js"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"fffleet": "^2.
|
|
24
|
+
"fffleet": "^2.9.0"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [
|
|
27
27
|
"ffmpeg",
|
package/src/job-store.js
CHANGED
|
@@ -9,7 +9,20 @@
|
|
|
9
9
|
* The built-in one is a SQLite file through `node:sqlite`, loaded only when asked for (Node 22.13 or later).
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import { withoutInlinePayload } from 'fffleet';
|
|
13
|
+
|
|
12
14
|
const FIELDS = ['state', 'workerId', 'createdAt', 'startedAt', 'finishedAt', 'progress', 'exitCode', 'error', 'outputs', 'stderrTail', 'seq', 'order', 'history'];
|
|
15
|
+
|
|
16
|
+
/** Inline results (a report's `data`, a `base64` payload) are not persisted, in the outputs or in the event history. */
|
|
17
|
+
function persistable(job) {
|
|
18
|
+
const data = {};
|
|
19
|
+
for (const key of FIELDS) data[key] = job[key];
|
|
20
|
+
if (Array.isArray(data.outputs)) data.outputs = data.outputs.map(withoutInlinePayload);
|
|
21
|
+
if (Array.isArray(data.history)) {
|
|
22
|
+
data.history = data.history.map(e => (Array.isArray(e.outputs) ? { ...e, outputs: e.outputs.map(withoutInlinePayload) } : e));
|
|
23
|
+
}
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
13
26
|
const SCHEMA_VERSION = 1;
|
|
14
27
|
|
|
15
28
|
/** @param {string} file */
|
|
@@ -40,9 +53,7 @@ export async function openSqliteJobStore(file) {
|
|
|
40
53
|
|
|
41
54
|
return {
|
|
42
55
|
save(job) {
|
|
43
|
-
|
|
44
|
-
for (const key of FIELDS) data[key] = job[key];
|
|
45
|
-
upsert.run(job.id, job.order, job.final ? 1 : 0, JSON.stringify(data));
|
|
56
|
+
upsert.run(job.id, job.order, job.final ? 1 : 0, JSON.stringify({ spec: job.spec, ...persistable(job) }));
|
|
46
57
|
},
|
|
47
58
|
loadAll() {
|
|
48
59
|
const out = [];
|
package/src/orchestrator.js
CHANGED
|
@@ -5,7 +5,7 @@ import { createProviders } from './providers/index.js';
|
|
|
5
5
|
import { openSqliteJobStore } from './job-store.js';
|
|
6
6
|
import { serveUi } from './ui.js';
|
|
7
7
|
import { randomUUID } from 'node:crypto';
|
|
8
|
-
import { FleetError, JobRecord, byPriority, canonicalJson, followJobEvents, implicitRequirements, normalizeKinds, normalizeSlots, parseSpec, pruneFinished, satisfies } from 'fffleet';
|
|
8
|
+
import { FleetError, JobRecord, byPriority, canonicalJson, followJobEvents, implicitRequirements, normalizeKinds, normalizeSlots, parseSpec, pruneFinished, resolveVariant, satisfies } from 'fffleet';
|
|
9
9
|
import {
|
|
10
10
|
Registry, allowed, checkBearer, close, createApiHandler, createAuthenticator, createClientStore, createTokenSigner, createTokenVerifier,
|
|
11
11
|
bearerOf, getStream, issueToken, jobMetrics, listen, loadSigningKey, processMetrics, readBody, readJson, send, sendError,
|
|
@@ -168,7 +168,12 @@ export function createOrchestrator({
|
|
|
168
168
|
const pool = poolFor(worker, job.spec.class);
|
|
169
169
|
const total = worker.slots[pool] ?? 0;
|
|
170
170
|
return total > 0 && (worker.used[pool] ?? 0) < total
|
|
171
|
-
&& satisfies(worker.capabilities, implicitRequirements(job.spec)) && satisfies(worker.capabilities, job.spec.requires);
|
|
171
|
+
&& satisfies(worker.capabilities, implicitRequirements(specFor(job, worker).spec)) && satisfies(worker.capabilities, job.spec.requires);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** The spec a worker gets: the job's variant for that worker, or the base spec. */
|
|
175
|
+
function specFor(job, worker) {
|
|
176
|
+
return resolveVariant(job.spec, { workerId: worker.id, capabilities: worker.capabilities });
|
|
172
177
|
}
|
|
173
178
|
|
|
174
179
|
function load(worker) {
|
|
@@ -272,14 +277,15 @@ export function createOrchestrator({
|
|
|
272
277
|
job.pool = pool;
|
|
273
278
|
job.released = false;
|
|
274
279
|
job.assignedAt = Date.now();
|
|
275
|
-
|
|
280
|
+
const { spec, variant } = specFor(job, worker);
|
|
281
|
+
job.push({ state: 'assigned', workerId: worker.id, variant });
|
|
276
282
|
|
|
277
283
|
let res;
|
|
278
284
|
try {
|
|
279
285
|
res = await fetch(`${worker.url}/v1/jobs`, {
|
|
280
286
|
method: 'POST',
|
|
281
287
|
headers: workerHeaders(worker, { 'content-type': 'application/json' }),
|
|
282
|
-
body: JSON.stringify(
|
|
288
|
+
body: JSON.stringify(spec),
|
|
283
289
|
signal: AbortSignal.timeout(10000),
|
|
284
290
|
});
|
|
285
291
|
} catch (err) {
|
|
@@ -310,7 +316,7 @@ export function createOrchestrator({
|
|
|
310
316
|
release(job, false);
|
|
311
317
|
if (dropWorker) removeWorker(worker, null);
|
|
312
318
|
if (job.final) return;
|
|
313
|
-
job.push({ state: 'queued', workerId: null });
|
|
319
|
+
job.push({ state: 'queued', workerId: null, variant: null });
|
|
314
320
|
enqueue(job);
|
|
315
321
|
schedulePump(REDISPATCH_DELAY_MS);
|
|
316
322
|
}
|