@kici-dev/orchestrator 0.12.0 → 0.14.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/dist/agent/dispatcher.d.ts +39 -0
- package/dist/agent/registry.d.ts +31 -0
- package/dist/app.d.ts +6 -0
- package/dist/cache/cache-upload-settle.d.ts +75 -0
- package/dist/cache/pending-inits.d.ts +9 -0
- package/dist/cancel/cancel-run.d.ts +22 -4
- package/dist/cancel/peer-job-cancel.d.ts +62 -0
- package/dist/cancel/sweep-stuck-cancelling.d.ts +3 -1
- package/dist/cli/api-client.d.ts +73 -0
- package/dist/cli/commands/cluster-settings.d.ts +31 -1
- package/dist/cli/commands/local-hook.d.ts +3 -2
- package/dist/cli/commands/local-trigger.d.ts +7 -0
- package/dist/cli/commands/peer.d.ts +27 -1
- package/dist/cli/commands/scaler.d.ts +40 -4
- package/dist/cli.js +2549 -972
- package/dist/cluster/cluster-settings-reader.d.ts +8 -2
- package/dist/cluster/coordinator-credential.d.ts +45 -0
- package/dist/cluster/coordinator.d.ts +52 -10
- package/dist/cluster/index.d.ts +1 -0
- package/dist/cluster/instance-heartbeat.d.ts +6 -1
- package/dist/cluster/join-token.d.ts +2 -0
- package/dist/cluster/peer-auth-coordinator.d.ts +13 -0
- package/dist/cluster/peer-client.d.ts +41 -4
- package/dist/cluster/peer-credentials.d.ts +31 -0
- package/dist/cluster/peer-forget.d.ts +138 -0
- package/dist/cluster/peer-handler.d.ts +18 -1
- package/dist/cluster/scaler-orphans-peer.d.ts +40 -0
- package/dist/cluster/settings-propagation.d.ts +85 -0
- package/dist/cluster/worker-cluster-settings.d.ts +29 -0
- package/dist/config.d.ts +12 -0
- package/dist/db/migrations/152_org_settings_cache_upload_settle_timeout.d.ts +15 -0
- package/dist/db/migrations/153_execution_runs_cancel_force.d.ts +16 -0
- package/dist/db/migrations/154_cluster_settings_firecracker_api_socket_wait.d.ts +4 -0
- package/dist/db/migrations/155_org_settings_reroute_spawn_retry.d.ts +17 -0
- package/dist/db/migrations/156_kici_events_match_outcome.d.ts +17 -0
- package/dist/db/types.d.ts +31 -0
- package/dist/events/event-router.d.ts +7 -1
- package/dist/events/event-store.d.ts +20 -3
- package/dist/events/types.d.ts +45 -0
- package/dist/helpers/windows-batch.d.ts +59 -0
- package/dist/index.js +252 -53
- package/dist/metrics/prometheus.d.ts +2 -0
- package/dist/orchestrator-core.d.ts +7 -0
- package/dist/pipeline/changed-files.d.ts +51 -0
- package/dist/pipeline/cross-source-tally.d.ts +21 -0
- package/dist/pipeline/degraded-reason.d.ts +8 -0
- package/dist/pipeline/dispatch-matched-workflow.d.ts +10 -0
- package/dist/pipeline/global-eval-round.d.ts +3 -2
- package/dist/pipeline/processor.d.ts +9 -1
- package/dist/pipeline/rerun-inputs.d.ts +16 -7
- package/dist/providers/github/changed-files.d.ts +14 -4
- package/dist/providers/universal-git/changed-files.d.ts +6 -0
- package/dist/providers/universal-git/config.d.ts +4 -0
- package/dist/registration/registration-store.d.ts +10 -0
- package/dist/routes/admin-cluster-settings.d.ts +13 -1
- package/dist/routes/admin-event-inspect.d.ts +36 -0
- package/dist/routes/admin-peer-forget.d.ts +43 -0
- package/dist/routes/admin-scaler-orphans.d.ts +64 -0
- package/dist/routes/admin.d.ts +23 -0
- package/dist/scaler/backend-factory.d.ts +6 -1
- package/dist/scaler/bare-metal-backend.d.ts +17 -15
- package/dist/scaler/bare-metal-launch.d.ts +90 -0
- package/dist/scaler/container-backend.d.ts +2 -0
- package/dist/scaler/container-runtime.d.ts +9 -0
- package/dist/scaler/firecracker-backend.d.ts +181 -7
- package/dist/scaler/live-vms.d.ts +57 -0
- package/dist/scaler/manager.d.ts +138 -5
- package/dist/scaler/orphan-requests.d.ts +23 -0
- package/dist/scaler/overlay-template.d.ts +38 -0
- package/dist/scaler/scaler-state-store.d.ts +7 -0
- package/dist/scaler/spawn-errors.d.ts +17 -0
- package/dist/scaler/startup-orphan-sweep.d.ts +15 -0
- package/dist/scaler/types.d.ts +21 -2
- package/dist/scaler/vm-job-bindings.d.ts +17 -0
- package/dist/secrets/rbac.d.ts +7 -1
- package/dist/server.js +7086 -2557
- package/dist/stale-detector/workflow-deadline-detector.d.ts +7 -1
- package/dist/standalone.js +16473 -11945
- package/dist/storage/s3.d.ts +36 -0
- package/dist/worker/in-memory-execution-tracker.d.ts +5 -0
- package/dist/worker/in-memory-job-queue.d.ts +21 -1
- package/dist/worker/queued-reroute-release.d.ts +39 -0
- package/dist/worker/reroute-spawn-control.d.ts +58 -0
- package/dist/worker/spawn-retry-budget.d.ts +87 -0
- package/dist/worker-core.d.ts +11 -2
- package/dist/ws/agent-handler.d.ts +24 -3
- package/dist/ws/agent-heartbeat.d.ts +2 -2
- package/installer-image-digests.json +3 -3
- package/package.json +5 -5
- package/sbom.spdx.json +53 -53
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ScalerOrphansAction, type PeerScalerOrphansResponse } from '@kici-dev/engine';
|
|
2
|
+
import type { ScalerManager } from './manager.js';
|
|
3
|
+
/**
|
|
4
|
+
* The longest a scaler orphan request waits for its node. The `kici-admin`
|
|
5
|
+
* HTTP client stops waiting for response headers after 300 s, so a longer
|
|
6
|
+
* wait could never reach the operator.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MAX_SCALER_ORPHANS_TIMEOUT_MS = 240000;
|
|
9
|
+
/** A scaler orphan answer without its peer-message envelope. */
|
|
10
|
+
export type ScalerOrphansAnswer = Omit<PeerScalerOrphansResponse, 'type' | 'messageId'>;
|
|
11
|
+
/** What one scaler orphan request asks of the node. */
|
|
12
|
+
export interface ScalerOrphansRequest {
|
|
13
|
+
action: ScalerOrphansAction;
|
|
14
|
+
/** `stop` only: the VM ids the operator approved. */
|
|
15
|
+
vmIds?: string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Answer a scaler orphan request on this node. A node with no scaler manager
|
|
19
|
+
* runs no Firecracker scaler: it lists nothing and holds none of the VMs a stop
|
|
20
|
+
* names. A failure is answered `ok: false` with its message, never thrown.
|
|
21
|
+
*/
|
|
22
|
+
export declare function answerScalerOrphansRequest(manager: Pick<ScalerManager, 'listLiveVms' | 'stopUntrackedVms' | 'firecrackerScalerNames'> | null, req: ScalerOrphansRequest): Promise<ScalerOrphansAnswer>;
|
|
23
|
+
//# sourceMappingURL=orphan-requests.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Directory that holds the templates, relative to the jailer chroot base dir.
|
|
3
|
+
* It sits beside the per-VM chroots because the orchestrator must already be
|
|
4
|
+
* able to create directories there; the leading dot keeps it out of the
|
|
5
|
+
* orphan sweep, which reads every other entry as a VM id.
|
|
6
|
+
*/
|
|
7
|
+
export declare const OVERLAY_TEMPLATE_DIR: string;
|
|
8
|
+
/**
|
|
9
|
+
* Timeout for formatting a template. It runs once per size per host, mostly
|
|
10
|
+
* off a spawn's critical path, and its `fsync` may wait behind a disk backlog,
|
|
11
|
+
* so it gets far more room than a per-spawn step.
|
|
12
|
+
*/
|
|
13
|
+
export declare const OVERLAY_TEMPLATE_MKFS_TIMEOUT_MS = 300000;
|
|
14
|
+
/** Timeout for the per-spawn copy. */
|
|
15
|
+
export declare const OVERLAY_COPY_TIMEOUT_MS = 30000;
|
|
16
|
+
/** Runs a host command, rejecting on failure. The backend passes its `execAsync`. */
|
|
17
|
+
export type OverlayCommandRunner = (cmd: string, args: string[], timeoutMs: number) => Promise<unknown>;
|
|
18
|
+
/** Where the template for a drive size lives. */
|
|
19
|
+
export declare function overlayTemplatePath(chrootBaseDir: string, sizeMib: number): string;
|
|
20
|
+
/**
|
|
21
|
+
* Whether `path` is a usable template for `sizeMib`: it exists, its size is
|
|
22
|
+
* exactly `sizeMib` MiB, and it carries the ext4 superblock magic.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isOverlayTemplate(path: string, sizeMib: number): Promise<boolean>;
|
|
25
|
+
/** Builds and hands out overlay templates for one jailer chroot base dir. */
|
|
26
|
+
export declare class OverlayTemplates {
|
|
27
|
+
private readonly chrootBaseDir;
|
|
28
|
+
private readonly run;
|
|
29
|
+
/** In-flight builds by size, so concurrent first uses share one build. */
|
|
30
|
+
private readonly builds;
|
|
31
|
+
constructor(chrootBaseDir: string, run: OverlayCommandRunner);
|
|
32
|
+
/** Return the path of a valid template for `sizeMib`, building it if needed. */
|
|
33
|
+
ensure(sizeMib: number): Promise<string>;
|
|
34
|
+
/** Create the overlay drive at `dest` as a sparse copy of the template. */
|
|
35
|
+
createOverlay(dest: string, sizeMib: number): Promise<void>;
|
|
36
|
+
private build;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=overlay-template.d.ts.map
|
|
@@ -270,6 +270,13 @@ export declare class ScalerStateStore {
|
|
|
270
270
|
* has an unknown owner and is deliberately not returned to anybody.
|
|
271
271
|
*/
|
|
272
272
|
listSpawningAgentsForOwner(instanceId: string): Promise<SpawningAgentSnapshot[]>;
|
|
273
|
+
/**
|
|
274
|
+
* Whether `instanceId` adopted an event provision whose spawn row is still
|
|
275
|
+
* live: one of the rows `listReapCandidates` returns that the reaper judges
|
|
276
|
+
* by its adopter's liveness rather than by its own deadline. `peer forget`
|
|
277
|
+
* reads it, so forgetting such an adopter never cuts the reaper's grace short.
|
|
278
|
+
*/
|
|
279
|
+
hasAdoptedProvisions(instanceId: string): Promise<boolean>;
|
|
273
280
|
/**
|
|
274
281
|
* Every event row that is either past its spawn deadline without ever being
|
|
275
282
|
* adopted, or adopted by some instance. The reaper decides which to tear down;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors a scaler backend's `spawn()` throws to tell the manager how to treat
|
|
3
|
+
* the failure.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* A spawn the host refused outright. Retrying cannot succeed until an operator
|
|
7
|
+
* changes something — the binary path, the label set's env — so the manager
|
|
8
|
+
* defers the scaler instead of freeing the capacity for an immediate retry.
|
|
9
|
+
* The backend emits `scaler.failed` before it throws this.
|
|
10
|
+
*/
|
|
11
|
+
export declare class DeterministicSpawnError extends Error {
|
|
12
|
+
constructor(message: string, options?: {
|
|
13
|
+
cause?: unknown;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export declare function isDeterministicSpawnError(err: unknown): err is DeterministicSpawnError;
|
|
17
|
+
//# sourceMappingURL=spawn-errors.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ScalerBackend } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reap each container and Firecracker backend's orphans once, and start the
|
|
4
|
+
* Firecracker periodic sweep. A failure is logged and never stops startup.
|
|
5
|
+
*
|
|
6
|
+
* The periodic sweep is what reclaims a VM chroot, TAP or IP that a failed
|
|
7
|
+
* spawn could not remove (the jailer had already taken the chroot, or the
|
|
8
|
+
* removal raced the jailer). Startup-only cleanup leaves those to accumulate
|
|
9
|
+
* for as long as the process stays up.
|
|
10
|
+
*/
|
|
11
|
+
export declare function reapOrphansAtStartup(backends: ReadonlyArray<{
|
|
12
|
+
name: string;
|
|
13
|
+
backend: ScalerBackend;
|
|
14
|
+
}>): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=startup-orphan-sweep.d.ts.map
|
package/dist/scaler/types.d.ts
CHANGED
|
@@ -200,9 +200,12 @@ export interface ManagedAgent {
|
|
|
200
200
|
* Result of a scaling decision.
|
|
201
201
|
* Discriminated union on 'action' for exhaustive pattern matching.
|
|
202
202
|
*/
|
|
203
|
-
export type ScaleResult =
|
|
203
|
+
export type ScaleResult =
|
|
204
|
+
/** A spawn started; `agentId` is the scaler-managed id the new agent will register with. */
|
|
205
|
+
{
|
|
204
206
|
action: 'spawning';
|
|
205
207
|
backendType: string;
|
|
208
|
+
agentId: string;
|
|
206
209
|
} | {
|
|
207
210
|
action: 'at-capacity';
|
|
208
211
|
} | {
|
|
@@ -212,10 +215,15 @@ export type ScaleResult = {
|
|
|
212
215
|
action: 'failed';
|
|
213
216
|
error: string;
|
|
214
217
|
}
|
|
215
|
-
/**
|
|
218
|
+
/**
|
|
219
|
+
* Scale-up declined without attempting a spawn (e.g. coordinator draining).
|
|
220
|
+
* `retryAfterMs` is set when the scaler is deferring after failed launches:
|
|
221
|
+
* a request before then is declined the same way.
|
|
222
|
+
*/
|
|
216
223
|
| {
|
|
217
224
|
action: 'skipped';
|
|
218
225
|
reason: string;
|
|
226
|
+
retryAfterMs?: number;
|
|
219
227
|
};
|
|
220
228
|
/**
|
|
221
229
|
* What triggered a pending-scale re-drive (`Dispatcher.retryPendingScaleRequests`):
|
|
@@ -297,6 +305,9 @@ export interface ScalerBackend {
|
|
|
297
305
|
* the provisioned resource for operator inspection.
|
|
298
306
|
* @returns The managed agent tracking object
|
|
299
307
|
* @throws If the label set is not supported by this backend
|
|
308
|
+
* @throws DeterministicSpawnError, after emitting `scaler.failed`, when the
|
|
309
|
+
* host refused the launch itself. The manager defers the scaler instead of
|
|
310
|
+
* freeing the capacity for an immediate retry.
|
|
300
311
|
*/
|
|
301
312
|
spawn(labelSet: string[], agentId: string, orchestratorUrl: string, onEvent?: ScalerEventCallback, effectiveLimits?: EffectiveLimits, spawnContext?: SpawnContext,
|
|
302
313
|
/**
|
|
@@ -316,6 +327,14 @@ export interface ScalerBackend {
|
|
|
316
327
|
* teardown or a spawn timeout. Local backends accept and ignore it.
|
|
317
328
|
*/
|
|
318
329
|
destroy(managedId: string, context?: ScalerDestroyContext): Promise<void>;
|
|
330
|
+
/**
|
|
331
|
+
* Record that a managed agent's process registered with the orchestrator.
|
|
332
|
+
* Called by ScalerManager when a spawn it started registers locally.
|
|
333
|
+
* Optional: a backend implements it when it must tell a compute that stops
|
|
334
|
+
* before registering (a failed spawn it tears down itself) from one that
|
|
335
|
+
* stops after (an agent whose disconnect triggers `destroy`).
|
|
336
|
+
*/
|
|
337
|
+
markRegistered?(managedId: string): void;
|
|
319
338
|
/**
|
|
320
339
|
* Reclaim the HOST-LOCAL compute of a managed agent this backend no longer
|
|
321
340
|
* tracks in memory, from whatever durable host state survived the loss.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable job-to-agent bindings, read from the coordinator's dispatch queue.
|
|
3
|
+
*
|
|
4
|
+
* A worker has no database, so this is the coordinator's half of the
|
|
5
|
+
* live-VM tracking: a VM whose agent holds a non-terminal job is tracked, even
|
|
6
|
+
* when the node that runs the VM has lost every in-memory trace of it.
|
|
7
|
+
*/
|
|
8
|
+
import type { Kysely } from 'kysely';
|
|
9
|
+
import type { Database } from '../db/types.js';
|
|
10
|
+
/**
|
|
11
|
+
* The non-terminal job each of `agentIds` holds, keyed by agent id. An agent
|
|
12
|
+
* holds a job it was dispatched (`agent_id`) and a job waiting for it to
|
|
13
|
+
* reconnect (`recovery_agent_id`). The value is the job id the queue
|
|
14
|
+
* dispatches by, `dispatch_queue.id`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function findActiveJobBindings(db: Kysely<Database>, agentIds: readonly string[]): Promise<Map<string, string>>;
|
|
17
|
+
//# sourceMappingURL=vm-job-bindings.d.ts.map
|
package/dist/secrets/rbac.d.ts
CHANGED
|
@@ -17,7 +17,13 @@ export type Permission = 'context.create' | 'context.read' | 'context.update' |
|
|
|
17
17
|
/** Read the org-wide CI trust policy that gates fork / unknown / workflow-change PRs. */
|
|
18
18
|
| 'ci_trust.read'
|
|
19
19
|
/** Modify org-wide trust policies (independent mode only — Platform-attached PATCH refuses). */
|
|
20
|
-
| 'ci_trust.admin'
|
|
20
|
+
| 'ci_trust.admin'
|
|
21
|
+
/** List the live Firecracker VMs on a node and how each is tracked. */
|
|
22
|
+
| 'scaler.read'
|
|
23
|
+
/** Stop live Firecracker VMs the node's orchestrator does not track. */
|
|
24
|
+
| 'scaler.manage'
|
|
25
|
+
/** Drop a departed peer from the coordinators' live peer registries. */
|
|
26
|
+
| 'peer.manage';
|
|
21
27
|
/**
|
|
22
28
|
* Error thrown when a role lacks the required permission.
|
|
23
29
|
*/
|