@ship.zone/runner 4.0.0 → 5.0.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/changelog.md +18 -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-entry.js +0 -0
- 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 +58 -25
- 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/package.json +11 -10
- package/readme.md +64 -77
- 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 +73 -28
- package/ts/protocol-validator.ts +6 -39
- package/ts/runner.ts +6 -13
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) {
|