@ship.zone/runner 4.0.0 → 5.0.1
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/.smartconfig.json +13 -2
- package/changelog.md +26 -0
- package/dist_rust/runnerworkspace_linux_amd64_musl.tsrust-build.json +3 -3
- package/dist_rust/runnerworkspace_linux_arm64_musl.tsrust-build.json +3 -3
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/cli.d.ts +7 -0
- package/dist_ts/cli.js +140 -48
- package/dist_ts/config.js +20 -17
- package/dist_ts/interfaces.d.ts +7 -24
- package/dist_ts/microvm-executor.js +62 -27
- package/dist_ts/protocol-validator.d.ts +3 -5
- package/dist_ts/protocol-validator.js +7 -36
- package/dist_ts/runner.d.ts +3 -4
- package/dist_ts/runner.js +9 -14
- package/dist_ts/state-owner.d.ts +8 -0
- package/dist_ts/state-owner.js +15 -1
- package/package.json +5 -5
- package/readme.md +66 -79
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/cli.ts +162 -52
- package/ts/config.ts +20 -18
- package/ts/interfaces.ts +9 -24
- package/ts/microvm-executor.ts +77 -29
- package/ts/protocol-validator.ts +6 -39
- package/ts/runner.ts +6 -13
- package/ts/state-owner.ts +20 -0
package/ts/config.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
writeAll,
|
|
11
11
|
} from './filesystem.js';
|
|
12
12
|
import type { IOciExecutorConfig, IRunnerConfig, IRunnerCredential } from './interfaces.js';
|
|
13
|
+
import { parseDigestPinnedImageReference } from './oci-registry.js';
|
|
13
14
|
import { isRecord, validateHttpUrl } from './validation.js';
|
|
14
15
|
|
|
15
16
|
const { dirname, isAbsolute, join } = plugins.path;
|
|
@@ -31,7 +32,6 @@ const timestampPattern =
|
|
|
31
32
|
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/;
|
|
32
33
|
|
|
33
34
|
const defaultOciConfig: IOciExecutorConfig = {
|
|
34
|
-
runnerProfile: 'workload',
|
|
35
35
|
kernelPath: '/var/lib/ship-zone-runner/vmlinux',
|
|
36
36
|
bootArgs: 'console=ttyS0 reboot=k panic=1 pci=off rdinit=/init',
|
|
37
37
|
maximumRootfsBytes: 4 * 1024 * 1024 * 1024,
|
|
@@ -57,8 +57,8 @@ const defaultOciConfig: IOciExecutorConfig = {
|
|
|
57
57
|
export const defaultRunnerConfig = (): IRunnerConfig => ({
|
|
58
58
|
controlPlaneUrl: '',
|
|
59
59
|
allowInsecureLoopback: false,
|
|
60
|
-
name: `runner-${
|
|
61
|
-
labels: ['linux', hostArchitectureLabel(), '
|
|
60
|
+
name: `runner-${plugins.os.hostname() || 'local'}`,
|
|
61
|
+
labels: ['linux', hostArchitectureLabel(), 'microvm'],
|
|
62
62
|
stateDirectory: './.runner-state',
|
|
63
63
|
transferStagingReserveBytes: 1024 * 1024 * 1024,
|
|
64
64
|
transferStagingReserveInodes: 10_000,
|
|
@@ -187,17 +187,14 @@ const validTimestamp = (value: string): boolean => {
|
|
|
187
187
|
|
|
188
188
|
/**
|
|
189
189
|
* Network modes enforceable by the Firecracker microVM runner:
|
|
190
|
-
* - `none
|
|
191
|
-
* - `egress`
|
|
190
|
+
* - `none`: isolated guest namespace with loopback only.
|
|
191
|
+
* Host-enforced `egress` guest transport is not yet wired into Firecracker/smartvm, so
|
|
192
|
+
* advertising `egress` is rejected fail-closed instead of silently running egress jobs offline.
|
|
192
193
|
*/
|
|
193
194
|
const requireEnforceableNetworks = (networks: readonly string[]): void => {
|
|
194
|
-
if (
|
|
195
|
-
networks.length === 0 ||
|
|
196
|
-
!networks.includes('none') ||
|
|
197
|
-
networks.some((mode) => mode !== 'none' && mode !== 'egress')
|
|
198
|
-
) {
|
|
195
|
+
if (networks.length !== 1 || networks[0] !== 'none') {
|
|
199
196
|
throw new ConfigurationError(
|
|
200
|
-
'oci.allowedNetworks must
|
|
197
|
+
'oci.allowedNetworks must be ["none"]; Firecracker guest egress transport is not yet wired',
|
|
201
198
|
);
|
|
202
199
|
}
|
|
203
200
|
};
|
|
@@ -228,9 +225,10 @@ const parseOciConfig = (input: unknown, fallback: IOciExecutorConfig): IOciExecu
|
|
|
228
225
|
'oci.runtime and oci.runtimePath were removed in 4.0.0; this runner uses Firecracker microVMs exclusively',
|
|
229
226
|
);
|
|
230
227
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
228
|
+
if (Object.hasOwn(value, 'runnerProfile')) {
|
|
229
|
+
throw new ConfigurationError(
|
|
230
|
+
'oci.runnerProfile was removed in 5.0.0; one unified microVM runner executes oci, vm, and oci-image jobs',
|
|
231
|
+
);
|
|
234
232
|
}
|
|
235
233
|
const allowedNetworks = stringArray(
|
|
236
234
|
value.allowedNetworks,
|
|
@@ -240,9 +238,9 @@ const parseOciConfig = (input: unknown, fallback: IOciExecutorConfig): IOciExecu
|
|
|
240
238
|
);
|
|
241
239
|
requireEnforceableNetworks(allowedNetworks);
|
|
242
240
|
return {
|
|
243
|
-
runnerProfile,
|
|
244
241
|
kernelPath: stringValue(value.kernelPath, fallback.kernelPath, 'oci.kernelPath'),
|
|
245
242
|
builderRootfsPath: optionalString(value.builderRootfsPath, 'oci.builderRootfsPath'),
|
|
243
|
+
builderImage: optionalString(value.builderImage, 'oci.builderImage'),
|
|
246
244
|
buildctlPath: optionalString(value.buildctlPath, 'oci.buildctlPath'),
|
|
247
245
|
smartvmSocketPath: optionalString(value.smartvmSocketPath, 'oci.smartvmSocketPath'),
|
|
248
246
|
smartvmRuntimeDir: optionalString(value.smartvmRuntimeDir, 'oci.smartvmRuntimeDir'),
|
|
@@ -670,9 +668,6 @@ export const validateRunnerConfig = (config: IRunnerConfig): void => {
|
|
|
670
668
|
}
|
|
671
669
|
numberValue(config.oci.defaultCpus, config.oci.defaultCpus, 'oci.defaultCpus', 0, 1024);
|
|
672
670
|
numberValue(config.oci.maximumCpus, config.oci.maximumCpus, 'oci.maximumCpus', 0, 1024);
|
|
673
|
-
if (config.oci.runnerProfile !== 'workload' && config.oci.runnerProfile !== 'builder') {
|
|
674
|
-
throw new ConfigurationError('oci.runnerProfile must be "workload" or "builder"');
|
|
675
|
-
}
|
|
676
671
|
requireEnforceableNetworks(config.oci.allowedNetworks);
|
|
677
672
|
parseBlockedCidrs(config.oci.egressBlockedCidrs, []);
|
|
678
673
|
if (!isAbsolute(config.oci.kernelPath)) {
|
|
@@ -681,6 +676,13 @@ export const validateRunnerConfig = (config: IRunnerConfig): void => {
|
|
|
681
676
|
if (config.oci.builderRootfsPath && !isAbsolute(config.oci.builderRootfsPath)) {
|
|
682
677
|
throw new ConfigurationError('oci.builderRootfsPath must be absolute');
|
|
683
678
|
}
|
|
679
|
+
if (config.oci.builderImage) {
|
|
680
|
+
try {
|
|
681
|
+
parseDigestPinnedImageReference(config.oci.builderImage);
|
|
682
|
+
} catch {
|
|
683
|
+
throw new ConfigurationError('oci.builderImage must be a digest-pinned OCI image reference');
|
|
684
|
+
}
|
|
685
|
+
}
|
|
684
686
|
if (config.oci.buildctlPath && !isAbsolute(config.oci.buildctlPath)) {
|
|
685
687
|
throw new ConfigurationError('oci.buildctlPath must be absolute');
|
|
686
688
|
}
|
package/ts/interfaces.ts
CHANGED
|
@@ -3,12 +3,8 @@ import { commitinfo } from './00_commitinfo_data.js';
|
|
|
3
3
|
export const runnerVersion: string = commitinfo.version;
|
|
4
4
|
|
|
5
5
|
export type TExecutionProfile = 'oci' | 'oci-image' | 'vm';
|
|
6
|
-
export type TRunnerRole = 'workload' | 'builder';
|
|
7
|
-
export type TIsolation = 'container' | 'microvm';
|
|
8
6
|
export type TRunnerFeature = 'source.tar-gz' | 'artifacts' | 'caches';
|
|
9
|
-
export type TLeaseFeature = 'image-pull-grants' | 'candidate-bindings' | 'npm-read-grants';
|
|
10
7
|
export type TNetworkMode = 'none' | 'egress';
|
|
11
|
-
export type TSourceFormat = 'tar.gz';
|
|
12
8
|
export type TArtifactPermission = 'none' | 'write';
|
|
13
9
|
export type TCachePermission = 'none' | 'read' | 'read-write';
|
|
14
10
|
export type TImagePermission = 'none' | 'push';
|
|
@@ -83,17 +79,13 @@ export interface IResourceLimits {
|
|
|
83
79
|
|
|
84
80
|
export interface IRunnerCapabilities {
|
|
85
81
|
executionProfiles: TExecutionProfile[];
|
|
86
|
-
isolation: TIsolation[];
|
|
87
82
|
platforms: string[];
|
|
88
83
|
labels: string[];
|
|
89
84
|
features: TRunnerFeature[];
|
|
90
85
|
networks: TNetworkMode[];
|
|
91
|
-
sourceFormats: TSourceFormat[];
|
|
92
86
|
limits: ITransferLimits;
|
|
93
87
|
/** The largest resource ceilings the runner enforces per attempt. */
|
|
94
88
|
resources?: IResourceLimits;
|
|
95
|
-
/** The lease contents the runner uses. */
|
|
96
|
-
leaseFeatures?: TLeaseFeature[];
|
|
97
89
|
/** The largest job `timeoutMs` the runner executes. */
|
|
98
90
|
maximumTimeoutMs?: number;
|
|
99
91
|
}
|
|
@@ -143,7 +135,6 @@ export interface IClaimJobRequest {
|
|
|
143
135
|
claimRequestId: string;
|
|
144
136
|
runnerId: string;
|
|
145
137
|
sessionId: string;
|
|
146
|
-
capabilities: IRunnerCapabilities;
|
|
147
138
|
}
|
|
148
139
|
|
|
149
140
|
export interface IClaimJobResponse {
|
|
@@ -321,7 +312,6 @@ export interface IErrorResponse {
|
|
|
321
312
|
|
|
322
313
|
export interface IJobRequirements {
|
|
323
314
|
executionProfile: TExecutionProfile;
|
|
324
|
-
isolation: TIsolation;
|
|
325
315
|
platform?: string;
|
|
326
316
|
labels: string[];
|
|
327
317
|
features: TRunnerFeature[];
|
|
@@ -480,26 +470,25 @@ export interface IImageBuildRunnerJob extends ICompiledRunnerJobBase {
|
|
|
480
470
|
/** Every compiled job shape the published runner job schema admits. */
|
|
481
471
|
export type TCompiledRunnerJob = IContainerRunnerJob | IVmRunnerJob | IImageBuildRunnerJob;
|
|
482
472
|
|
|
483
|
-
/** An `oci` job this runner executes in Firecracker
|
|
473
|
+
/** An `oci` job this runner executes in a Firecracker microVM. */
|
|
484
474
|
export interface IOciRunnerJob extends IContainerRunnerJob {
|
|
485
|
-
requirements: IJobRequirements & { executionProfile: 'oci'
|
|
475
|
+
requirements: IJobRequirements & { executionProfile: 'oci' };
|
|
486
476
|
}
|
|
487
477
|
|
|
488
|
-
/** A `vm` job this runner executes in Firecracker
|
|
478
|
+
/** A `vm` job this runner executes in a Firecracker microVM. */
|
|
489
479
|
export interface IVmExecutableRunnerJob extends IVmRunnerJob {
|
|
490
|
-
requirements: IJobRequirements & { executionProfile: 'vm';
|
|
480
|
+
requirements: IJobRequirements & { executionProfile: 'vm'; platform: string };
|
|
491
481
|
}
|
|
492
482
|
|
|
493
|
-
/** An `oci-image` job this runner executes in a
|
|
483
|
+
/** An `oci-image` job this runner executes in a Firecracker microVM. */
|
|
494
484
|
export interface IImageBuildExecutableRunnerJob extends IImageBuildRunnerJob {
|
|
495
485
|
requirements: IJobRequirements & {
|
|
496
486
|
executionProfile: 'oci-image';
|
|
497
|
-
isolation: 'microvm';
|
|
498
487
|
platform: string;
|
|
499
488
|
};
|
|
500
489
|
}
|
|
501
490
|
|
|
502
|
-
/** Every compiled job shape this Firecracker runner
|
|
491
|
+
/** Every compiled job shape this unified Firecracker runner executes. */
|
|
503
492
|
export type TExecutableRunnerJob =
|
|
504
493
|
| IOciRunnerJob
|
|
505
494
|
| IVmExecutableRunnerJob
|
|
@@ -561,16 +550,12 @@ export type TOciArchitecture = 'amd64' | 'arm64';
|
|
|
561
550
|
export type TOciHelperTarget = 'linux_amd64' | 'linux_arm64';
|
|
562
551
|
|
|
563
552
|
export interface IOciExecutorConfig {
|
|
564
|
-
/**
|
|
565
|
-
* Dedicated runner role per `@ship.zone/ci-spec`:
|
|
566
|
-
* - `'workload'`: executes `oci` and `vm` jobs (never `oci-image`).
|
|
567
|
-
* - `'builder'`: executes `oci-image` container builds exclusively (never `oci` or `vm`).
|
|
568
|
-
*/
|
|
569
|
-
runnerProfile: TRunnerRole;
|
|
570
553
|
/** Pinned Linux vmlinux kernel path for Firecracker microVMs. */
|
|
571
554
|
kernelPath: string;
|
|
572
|
-
/**
|
|
555
|
+
/** Optional pinned ext2 guest rootfs containing rootless BuildKit (`buildkitd` + `buildctl`) for `oci-image` jobs. */
|
|
573
556
|
builderRootfsPath?: string;
|
|
557
|
+
/** Optional digest-pinned OCI image containing rootless BuildKit (pulled on demand when `builderRootfsPath` is not set). */
|
|
558
|
+
builderImage?: string;
|
|
574
559
|
/** Optional override for the `buildctl` binary path inside the builder guest. */
|
|
575
560
|
buildctlPath?: string;
|
|
576
561
|
/** Optional smartvm-helper Unix socket path (defaults to `/run/smartvm/helper.sock`). */
|
package/ts/microvm-executor.ts
CHANGED
|
@@ -40,6 +40,7 @@ import { EgressAllowlistController, grantOriginsFromLease } from './egress-proxy
|
|
|
40
40
|
import { buildNpmrcContent, GUEST_NPMRC_PATH } from './npm-grants.js';
|
|
41
41
|
import {
|
|
42
42
|
ensurePrivateStateDirectory,
|
|
43
|
+
resolvePackagedSmartVmBridgePath,
|
|
43
44
|
resolvePackagedWorkspaceHelperPath,
|
|
44
45
|
type RunnerStateOwner,
|
|
45
46
|
workspaceHelperMaximumBytes,
|
|
@@ -487,10 +488,12 @@ export class MicroVmExecutor implements IJobExecutor {
|
|
|
487
488
|
if (runtimeDir) {
|
|
488
489
|
await plugins.fs.mkdir(runtimeDir, { recursive: true, mode: 0o700 });
|
|
489
490
|
}
|
|
491
|
+
const bridgeBinaryPath = this.config.oci.smartvmBridgePath ??
|
|
492
|
+
await resolvePackagedSmartVmBridgePath();
|
|
490
493
|
const options: plugins.smartvm.ISmartVMConnectOptions = {
|
|
491
494
|
...(this.config.oci.smartvmSocketPath ? { helperSocketPath: this.config.oci.smartvmSocketPath } : {}),
|
|
492
495
|
...(runtimeDir ? { runtimeDir } : {}),
|
|
493
|
-
...(
|
|
496
|
+
...(bridgeBinaryPath ? { bridgeBinaryPath } : {}),
|
|
494
497
|
requestTimeoutMs: this.config.requestTimeoutMs,
|
|
495
498
|
};
|
|
496
499
|
this.smartvmPromise = this.connectSmartVm(options).catch((error) => {
|
|
@@ -594,6 +597,14 @@ export class MicroVmExecutor implements IJobExecutor {
|
|
|
594
597
|
if (this.runtimeFacts) return this.runtimeFacts;
|
|
595
598
|
this.stateOwner.assertHeld();
|
|
596
599
|
await this.verifyKernelFile(this.config.oci.kernelPath);
|
|
600
|
+
if (this.config.oci.builderRootfsPath) {
|
|
601
|
+
const builderStat = await lstatIfPresent(this.config.oci.builderRootfsPath);
|
|
602
|
+
if (!builderStat || !builderStat.isFile() || builderStat.size === 0) {
|
|
603
|
+
throw new RunnerError(
|
|
604
|
+
`Firecracker builder rootfs is missing or invalid: ${this.config.oci.builderRootfsPath}`,
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
597
608
|
const smartvm = await this.getSmartVm();
|
|
598
609
|
const report = await smartvm.checkHost();
|
|
599
610
|
if (!report.ok) {
|
|
@@ -653,39 +664,76 @@ export class MicroVmExecutor implements IJobExecutor {
|
|
|
653
664
|
const smartvm = await this.getSmartVm();
|
|
654
665
|
|
|
655
666
|
if ('build' in job) {
|
|
656
|
-
const builderRootfsPath = this.config.oci.builderRootfsPath;
|
|
657
|
-
if (!builderRootfsPath) {
|
|
658
|
-
throw new RunnerError(
|
|
659
|
-
'oci.builderRootfsPath must be configured to execute oci-image builds',
|
|
660
|
-
);
|
|
661
|
-
}
|
|
662
|
-
const stat = await lstatIfPresent(builderRootfsPath);
|
|
663
|
-
if (!stat || !stat.isFile() || stat.size === 0) {
|
|
664
|
-
throw new RunnerError(
|
|
665
|
-
`Firecracker builder rootfs is missing or invalid: ${builderRootfsPath}`,
|
|
666
|
-
);
|
|
667
|
-
}
|
|
668
667
|
// Verify every base image reference resolves to an exact digest-pinned image.
|
|
669
668
|
for (const base of job.build.baseImages) {
|
|
670
669
|
const resolved = resolveImageReference(base.image, context.lease.bindings);
|
|
671
670
|
parseDigestPinnedImageReference(resolved);
|
|
672
671
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
672
|
+
|
|
673
|
+
const builderRootfsPath = this.config.oci.builderRootfsPath;
|
|
674
|
+
const builderImage = this.config.oci.builderImage;
|
|
675
|
+
|
|
676
|
+
if (builderRootfsPath) {
|
|
677
|
+
const stat = await lstatIfPresent(builderRootfsPath);
|
|
678
|
+
if (!stat || !stat.isFile() || stat.size === 0) {
|
|
679
|
+
throw new RunnerError(
|
|
680
|
+
`Firecracker builder rootfs is missing or invalid: ${builderRootfsPath}`,
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
const { imageDigest } = await smartvm.computeImageDigest({
|
|
684
|
+
kernelPath: runtime.kernelPath,
|
|
685
|
+
rootfsPath: builderRootfsPath,
|
|
686
|
+
initrdPath: runtime.initrdPath,
|
|
687
|
+
bootArgs: this.config.oci.bootArgs,
|
|
688
|
+
});
|
|
689
|
+
return {
|
|
690
|
+
preparationId: plugins.crypto.randomUUID(),
|
|
691
|
+
attemptId: context.lease.attemptId,
|
|
692
|
+
image: builderRootfsPath,
|
|
693
|
+
imageArchitecture: runtime.architecture,
|
|
694
|
+
rootfsPath: builderRootfsPath,
|
|
695
|
+
imageDigest,
|
|
696
|
+
shapeId: shape.id,
|
|
697
|
+
cleanup: async () => {},
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
if (builderImage) {
|
|
702
|
+
parseDigestPinnedImageReference(builderImage);
|
|
703
|
+
const materialized = this.dependencies.materializeImage
|
|
704
|
+
? await this.dependencies.materializeImage(builderImage, runtime.architecture, context.signal)
|
|
705
|
+
: await this.getRegistryClient(runtime.helperPath).materializeImage(
|
|
706
|
+
builderImage,
|
|
707
|
+
runtime.architecture,
|
|
708
|
+
context.signal,
|
|
709
|
+
);
|
|
710
|
+
if (materialized.os !== 'linux' || materialized.architecture !== runtime.architecture) {
|
|
711
|
+
await materialized.cleanup().catch(() => {});
|
|
712
|
+
throw new ProtocolError(
|
|
713
|
+
`Materialized builder image platform ${materialized.os}/${materialized.architecture} does not match linux/${runtime.architecture}`,
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
const { imageDigest } = await smartvm.computeImageDigest({
|
|
717
|
+
kernelPath: runtime.kernelPath,
|
|
718
|
+
rootfsPath: materialized.rootfsPath,
|
|
719
|
+
initrdPath: runtime.initrdPath,
|
|
720
|
+
bootArgs: this.config.oci.bootArgs,
|
|
721
|
+
});
|
|
722
|
+
return {
|
|
723
|
+
preparationId: plugins.crypto.randomUUID(),
|
|
724
|
+
attemptId: context.lease.attemptId,
|
|
725
|
+
image: builderImage,
|
|
726
|
+
imageArchitecture: materialized.architecture,
|
|
727
|
+
rootfsPath: materialized.rootfsPath,
|
|
728
|
+
imageDigest,
|
|
729
|
+
shapeId: shape.id,
|
|
730
|
+
cleanup: () => materialized.cleanup(),
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
throw new RunnerError(
|
|
735
|
+
'oci.builderRootfsPath or oci.builderImage must be configured to execute oci-image builds',
|
|
736
|
+
);
|
|
689
737
|
}
|
|
690
738
|
|
|
691
739
|
const image = resolveImageReference(job.execution.image, context.lease.bindings);
|
package/ts/protocol-validator.ts
CHANGED
|
@@ -3,14 +3,12 @@ import type {
|
|
|
3
3
|
ICompiledStep,
|
|
4
4
|
IJobLease,
|
|
5
5
|
IOciJobLease,
|
|
6
|
-
IOciRunnerJob,
|
|
7
6
|
IRunnerCapabilities,
|
|
8
7
|
ITransferLimits,
|
|
9
8
|
TCompiledRunnerJob,
|
|
10
9
|
TImageReference,
|
|
11
10
|
TJsonObject,
|
|
12
11
|
TJsonValue,
|
|
13
|
-
TLeaseFeature,
|
|
14
12
|
} from './interfaces.js';
|
|
15
13
|
import { acceptSpecVersion, runnerSpecVersion } from './spec-version.js';
|
|
16
14
|
import { isRecord } from './validation.js';
|
|
@@ -169,9 +167,6 @@ const requireCapabilityFit = (
|
|
|
169
167
|
if (!capabilities.executionProfiles.includes(requirements.executionProfile)) {
|
|
170
168
|
throw new ProtocolError('Job execution profile is not supported by this runner');
|
|
171
169
|
}
|
|
172
|
-
if (!capabilities.isolation.includes(requirements.isolation)) {
|
|
173
|
-
throw new ProtocolError('Job isolation is not supported by this runner');
|
|
174
|
-
}
|
|
175
170
|
if (requirements.platform !== undefined) {
|
|
176
171
|
if (!capabilities.platforms.includes(requirements.platform)) {
|
|
177
172
|
throw new ProtocolError('Job platform is not executed natively by this runner');
|
|
@@ -192,9 +187,6 @@ const requireCapabilityFit = (
|
|
|
192
187
|
if (!capabilities.networks.includes(job.network.mode)) {
|
|
193
188
|
throw new ProtocolError('Job network mode is not supported by this runner');
|
|
194
189
|
}
|
|
195
|
-
if (!capabilities.sourceFormats.includes(job.source.format)) {
|
|
196
|
-
throw new ProtocolError('Job source format is not supported by this runner');
|
|
197
|
-
}
|
|
198
190
|
for (const name of transferLimitNames) {
|
|
199
191
|
if (requirements.limits[name] > capabilities.limits[name]) {
|
|
200
192
|
throw new ProtocolError(`Job requirement ${name} exceeds runner capability`);
|
|
@@ -222,28 +214,6 @@ const requireCapabilityFit = (
|
|
|
222
214
|
}
|
|
223
215
|
};
|
|
224
216
|
|
|
225
|
-
/**
|
|
226
|
-
* Checks that a lease uses only the lease features of the capability snapshot: a pull grant
|
|
227
|
-
* requires `image-pull-grants`, a binding `candidate-bindings`, and `npmGrants`
|
|
228
|
-
* `npm-read-grants`. A snapshot without `leaseFeatures` imposes no such condition.
|
|
229
|
-
*/
|
|
230
|
-
const requireLeaseFeatureFit = (lease: IJobLease, capabilities: IRunnerCapabilities): void => {
|
|
231
|
-
const advertised = capabilities.leaseFeatures;
|
|
232
|
-
if (advertised === undefined) return;
|
|
233
|
-
const used: Array<[boolean, TLeaseFeature]> = [
|
|
234
|
-
[lease.grants.some((grant) => grant.access === 'pull'), 'image-pull-grants'],
|
|
235
|
-
[lease.bindings.length > 0, 'candidate-bindings'],
|
|
236
|
-
[lease.npmGrants !== undefined, 'npm-read-grants'],
|
|
237
|
-
];
|
|
238
|
-
for (const [uses, feature] of used) {
|
|
239
|
-
if (uses && !advertised.includes(feature)) {
|
|
240
|
-
throw new ProtocolError(
|
|
241
|
-
`Lease uses ${feature}, a lease feature this runner does not advertise`,
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
|
|
247
217
|
const requireTransferCoherence = (job: TCompiledRunnerJob): void => {
|
|
248
218
|
const limits = job.requirements.limits;
|
|
249
219
|
if (!job.requirements.features.includes('source.tar-gz')) {
|
|
@@ -464,15 +434,11 @@ const requireLeaseCoherence = (lease: IJobLease): void => {
|
|
|
464
434
|
};
|
|
465
435
|
|
|
466
436
|
/**
|
|
467
|
-
* Narrows a coherent lease to an executable Firecracker
|
|
468
|
-
* `oci-image`).
|
|
469
|
-
* Firecracker microVMs exclusively.
|
|
437
|
+
* Narrows a coherent lease to an executable Firecracker microVM lease (`oci`, `vm`, or
|
|
438
|
+
* `oci-image`).
|
|
470
439
|
*/
|
|
471
440
|
export const requireExecutableLease = (lease: IJobLease): IOciJobLease => {
|
|
472
441
|
const job = lease.job;
|
|
473
|
-
if (job.requirements.isolation !== 'microvm') {
|
|
474
|
-
throw new UnsupportedJobError('container isolation is not supported by this runner');
|
|
475
|
-
}
|
|
476
442
|
if (job.requirements.platform && !job.requirements.platform.startsWith('linux/')) {
|
|
477
443
|
throw new UnsupportedJobError(
|
|
478
444
|
`Platform ${job.requirements.platform} is not supported by this Linux Firecracker runner`,
|
|
@@ -491,6 +457,9 @@ export const requireExecutableLease = (lease: IJobLease): IOciJobLease => {
|
|
|
491
457
|
if (!('build' in job)) {
|
|
492
458
|
throw new UnsupportedJobError('Job does not match the oci-image build profile');
|
|
493
459
|
}
|
|
460
|
+
if (job.caches.length > 0) {
|
|
461
|
+
throw new UnsupportedJobError('oci-image build caches are not supported by this runner');
|
|
462
|
+
}
|
|
494
463
|
} else {
|
|
495
464
|
throw new UnsupportedJobError(
|
|
496
465
|
`Execution profile ${String(profile)} is not supported by this runner`,
|
|
@@ -550,8 +519,7 @@ export class RunnerProtocolValidator {
|
|
|
550
519
|
}
|
|
551
520
|
|
|
552
521
|
/**
|
|
553
|
-
* Validates a lease against the published `JobLease` schema, its job, lease coherence
|
|
554
|
-
* lease features of the capability snapshot.
|
|
522
|
+
* Validates a lease against the published `JobLease` schema, its job, and lease coherence.
|
|
555
523
|
*/
|
|
556
524
|
public async validateJobLease(leaseUnknown: unknown): Promise<IJobLease> {
|
|
557
525
|
if (!isRecord(leaseUnknown)) throw new ProtocolError('Invalid job lease');
|
|
@@ -559,7 +527,6 @@ export class RunnerProtocolValidator {
|
|
|
559
527
|
const job = await this.validateJob(jobUnknown);
|
|
560
528
|
const lease = validateWireMessage<IJobLease>('JobLease', { ...envelope, job });
|
|
561
529
|
requireLeaseCoherence(lease);
|
|
562
|
-
requireLeaseFeatureFit(lease, this.capabilities);
|
|
563
530
|
return lease;
|
|
564
531
|
}
|
|
565
532
|
|
package/ts/runner.ts
CHANGED
|
@@ -213,24 +213,22 @@ class LeaseGuard {
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
/**
|
|
216
|
-
* The capabilities this Firecracker runner advertises:
|
|
217
|
-
* -
|
|
218
|
-
*
|
|
219
|
-
* Both advertise `image-pull-grants`, `candidate-bindings`, and `npm-read-grants`.
|
|
216
|
+
* The capabilities this unified Firecracker microVM runner advertises:
|
|
217
|
+
* - Always advertises `oci` and `vm`; adds `oci-image` whenever `builderRootfsPath` or
|
|
218
|
+
* `builderImage` is configured so one runner handles every profile in disposable microVMs.
|
|
220
219
|
*/
|
|
221
220
|
export const runnerCapabilities = (
|
|
222
221
|
config: IRunnerConfig,
|
|
223
222
|
runtime: Pick<IOciRuntimeFacts, 'os' | 'architecture'>,
|
|
224
223
|
): IRunnerCapabilities => {
|
|
225
|
-
const
|
|
226
|
-
const artifactEnabled =
|
|
224
|
+
const hasBuilder = Boolean(config.oci.builderRootfsPath || config.oci.builderImage);
|
|
225
|
+
const artifactEnabled = config.maximumArtifacts > 0 &&
|
|
227
226
|
config.maximumArtifactBytes > 0 && config.maximumArtifactExtractedBytes > 0 &&
|
|
228
227
|
config.maximumArtifactEntries > 0;
|
|
229
228
|
const cacheEnabled = config.maximumCaches > 0 && config.maximumCacheArchiveBytes > 0 &&
|
|
230
229
|
config.maximumCacheExtractedBytes > 0 && config.maximumCacheEntries > 0;
|
|
231
230
|
return createRunnerCapabilitySnapshot({
|
|
232
|
-
executionProfiles:
|
|
233
|
-
isolation: ['microvm'],
|
|
231
|
+
executionProfiles: hasBuilder ? ['oci', 'vm', 'oci-image'] : ['oci', 'vm'],
|
|
234
232
|
platforms: [`${runtime.os}/${runtime.architecture}`],
|
|
235
233
|
labels: [...config.labels],
|
|
236
234
|
features: [
|
|
@@ -239,7 +237,6 @@ export const runnerCapabilities = (
|
|
|
239
237
|
...(cacheEnabled ? ['caches' as const] : []),
|
|
240
238
|
],
|
|
241
239
|
networks: [...config.oci.allowedNetworks],
|
|
242
|
-
sourceFormats: ['tar.gz'],
|
|
243
240
|
limits: {
|
|
244
241
|
maximumSourceArchiveBytes: config.maximumSourceArchiveBytes,
|
|
245
242
|
maximumSourceExtractedBytes: config.maximumSourceExtractedBytes,
|
|
@@ -263,7 +260,6 @@ export const runnerCapabilities = (
|
|
|
263
260
|
maximumPids: config.oci.maximumPids,
|
|
264
261
|
maximumSharedMemoryBytes: config.oci.maximumSharedMemoryBytes,
|
|
265
262
|
},
|
|
266
|
-
leaseFeatures: ['image-pull-grants', 'candidate-bindings', 'npm-read-grants'],
|
|
267
263
|
maximumTimeoutMs: config.oci.maximumTimeoutMs,
|
|
268
264
|
});
|
|
269
265
|
};
|
|
@@ -381,7 +377,6 @@ export class ShipRunner {
|
|
|
381
377
|
lastResult = await this.runOnce(
|
|
382
378
|
runnerId,
|
|
383
379
|
session.sessionId,
|
|
384
|
-
capabilities,
|
|
385
380
|
validator,
|
|
386
381
|
discovery.limits,
|
|
387
382
|
journal,
|
|
@@ -441,7 +436,6 @@ export class ShipRunner {
|
|
|
441
436
|
private async runOnce(
|
|
442
437
|
runnerId: string,
|
|
443
438
|
sessionId: string,
|
|
444
|
-
capabilities: IRunnerCapabilities,
|
|
445
439
|
validator: RunnerProtocolValidator,
|
|
446
440
|
protocolLimits: IProtocolLimits,
|
|
447
441
|
journal: AttemptStateStore,
|
|
@@ -452,7 +446,6 @@ export class ShipRunner {
|
|
|
452
446
|
claimRequestId: plugins.crypto.randomUUID(),
|
|
453
447
|
runnerId,
|
|
454
448
|
sessionId,
|
|
455
|
-
capabilities,
|
|
456
449
|
}, runnerSignal);
|
|
457
450
|
const claimElapsedMs = Math.max(0, this.now() - claimStartedAt);
|
|
458
451
|
if (claim.lease === null) {
|
package/ts/state-owner.ts
CHANGED
|
@@ -56,6 +56,26 @@ export const hostHelperTarget = (): TOciHelperTarget => {
|
|
|
56
56
|
/** Name of the workspace helper sidecar that the runner's single executables embed. */
|
|
57
57
|
export const workspaceHelperSidecarName = 'runnerworkspace';
|
|
58
58
|
|
|
59
|
+
/** Name of the smartvm-bridge sidecar that the runner's single executables embed. */
|
|
60
|
+
export const smartvmBridgeSidecarName = 'smartvm-bridge';
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Path of the embedded `smartvm-bridge` sidecar when running inside a single executable, or
|
|
64
|
+
* `undefined` when running from Node.js/npm (where `@push.rocks/smartvm` resolves its own
|
|
65
|
+
* packaged binary under `dist_rust/`).
|
|
66
|
+
*/
|
|
67
|
+
export const resolvePackagedSmartVmBridgePath = async (): Promise<string | undefined> => {
|
|
68
|
+
if (!plugins.smartsea.isSea()) return undefined;
|
|
69
|
+
return await plugins.smartsea.getSidecarPath(smartvmBridgeSidecarName).catch((error) => {
|
|
70
|
+
throw new RunnerError(
|
|
71
|
+
`The embedded smartvm-bridge sidecar is unavailable: ${
|
|
72
|
+
error instanceof Error ? error.message : String(error)
|
|
73
|
+
}`,
|
|
74
|
+
{ cause: error },
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
59
79
|
/**
|
|
60
80
|
* Path of the packaged static workspace helper for `target`, a real file the runner reads and
|
|
61
81
|
* copies. Inside a runner single executable it is the embedded helper of the host architecture,
|