@cnc-tools/storm 0.16.0 → 0.17.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/application.d.ts +22 -13
- package/dist/application.js +21 -10
- package/dist/bin/run.d.ts +18 -0
- package/dist/bin/run.js +31 -0
- package/dist/bin/storm.js +42 -26
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-5CCP36QQ.js → chunk-2RNDPDTJ.js} +2 -2
- package/dist/chunks/chunk-2VP4GRJM.js +1219 -0
- package/dist/chunks/{chunk-P357TZAY.js → chunk-4O5C2XGJ.js} +18 -15
- package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-4WAMTUWZ.js} +419 -340
- package/dist/chunks/{chunk-OIY3DMF2.js → chunk-6UHIJXZG.js} +3 -3
- package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
- package/dist/chunks/{chunk-CK2GZEPK.js → chunk-7DZE67QM.js} +2 -2
- package/dist/chunks/{chunk-VUPZH7J2.js → chunk-BCBKYOHW.js} +1 -1
- package/dist/chunks/{chunk-2MAD5NKK.js → chunk-CKGZA25H.js} +1 -18
- package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-D27KILIA.js} +1 -1
- package/dist/chunks/{chunk-V4IKA3WI.js → chunk-DADEYJDW.js} +24 -17
- package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
- package/dist/chunks/chunk-F4MOYHRY.js +198 -0
- package/dist/chunks/{chunk-HVNK3I45.js → chunk-FNBB6V4R.js} +1 -1
- package/dist/chunks/{chunk-G3PHMXH5.js → chunk-GRT3UIBV.js} +18 -1
- package/dist/chunks/chunk-HP3CURSZ.js +88 -0
- package/dist/chunks/{chunk-DWEAHX4T.js → chunk-HWIQ2S7K.js} +5 -5
- package/dist/chunks/chunk-JN3YY6ZH.js +2166 -0
- package/dist/chunks/{chunk-TJNFVNKR.js → chunk-LKTZ5OXS.js} +1 -1
- package/dist/chunks/{chunk-3L52KNQA.js → chunk-M7EKRGVD.js} +8 -8
- package/dist/chunks/chunk-MR77L2GK.js +340 -0
- package/dist/chunks/{chunk-DC2CDHNK.js → chunk-RNAS7JHE.js} +1438 -445
- package/dist/chunks/{chunk-FCQUJDA4.js → chunk-RWIXDDCK.js} +4 -189
- package/dist/chunks/{chunk-5VXBKPW6.js → chunk-WV3DP6NR.js} +1 -1
- package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
- package/dist/chunks/{chunk-FOZWA52V.js → chunk-YEPFSLQR.js} +480 -375
- package/dist/chunks/{live-app-WECQOQ4C.js → live-app-R76JQXZL.js} +15 -13
- package/dist/commands/exec/across-sandboxes-outcomes.d.ts +1 -1
- package/dist/commands/exec/across-sandboxes-outcomes.js +2 -2
- package/dist/commands/exec/before-run.d.ts +123 -0
- package/dist/commands/exec/before-run.js +105 -0
- package/dist/commands/exec/command.d.ts +31 -2
- package/dist/commands/exec/command.js +31 -95
- package/dist/commands/exec/driver-plan.d.ts +9 -4
- package/dist/commands/exec/driver-plan.js +8 -8
- package/dist/commands/exec/exec-words.js +1 -1
- package/dist/commands/exec/execute-run.d.ts +39 -0
- package/dist/commands/exec/execute-run.js +325 -0
- package/dist/commands/exec/live-view.d.ts +3 -3
- package/dist/commands/exec/live-view.js +16 -15
- package/dist/commands/exec/metadata.js +1 -1
- package/dist/commands/exec/mint-failed.d.ts +38 -0
- package/dist/commands/exec/mint-failed.js +27 -4
- package/dist/commands/exec/outcomes.d.ts +34 -8
- package/dist/commands/exec/outcomes.js +30 -23
- package/dist/commands/exec/plan-run.d.ts +58 -150
- package/dist/commands/exec/plan-run.js +232 -88
- package/dist/commands/exec/progress.d.ts +10 -6
- package/dist/commands/exec/progress.js +38 -25
- package/dist/commands/exec/run-bin.d.ts +11 -11
- package/dist/commands/exec/run-bin.js +9 -9
- package/dist/commands/exec/run-flags.d.ts +69 -0
- package/dist/commands/exec/run-flags.js +58 -0
- package/dist/commands/exec/run-metadata.js +4 -4
- package/dist/commands/exec/run-summary.d.ts +58 -0
- package/dist/commands/exec/run-summary.js +205 -0
- package/dist/commands/exec/runner-refusals.d.ts +82 -0
- package/dist/commands/exec/runner-refusals.js +71 -0
- package/dist/commands/exec/sandbox-progress.js +3 -0
- package/dist/commands/exec/stopped-outcome.d.ts +12 -0
- package/dist/commands/exec/stopped-outcome.js +77 -0
- package/dist/commands/exec/view.d.ts +20 -11
- package/dist/commands/exec/view.js +103 -47
- package/dist/commands/runs/facts.d.ts +7 -3
- package/dist/commands/runs/facts.js +17 -8
- package/dist/commands/runs/list/command.d.ts +14 -6
- package/dist/commands/runs/list/command.js +10 -10
- package/dist/commands/runs/list/outcomes.d.ts +7 -3
- package/dist/commands/runs/logs/command.js +10 -10
- package/dist/commands/runs/show/command.d.ts +14 -6
- package/dist/commands/runs/show/command.js +30 -28
- package/dist/commands/runs/show/outcomes.d.ts +7 -3
- package/dist/commands/runs/show/outcomes.js +7 -5
- package/dist/commands/snapshots/access.d.ts +111 -0
- package/dist/commands/snapshots/access.js +96 -0
- package/dist/commands/snapshots/build/command.d.ts +360 -93
- package/dist/commands/snapshots/build/command.js +446 -150
- package/dist/commands/snapshots/build/metadata.d.ts +10 -0
- package/dist/commands/snapshots/build/metadata.js +31 -11
- package/dist/commands/snapshots/build/outcomes.d.ts +234 -43
- package/dist/commands/snapshots/build/outcomes.js +200 -36
- package/dist/commands/snapshots/list/command.d.ts +366 -25
- package/dist/commands/snapshots/list/command.js +296 -66
- package/dist/commands/snapshots/list/metadata.d.ts +16 -0
- package/dist/commands/snapshots/list/metadata.js +29 -6
- package/dist/commands/snapshots/list/outcomes.d.ts +245 -13
- package/dist/commands/snapshots/list/outcomes.js +221 -50
- package/dist/commands/snapshots/metadata.js +1 -1
- package/dist/commands/snapshots/prune/command.d.ts +430 -0
- package/dist/commands/snapshots/prune/command.js +161 -0
- package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
- package/dist/commands/snapshots/prune/metadata.js +39 -0
- package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
- package/dist/commands/snapshots/prune/outcomes.js +78 -0
- package/dist/commands/suites/list/command.js +17 -17
- package/dist/commands/suites/list/outcomes.js +2 -2
- package/dist/commands/test/command.d.ts +31 -2
- package/dist/commands/test/command.js +49 -252
- package/dist/commands/test/outcomes.d.ts +15 -1
- package/dist/config/check-runner.d.ts +3 -3
- package/dist/config/check-runner.js +8 -7
- package/dist/config/credential-resolver.d.ts +50 -5
- package/dist/config/credential-resolver.js +51 -19
- package/dist/config/credential-settle.d.ts +6 -2
- package/dist/config/credential-settle.js +11 -5
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +1 -1
- package/dist/config/runner.d.ts +5 -5
- package/dist/config/runner.js +1 -1
- package/dist/config/schema.d.ts +2 -2
- package/dist/config/schema.js +1 -1
- package/dist/config-file/define.d.ts +1 -1
- package/dist/config-file/define.js +1 -1
- package/dist/config-file/runner.d.ts +5 -5
- package/dist/config-file/toolchain.d.ts +1 -1
- package/dist/config-file/toolchain.js +2 -2
- package/dist/context.d.ts +8 -6
- package/dist/context.js +7 -6
- package/dist/core/across-sandboxes.d.ts +7 -6
- package/dist/core/across-sandboxes.js +123 -152
- package/dist/core/coordinator.d.ts +166 -0
- package/dist/core/coordinator.js +233 -0
- package/dist/core/events.d.ts +2 -2
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.js +1 -1
- package/dist/core/outcomes.d.ts +148 -0
- package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
- package/dist/core/resources.d.ts +31 -53
- package/dist/core/resources.js +32 -70
- package/dist/core/run-state.d.ts +7 -1
- package/dist/core/run-state.js +2 -0
- package/dist/core/run.d.ts +32 -236
- package/dist/core/run.js +106 -266
- package/dist/core/state-directory.d.ts +1 -1
- package/dist/core/state-directory.js +2 -2
- package/dist/credential/gateways.d.ts +15 -1
- package/dist/credential/index.d.ts +4 -3
- package/dist/credential/index.js +3 -2
- package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
- package/dist/credential/live/vercel-cli-gateway.js +1 -1
- package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
- package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
- package/dist/credential/source.d.ts +73 -6
- package/dist/credential/source.js +55 -2
- package/dist/extension-commands.d.ts +6 -1
- package/dist/extension-commands.js +15 -1
- package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
- package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
- package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
- package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
- package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
- package/dist/extensions/testserver/credential-facts.d.ts +6 -2
- package/dist/extensions/testserver/credential-facts.js +29 -11
- package/dist/extensions/testserver/lifecycle.js +7 -1
- package/dist/extensions/testserver/limit.d.ts +3 -0
- package/dist/extensions/testserver/limit.js +3 -0
- package/dist/extensions/testserver/provision.d.ts +8 -1
- package/dist/extensions/testserver/provision.js +8 -3
- package/dist/extensions/testserver/refusals.d.ts +6 -1
- package/dist/extensions/testserver/refusals.js +16 -1
- package/dist/extensions/testserver/resource.d.ts +1 -1
- package/dist/extensions/testserver/resource.js +1 -1
- package/dist/extensions/testserver/result.d.ts +1 -1
- package/dist/extensions/testserver/result.js +9 -4
- package/dist/planning/driver-file-lists.d.ts +0 -15
- package/dist/planning/driver-file-lists.js +2 -21
- package/dist/planning/plan-only.d.ts +3 -14
- package/dist/planning/plan-only.js +11 -20
- package/dist/planning/run-kind-flags.js +2 -2
- package/dist/planning/run-plan.d.ts +45 -12
- package/dist/planning/run-plan.js +4 -3
- package/dist/planning/suites.d.ts +1 -1
- package/dist/planning/suites.js +2 -2
- package/dist/planning/test-plan.d.ts +9 -0
- package/dist/planning/test-plan.js +9 -0
- package/dist/run-directory/recording.js +2 -2
- package/dist/run-directory/run-record.d.ts +21 -6
- package/dist/run-directory/run-record.js +12 -9
- package/dist/runner/base.js +1 -1
- package/dist/runner/build-snapshots.d.ts +55 -29
- package/dist/runner/build-snapshots.js +130 -29
- package/dist/runner/context.d.ts +15 -7
- package/dist/runner/context.js +19 -6
- package/dist/runner/events.d.ts +16 -10
- package/dist/runner/gateways.d.ts +87 -21
- package/dist/runner/gateways.js +1 -1
- package/dist/runner/index.d.ts +11 -7
- package/dist/runner/index.js +9 -4
- package/dist/runner/live/sandbox-errors.d.ts +2 -0
- package/dist/runner/live/sandbox-errors.js +4 -0
- package/dist/runner/live/sandbox-gateway.js +129 -3
- package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
- package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
- package/dist/runner/live/snapshot-records.js +6 -7
- package/dist/runner/local-snapshot-index.d.ts +199 -0
- package/dist/runner/local-snapshot-index.js +211 -0
- package/dist/runner/network-policy.d.ts +6 -6
- package/dist/runner/network-policy.js +7 -7
- package/dist/runner/policy-writes.d.ts +1 -1
- package/dist/runner/policy-writes.js +1 -1
- package/dist/runner/prepare.d.ts +14 -14
- package/dist/runner/prepare.js +20 -11
- package/dist/runner/ready.d.ts +18 -10
- package/dist/runner/ready.js +104 -33
- package/dist/runner/sandboxed-command.d.ts +3 -3
- package/dist/runner/sandboxed-command.js +3 -3
- package/dist/runner/scope.d.ts +10 -6
- package/dist/runner/scope.js +10 -3
- package/dist/runner/secrets.d.ts +13 -13
- package/dist/runner/secrets.js +18 -15
- package/dist/runner/session.d.ts +8 -8
- package/dist/runner/session.js +3 -3
- package/dist/runner/shared-snapshot-entry.d.ts +92 -0
- package/dist/runner/shared-snapshot-entry.js +168 -0
- package/dist/runner/shared-snapshot-list.d.ts +81 -0
- package/dist/runner/shared-snapshot-list.js +155 -0
- package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
- package/dist/runner/shared-snapshot-lookup.js +118 -0
- package/dist/runner/shared-snapshot-prune.d.ts +58 -0
- package/dist/runner/shared-snapshot-prune.js +133 -0
- package/dist/runner/snapshot-build.d.ts +42 -14
- package/dist/runner/snapshot-build.js +32 -29
- package/dist/runner/snapshot-choice.js +1 -1
- package/dist/runner/snapshot-inspect.d.ts +39 -40
- package/dist/runner/snapshot-inspect.js +55 -35
- package/dist/runner/snapshot-key.d.ts +13 -12
- package/dist/runner/snapshot-key.js +13 -12
- package/dist/runner/steps.d.ts +1 -1
- package/dist/runner/steps.js +1 -1
- package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +2 -2
- package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +3 -2
- package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +24 -23
- package/dist/runner/{recipe.js → vercel-sandbox-options.js} +70 -69
- package/dist/runner/{recipe-secrets.d.ts → vercel-sandbox-secrets.d.ts} +6 -6
- package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +20 -20
- package/dist/sdk/extension/commands.d.ts +8 -3
- package/dist/sdk/extension/commands.js +3 -1
- package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
- package/dist/sdk/extension/credential-diagnosis.js +25 -5
- package/dist/sdk/extension/credential-source.d.ts +20 -3
- package/dist/sdk/extension/credential-source.js +4 -4
- package/dist/sdk/extension/index.d.ts +3 -2
- package/dist/sdk/extension/index.js +2 -1
- package/dist/sdk/extension/resource-definition.d.ts +1 -1
- package/dist/sdk/extension/secret-source.d.ts +1 -1
- package/dist/sdk/extension/secret-source.js +1 -1
- package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
- package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
- package/dist/shared/cleanup.d.ts +3 -3
- package/dist/shared/cleanup.js +15 -5
- package/dist/shared/snapshot-text.d.ts +4 -4
- package/dist/shared/snapshot-text.js +11 -11
- package/dist/time/duration.js +1 -1
- package/package.json +3 -2
- package/skills/overview.md +4 -4
- package/skills/plan-runs.md +1 -1
- package/skills/read-run-output.md +6 -6
- package/dist/chunks/chunk-7EENF73W.js +0 -782
- package/dist/chunks/chunk-Z5PBVG3Y.js +0 -2599
- package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
- package/dist/commands/exec/across-sandboxes-run.js +0 -339
- package/dist/commands/exec/plan-only.d.ts +0 -10
- package/dist/commands/exec/plan-only.js +0 -45
- package/dist/commands/exec/run-command.d.ts +0 -475
- package/dist/commands/exec/run-command.js +0 -603
- package/dist/commands/exec/run-planned.d.ts +0 -20
- package/dist/commands/exec/run-planned.js +0 -22
- package/dist/commands/exec/sandbox-view.d.ts +0 -19
- package/dist/commands/exec/sandbox-view.js +0 -72
- package/dist/commands/test/plan.d.ts +0 -92
- package/dist/commands/test/plan.js +0 -125
- package/dist/core/sandbox-end.d.ts +0 -64
- package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
- package/dist/runner/snapshot-cache.d.ts +0 -148
- package/dist/runner/snapshot-cache.js +0 -126
|
@@ -7,11 +7,13 @@ import {
|
|
|
7
7
|
openRunnerSession,
|
|
8
8
|
parseTestEvent,
|
|
9
9
|
systemClock,
|
|
10
|
-
systemTimer
|
|
11
|
-
|
|
10
|
+
systemTimer,
|
|
11
|
+
vercelProjectSource
|
|
12
|
+
} from "./chunk-RNAS7JHE.js";
|
|
12
13
|
import {
|
|
13
|
-
describeMintFailure
|
|
14
|
-
|
|
14
|
+
describeMintFailure,
|
|
15
|
+
describeVercelOidcTokenFailure
|
|
16
|
+
} from "./chunk-XBDRVFEV.js";
|
|
15
17
|
|
|
16
18
|
// src/core/reports.ts
|
|
17
19
|
var WARNINGS_HEADING = "Warnings";
|
|
@@ -455,7 +457,8 @@ function applyRunnerEvent(state, event, at) {
|
|
|
455
457
|
kind: "reused",
|
|
456
458
|
id: event.snapshotId,
|
|
457
459
|
base: event.base,
|
|
458
|
-
builtBehind: event.builtBehind
|
|
460
|
+
builtBehind: event.builtBehind,
|
|
461
|
+
source: event.source
|
|
459
462
|
}
|
|
460
463
|
})
|
|
461
464
|
);
|
|
@@ -519,6 +522,7 @@ function applyRunnerEvent(state, event, at) {
|
|
|
519
522
|
case "output-started":
|
|
520
523
|
case "output-ended":
|
|
521
524
|
case "snapshot-entry-not-written":
|
|
525
|
+
case "shared-snapshot-lookup-failed":
|
|
522
526
|
case "command-output-started":
|
|
523
527
|
return state;
|
|
524
528
|
}
|
|
@@ -993,36 +997,149 @@ var livePackageBinGateway = {
|
|
|
993
997
|
}
|
|
994
998
|
};
|
|
995
999
|
|
|
996
|
-
// src/core/
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
// src/core/payload.ts
|
|
1000
|
-
function runPayload(resources, options = {}) {
|
|
1001
|
-
return {
|
|
1002
|
-
version: 3,
|
|
1003
|
-
resources,
|
|
1004
|
-
...options.testEvents === void 0 ? {} : { testEvents: options.testEvents },
|
|
1005
|
-
...options.verbose === true ? { verbose: true } : {},
|
|
1006
|
-
...options.sandbox === void 0 ? {} : { sandbox: options.sandbox }
|
|
1007
|
-
};
|
|
1000
|
+
// src/core/outcomes.ts
|
|
1001
|
+
function canceledStop() {
|
|
1002
|
+
return { kind: "canceled" };
|
|
1008
1003
|
}
|
|
1009
|
-
function
|
|
1010
|
-
|
|
1011
|
-
return
|
|
1004
|
+
function runnerLaneOutcome(outcome) {
|
|
1005
|
+
if (outcome.kind === "ready") return "ready";
|
|
1006
|
+
return outcome.kind === "aborted" ? "stopped" : "failed";
|
|
1012
1007
|
}
|
|
1013
|
-
function
|
|
1014
|
-
if (
|
|
1015
|
-
if (
|
|
1016
|
-
|
|
1017
|
-
return
|
|
1008
|
+
function runnerStopped(outcome) {
|
|
1009
|
+
if (outcome.kind === "failed") return { kind: "runner_failed", failure: outcome.failure };
|
|
1010
|
+
if (outcome.kind === "snapshot-gone")
|
|
1011
|
+
return { kind: "snapshot_gone", entry: outcome.entry, removal: outcome.removal };
|
|
1012
|
+
return void 0;
|
|
1013
|
+
}
|
|
1014
|
+
function acrossSandboxesExitStatus(sandboxes) {
|
|
1015
|
+
return sandboxes.every(({ state }) => state === "passed") ? 0 : 1;
|
|
1016
|
+
}
|
|
1017
|
+
function sandboxEndFacts(end, commandStarted) {
|
|
1018
|
+
const short = (cause, failedStage, started = commandStarted) => ({
|
|
1019
|
+
state: started ? "failed" : "not-started",
|
|
1020
|
+
failedStage,
|
|
1021
|
+
exitCode: null,
|
|
1022
|
+
cause: oneLine(cause)
|
|
1023
|
+
});
|
|
1024
|
+
switch (end.kind) {
|
|
1025
|
+
case "ran": {
|
|
1026
|
+
const { command } = end;
|
|
1027
|
+
if (command.kind === "exited")
|
|
1028
|
+
return {
|
|
1029
|
+
state: command.code === 0 ? "passed" : "failed",
|
|
1030
|
+
failedStage: command.code === 0 ? null : "command",
|
|
1031
|
+
exitCode: command.code,
|
|
1032
|
+
cause: null
|
|
1033
|
+
};
|
|
1034
|
+
return {
|
|
1035
|
+
state: "failed",
|
|
1036
|
+
failedStage: "command",
|
|
1037
|
+
exitCode: null,
|
|
1038
|
+
cause: command.kind === "signaled" ? `signaled: ${command.signal}` : "no-exit-code"
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
case "canceled":
|
|
1042
|
+
return { state: "canceled", failedStage: null, exitCode: null, cause: "canceled" };
|
|
1043
|
+
case "runner_failed": {
|
|
1044
|
+
const { failure } = end;
|
|
1045
|
+
const ranCommand = failure.kind === "sandbox-api-failed" && failure.operation === "run-command";
|
|
1046
|
+
return short(runnerFailureCause(failure), runnerFailureStage(failure), commandStarted || ranCommand);
|
|
1047
|
+
}
|
|
1048
|
+
case "mint_failed":
|
|
1049
|
+
return short(`mint-failed: ${describeMintFailure(end.failure, end.target).cause}`, "mint");
|
|
1050
|
+
case "vercel_oidc_token_failed":
|
|
1051
|
+
return short(`vercel-oidc-token-failed: ${describeVercelOidcTokenFailure(end.failure).cause}`, "mint");
|
|
1052
|
+
case "snapshot_gone":
|
|
1053
|
+
return short("snapshot-gone", "snapshot");
|
|
1054
|
+
case "spawn_failed":
|
|
1055
|
+
return short(`spawn-failed: ${end.message}`, "command");
|
|
1056
|
+
case "resource_refused":
|
|
1057
|
+
return short(`resource-refused: ${end.resource}: ${end.refusal.message}`, "resource");
|
|
1058
|
+
case "threw":
|
|
1059
|
+
return short(`threw: ${end.message}`, "storm");
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
function runnerFailureStage(failure) {
|
|
1063
|
+
switch (failure.kind) {
|
|
1064
|
+
case "snapshot-build-step-failed":
|
|
1065
|
+
return "snapshot";
|
|
1066
|
+
case "apply-failed":
|
|
1067
|
+
return "apply";
|
|
1068
|
+
case "install-failed":
|
|
1069
|
+
return "install";
|
|
1070
|
+
case "build-failed":
|
|
1071
|
+
return "build";
|
|
1072
|
+
case "checkout-failed":
|
|
1073
|
+
return "checkout";
|
|
1074
|
+
case "credential-claims-missing":
|
|
1075
|
+
return "mint";
|
|
1076
|
+
case "sandbox-api-failed":
|
|
1077
|
+
switch (failure.operation) {
|
|
1078
|
+
case "start-build-sandbox":
|
|
1079
|
+
case "save-snapshot":
|
|
1080
|
+
case "get-named-sandbox":
|
|
1081
|
+
case "get-snapshot":
|
|
1082
|
+
case "delete-named-sandbox":
|
|
1083
|
+
return "snapshot";
|
|
1084
|
+
case "start-runner-sandbox":
|
|
1085
|
+
case "login-path":
|
|
1086
|
+
case "run-script":
|
|
1087
|
+
return "start";
|
|
1088
|
+
case "upload":
|
|
1089
|
+
return "upload";
|
|
1090
|
+
case "run-command":
|
|
1091
|
+
return "command";
|
|
1092
|
+
}
|
|
1093
|
+
// A policy write fails at the stage it guards: a snapshot build's steps or save, the install and build steps, or
|
|
1094
|
+
// the command.
|
|
1095
|
+
case "network-policy-failed":
|
|
1096
|
+
switch (failure.around) {
|
|
1097
|
+
case "snapshot-steps":
|
|
1098
|
+
case "snapshot-save":
|
|
1099
|
+
return "snapshot";
|
|
1100
|
+
case "run-steps":
|
|
1101
|
+
return "install";
|
|
1102
|
+
case "command":
|
|
1103
|
+
return "command";
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
function runnerFailureCause(failure) {
|
|
1108
|
+
switch (failure.kind) {
|
|
1109
|
+
case "sandbox-api-failed":
|
|
1110
|
+
return `${failure.operation}: ${failure.message}`;
|
|
1111
|
+
case "checkout-failed":
|
|
1112
|
+
return `checkout-failed: ${failure.failure.message}`;
|
|
1113
|
+
case "credential-claims-missing":
|
|
1114
|
+
return `credential-claims-missing: ${failure.target.team}/${failure.target.project}`;
|
|
1115
|
+
case "snapshot-build-step-failed":
|
|
1116
|
+
case "apply-failed":
|
|
1117
|
+
case "install-failed":
|
|
1118
|
+
case "build-failed":
|
|
1119
|
+
return `${failure.kind}: ${failure.exitCode === null ? "no exit code" : `exited ${failure.exitCode}`}`;
|
|
1120
|
+
case "network-policy-failed":
|
|
1121
|
+
return `network-policy-failed: ${failure.operation} around ${failure.around}: ${failure.status === null ? "" : `HTTP ${failure.status}: `}${failure.message}`;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
function oneLine(text) {
|
|
1125
|
+
return text.trim().replace(/\s*\n\s*/g, " ");
|
|
1018
1126
|
}
|
|
1019
1127
|
|
|
1128
|
+
// src/core/run.ts
|
|
1129
|
+
import { posix as posix2 } from "node:path";
|
|
1130
|
+
|
|
1131
|
+
// src/core/coordinator.ts
|
|
1132
|
+
import { posix } from "node:path";
|
|
1133
|
+
|
|
1020
1134
|
// src/core/resources.ts
|
|
1021
1135
|
function resourceInstances({ named }, resourceContexts2, requests) {
|
|
1022
1136
|
return Object.entries(requests).map(
|
|
1023
1137
|
([key, request]) => instanceOf(named(request.definition, key), key, resourceContexts2, request)
|
|
1024
1138
|
);
|
|
1025
1139
|
}
|
|
1140
|
+
async function startResourceLanes(instances, progress) {
|
|
1141
|
+
for (const instance of instances) await instance.startLane(progress);
|
|
1142
|
+
}
|
|
1026
1143
|
function instanceOf(resource, key, resourceContexts2, request) {
|
|
1027
1144
|
const { name } = resource;
|
|
1028
1145
|
const lifecycle = resource.lifecycle(resourceContexts2[name]);
|
|
@@ -1123,9 +1240,9 @@ function instanceOf(resource, key, resourceContexts2, request) {
|
|
|
1123
1240
|
};
|
|
1124
1241
|
}
|
|
1125
1242
|
async function acquireResources(instances, input) {
|
|
1126
|
-
const { progress,
|
|
1243
|
+
const { progress, cancelSignal, stopSignal } = input;
|
|
1127
1244
|
const internal = new AbortController();
|
|
1128
|
-
const signal = AbortSignal.any([
|
|
1245
|
+
const signal = stopSignal === void 0 ? AbortSignal.any([cancelSignal, internal.signal]) : AbortSignal.any([cancelSignal, stopSignal, internal.signal]);
|
|
1129
1246
|
const finishLane = async (lane, task, outcomeOf2) => {
|
|
1130
1247
|
let value;
|
|
1131
1248
|
let outcome;
|
|
@@ -1142,36 +1259,25 @@ async function acquireResources(instances, input) {
|
|
|
1142
1259
|
if (outcome !== "ready") internal.abort();
|
|
1143
1260
|
return value;
|
|
1144
1261
|
};
|
|
1145
|
-
for (const instance of instances) await instance.startLane(progress);
|
|
1146
1262
|
const instanceTasks = instances.map(
|
|
1147
1263
|
(instance) => instance.acquire({ signal, credential: input.credential, progress, finishLane })
|
|
1148
1264
|
);
|
|
1149
|
-
const
|
|
1150
|
-
const [[besideEnded], instancesEnded] = await Promise.all([
|
|
1151
|
-
Promise.allSettled([besideTask]),
|
|
1152
|
-
Promise.allSettled(instanceTasks)
|
|
1153
|
-
]);
|
|
1154
|
-
if (besideEnded.status === "rejected") throw besideEnded.reason;
|
|
1265
|
+
const instancesEnded = await Promise.allSettled(instanceTasks);
|
|
1155
1266
|
const outcomes = [];
|
|
1156
1267
|
for (const one of instancesEnded) {
|
|
1157
1268
|
if (one.status === "rejected") throw one.reason;
|
|
1158
1269
|
outcomes.push(one.value);
|
|
1159
1270
|
}
|
|
1160
|
-
if (
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1163
|
-
if (
|
|
1164
|
-
|
|
1165
|
-
if (outcomes.some((outcome) => outcome?.kind === "canceled")) return { kind: "stopped", outcome: canceledStop() };
|
|
1166
|
-
return { kind: "acquired", beside: besideValue };
|
|
1271
|
+
if (cancelSignal.aborted) return { kind: "canceled" };
|
|
1272
|
+
for (const outcome of outcomes) if (outcome.kind === "refused") return { kind: "stopped", outcome: outcome.outcome };
|
|
1273
|
+
if (stopSignal?.aborted) return { kind: "internal-stopped" };
|
|
1274
|
+
if (outcomes.some((outcome) => outcome.kind === "canceled")) return { kind: "canceled" };
|
|
1275
|
+
return { kind: "acquired" };
|
|
1167
1276
|
}
|
|
1168
1277
|
function resourceLaneOutcome(result) {
|
|
1169
1278
|
if ("acquired" in result) return "ready";
|
|
1170
1279
|
return "canceled" in result ? "stopped" : "failed";
|
|
1171
1280
|
}
|
|
1172
|
-
function canceledStop() {
|
|
1173
|
-
return { kind: "canceled" };
|
|
1174
|
-
}
|
|
1175
1281
|
async function announceAcquired(instances, progress) {
|
|
1176
1282
|
for (const instance of instances) for (const event of instance.acquired()) await progress.emit(event);
|
|
1177
1283
|
}
|
|
@@ -1252,7 +1358,7 @@ function resourceWarnings(cleanup) {
|
|
|
1252
1358
|
return Object.values(cleanup).reduce((sum, { warnings }) => sum + warnings.length, 0);
|
|
1253
1359
|
}
|
|
1254
1360
|
|
|
1255
|
-
// src/core/
|
|
1361
|
+
// src/core/coordinator.ts
|
|
1256
1362
|
async function emitRunOpening(progress, request, instances) {
|
|
1257
1363
|
await progress.emit({
|
|
1258
1364
|
kind: "started",
|
|
@@ -1273,28 +1379,76 @@ async function emitRunOpening(progress, request, instances) {
|
|
|
1273
1379
|
});
|
|
1274
1380
|
}
|
|
1275
1381
|
}
|
|
1276
|
-
async function
|
|
1382
|
+
async function obtainRunnerCredential(context, choice, signal, progress) {
|
|
1277
1383
|
const canceled = () => ({ ...canceledStop(), commandStopped: false });
|
|
1278
1384
|
if (signal.aborted) return { ok: false, outcome: canceled() };
|
|
1279
|
-
const
|
|
1280
|
-
const
|
|
1281
|
-
if (!
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1385
|
+
const { source, obtain } = vercelProjectSource(choice, context, progress);
|
|
1386
|
+
const obtained = await obtain();
|
|
1387
|
+
if (!obtained.ok) {
|
|
1388
|
+
const { failure } = obtained;
|
|
1389
|
+
switch (failure.source) {
|
|
1390
|
+
case "mint":
|
|
1391
|
+
return {
|
|
1392
|
+
ok: false,
|
|
1393
|
+
outcome: { kind: "mint_failed", failure: failure.failure, target: failure.target, runner: true }
|
|
1394
|
+
};
|
|
1395
|
+
case "vercel-oidc":
|
|
1396
|
+
return { ok: false, outcome: { kind: "vercel_oidc_token_failed", failure: failure.failure, runner: true } };
|
|
1397
|
+
case "claims-missing":
|
|
1398
|
+
return {
|
|
1399
|
+
ok: false,
|
|
1400
|
+
outcome: { kind: "runner_failed", failure: { kind: "credential-claims-missing", target: failure.target } }
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1289
1404
|
if (signal.aborted) return { ok: false, outcome: canceled() };
|
|
1290
|
-
return { ok: true, mint, access: { credential:
|
|
1405
|
+
return { ok: true, mint: source, access: { credential: obtained.credential, ...obtained.project } };
|
|
1406
|
+
}
|
|
1407
|
+
async function emitLanesStarted(instances, progress) {
|
|
1408
|
+
await progress.emit({ kind: "lanes-started" });
|
|
1409
|
+
await startResourceLanes(instances, progress);
|
|
1410
|
+
}
|
|
1411
|
+
async function coordinateSetup(input) {
|
|
1412
|
+
const stop = new AbortController();
|
|
1413
|
+
const stopResources = () => stop.abort();
|
|
1414
|
+
const settledResources = input.runResources(stop.signal).then(
|
|
1415
|
+
(outcome) => {
|
|
1416
|
+
if (outcome.kind !== "ready" && outcome.kind !== "internal-stopped") stop.abort();
|
|
1417
|
+
return outcome;
|
|
1418
|
+
},
|
|
1419
|
+
(error) => {
|
|
1420
|
+
stop.abort();
|
|
1421
|
+
return { kind: "threw", error };
|
|
1422
|
+
}
|
|
1423
|
+
);
|
|
1424
|
+
const settledRunner = input.runRunner(stop.signal, settledResources, stopResources).then(
|
|
1425
|
+
(outcome) => {
|
|
1426
|
+
if (outcome.kind !== "ready" && outcome.kind !== "internal-stopped") stop.abort();
|
|
1427
|
+
return outcome;
|
|
1428
|
+
},
|
|
1429
|
+
(error) => {
|
|
1430
|
+
stop.abort();
|
|
1431
|
+
return { kind: "threw", error };
|
|
1432
|
+
}
|
|
1433
|
+
);
|
|
1434
|
+
const [runner, resources] = await Promise.all([settledRunner, settledResources]);
|
|
1435
|
+
if (runner.kind === "threw") return { kind: "threw", error: runner.error, lane: "runner" };
|
|
1436
|
+
if (resources.kind === "threw") return { kind: "threw", error: resources.error, lane: "resources" };
|
|
1437
|
+
if (input.cancelSignal.aborted) return { kind: "stopped", outcome: canceledStop() };
|
|
1438
|
+
if (runner.kind === "stopped") return { kind: "stopped", outcome: runner.outcome };
|
|
1439
|
+
if (resources.kind === "stopped") return { kind: "stopped", outcome: resources.outcome };
|
|
1440
|
+
if (runner.kind === "ready" && resources.kind === "ready")
|
|
1441
|
+
return { kind: "ready", runner: runner.value, resources: resources.value };
|
|
1442
|
+
if (runner.kind === "ready" && resources.kind === "internal-stopped")
|
|
1443
|
+
return { kind: "ready", runner: runner.value, resources: void 0 };
|
|
1444
|
+
return { kind: "stopped", outcome: canceledStop() };
|
|
1291
1445
|
}
|
|
1292
1446
|
async function runCommandInSandbox(session, request, signal, progress, onStarted) {
|
|
1293
1447
|
await progress.emit({ kind: "command-started", argv: request.argv });
|
|
1294
1448
|
if (signal.aborted) return { ok: false, outcome: { ...canceledStop(), commandStopped: false } };
|
|
1295
1449
|
onStarted?.();
|
|
1296
1450
|
let testEvents = Promise.resolve();
|
|
1297
|
-
const
|
|
1451
|
+
const ended = await session.runCommand({
|
|
1298
1452
|
argv: request.argv,
|
|
1299
1453
|
runPayload: request.runPayload,
|
|
1300
1454
|
...request.credentials === void 0 ? {} : { credentials: request.credentials },
|
|
@@ -1311,15 +1465,15 @@ async function runCommandInSandbox(session, request, signal, progress, onStarted
|
|
|
1311
1465
|
}
|
|
1312
1466
|
});
|
|
1313
1467
|
await testEvents;
|
|
1314
|
-
if (
|
|
1468
|
+
if (ended.kind === "killed" || ended.kind === "failed" && signal.aborted)
|
|
1315
1469
|
return { ok: false, outcome: { ...canceledStop(), commandStopped: true } };
|
|
1316
|
-
if (
|
|
1317
|
-
const command =
|
|
1470
|
+
if (ended.kind === "failed") return { ok: false, outcome: { kind: "runner_failed", failure: ended.failure } };
|
|
1471
|
+
const command = ended.exitCode === null ? { kind: "no-exit-code" } : { kind: "exited", code: ended.exitCode };
|
|
1318
1472
|
await progress.emit({
|
|
1319
1473
|
kind: "command-ended",
|
|
1320
1474
|
command: posix.basename(request.argv[0] ?? ""),
|
|
1321
1475
|
outcome: command,
|
|
1322
|
-
ms:
|
|
1476
|
+
ms: ended.ms
|
|
1323
1477
|
});
|
|
1324
1478
|
return { ok: true, command };
|
|
1325
1479
|
}
|
|
@@ -1347,19 +1501,100 @@ async function withResourceCleanup(instances, keepMs, progress, body) {
|
|
|
1347
1501
|
}
|
|
1348
1502
|
return { value, resourceCleanup };
|
|
1349
1503
|
}
|
|
1504
|
+
function sandboxFenceTracker() {
|
|
1505
|
+
const sessions = [];
|
|
1506
|
+
return {
|
|
1507
|
+
sessionCleanup(onStart) {
|
|
1508
|
+
const entry = { fenced: false };
|
|
1509
|
+
sessions.push(entry);
|
|
1510
|
+
let cleanupStarted = false;
|
|
1511
|
+
return {
|
|
1512
|
+
startCleanup: async () => {
|
|
1513
|
+
if (cleanupStarted) return;
|
|
1514
|
+
cleanupStarted = true;
|
|
1515
|
+
await onStart();
|
|
1516
|
+
},
|
|
1517
|
+
release: async (fence) => {
|
|
1518
|
+
entry.fenced = fence.runnerSandboxFenced;
|
|
1519
|
+
}
|
|
1520
|
+
};
|
|
1521
|
+
},
|
|
1522
|
+
allFenced: () => sessions.every(({ fenced }) => fenced)
|
|
1523
|
+
};
|
|
1524
|
+
}
|
|
1525
|
+
function mergedRunnerCleanup(target, cleanups) {
|
|
1526
|
+
return {
|
|
1527
|
+
kept: null,
|
|
1528
|
+
notKept: null,
|
|
1529
|
+
notStopped: cleanups.flatMap(({ notStopped }) => notStopped),
|
|
1530
|
+
notDeleted: cleanups.flatMap(({ notDeleted }) => notDeleted),
|
|
1531
|
+
target
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
// src/core/payload.ts
|
|
1536
|
+
function runPayload(resources, options = {}) {
|
|
1537
|
+
return {
|
|
1538
|
+
version: 3,
|
|
1539
|
+
resources,
|
|
1540
|
+
...options.testEvents === void 0 ? {} : { testEvents: options.testEvents },
|
|
1541
|
+
...options.verbose === true ? { verbose: true } : {},
|
|
1542
|
+
...options.sandbox === void 0 ? {} : { sandbox: options.sandbox }
|
|
1543
|
+
};
|
|
1544
|
+
}
|
|
1545
|
+
function commandEnvironment(env, payload) {
|
|
1546
|
+
const kept = Object.entries(env).filter((pair) => pair[1] !== void 0);
|
|
1547
|
+
return { ...Object.fromEntries(kept), [RUN_PAYLOAD_VARIABLE]: JSON.stringify(payload) };
|
|
1548
|
+
}
|
|
1549
|
+
function colorEnvironment(env, color) {
|
|
1550
|
+
if (env["FORCE_COLOR"] !== void 0 || env["NO_COLOR"] !== void 0) return env;
|
|
1551
|
+
if (color === "on") return { ...env, FORCE_COLOR: "1" };
|
|
1552
|
+
if (color === "off") return { ...env, NO_COLOR: "1" };
|
|
1553
|
+
return env;
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
// src/core/run.ts
|
|
1350
1557
|
async function executeRun(definitionSet, context, resourceContexts2, request, control, progress) {
|
|
1351
1558
|
const instances = resourceInstances(definitionSet[LOOKUP], resourceContexts2, request.resources);
|
|
1352
|
-
await emitRunOpening(
|
|
1353
|
-
|
|
1559
|
+
await emitRunOpening(
|
|
1560
|
+
progress,
|
|
1561
|
+
{
|
|
1562
|
+
version: request.version,
|
|
1563
|
+
commit: request.commit,
|
|
1564
|
+
configFile: request.configFile,
|
|
1565
|
+
...request.skipped === void 0 ? {} : { skipped: request.skipped },
|
|
1566
|
+
...request.runner.kind === "vercel-sandbox" ? { runner: request.runner.session } : {}
|
|
1567
|
+
},
|
|
1568
|
+
instances
|
|
1569
|
+
);
|
|
1570
|
+
const keepMs = request.runner.kind === "vercel-sandbox" ? request.runner.session.keepMs : null;
|
|
1354
1571
|
const {
|
|
1355
1572
|
value: { ended, runnerCleanup },
|
|
1356
1573
|
resourceCleanup
|
|
1357
|
-
} = await withResourceCleanup(
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1574
|
+
} = await withResourceCleanup(instances, keepMs, progress, async (cleanup) => {
|
|
1575
|
+
switch (request.runner.kind) {
|
|
1576
|
+
case "launch-machine":
|
|
1577
|
+
return {
|
|
1578
|
+
ended: await runOnLaunchMachine(context, request.runner, {
|
|
1579
|
+
argv: request.argv,
|
|
1580
|
+
verbose: request.verbose,
|
|
1581
|
+
instances,
|
|
1582
|
+
control,
|
|
1583
|
+
progress
|
|
1584
|
+
}),
|
|
1585
|
+
runnerCleanup: null
|
|
1586
|
+
};
|
|
1587
|
+
case "vercel-sandbox":
|
|
1588
|
+
return await runInVercelSandboxSession(context, request.runner, {
|
|
1589
|
+
argv: request.argv,
|
|
1590
|
+
verbose: request.verbose,
|
|
1591
|
+
instances,
|
|
1592
|
+
control,
|
|
1593
|
+
progress,
|
|
1594
|
+
cleanup
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
});
|
|
1363
1598
|
await progress.emit({
|
|
1364
1599
|
kind: "cleanup-finished",
|
|
1365
1600
|
resourceWarnings: resourceWarnings(resourceCleanup),
|
|
@@ -1375,13 +1610,16 @@ async function executeRun(definitionSet, context, resourceContexts2, request, co
|
|
|
1375
1610
|
resourceCleanup
|
|
1376
1611
|
};
|
|
1377
1612
|
}
|
|
1378
|
-
async function
|
|
1613
|
+
async function runOnLaunchMachine(context, runner, input) {
|
|
1614
|
+
const { argv, verbose, instances, control, progress } = input;
|
|
1615
|
+
await startResourceLanes(instances, progress);
|
|
1379
1616
|
const acquisition = await acquireResources(instances, {
|
|
1380
|
-
credential:
|
|
1381
|
-
|
|
1617
|
+
credential: runner.credential === void 0 ? void 0 : credentialSourceFor(runner.credential, context, progress),
|
|
1618
|
+
cancelSignal: control.signal,
|
|
1382
1619
|
progress
|
|
1383
1620
|
});
|
|
1384
1621
|
if (acquisition.kind === "stopped") return acquisition.outcome;
|
|
1622
|
+
if (acquisition.kind !== "acquired") return canceledStop();
|
|
1385
1623
|
const crediting = resourcesCredentials(instances);
|
|
1386
1624
|
if (crediting.length > 0)
|
|
1387
1625
|
throw new Error(
|
|
@@ -1390,13 +1628,13 @@ async function runUnsandboxed(context, request, instances, control, progress) {
|
|
|
1390
1628
|
await announceAcquired(instances, progress);
|
|
1391
1629
|
const terminal = context.runnerTerminal;
|
|
1392
1630
|
const env = commandEnvironment(
|
|
1393
|
-
colorEnvironment(
|
|
1631
|
+
colorEnvironment(runner.env, terminal.color),
|
|
1394
1632
|
runPayload(resourcesPayload(instances), {
|
|
1395
|
-
...
|
|
1396
|
-
...
|
|
1633
|
+
...runner.testEvents === void 0 ? {} : { testEvents: runner.testEvents },
|
|
1634
|
+
...verbose === void 0 ? {} : { verbose }
|
|
1397
1635
|
})
|
|
1398
1636
|
);
|
|
1399
|
-
await progress.emit({ kind: "command-started", argv
|
|
1637
|
+
await progress.emit({ kind: "command-started", argv });
|
|
1400
1638
|
if (control.signal.aborted) return canceledStop();
|
|
1401
1639
|
const commandStartedAt = context.clock.now();
|
|
1402
1640
|
const splitters = { stdout: lineSplitter(), stderr: lineSplitter() };
|
|
@@ -1406,7 +1644,7 @@ async function runUnsandboxed(context, request, instances, control, progress) {
|
|
|
1406
1644
|
else terminal.writeStderr(text);
|
|
1407
1645
|
};
|
|
1408
1646
|
const command = await context.commands.run({
|
|
1409
|
-
argv
|
|
1647
|
+
argv,
|
|
1410
1648
|
env,
|
|
1411
1649
|
terminate: control.terminate,
|
|
1412
1650
|
onOutput: ({ stream, data }) => write(stream, splitters[stream].push(data))
|
|
@@ -1415,66 +1653,77 @@ async function runUnsandboxed(context, request, instances, control, progress) {
|
|
|
1415
1653
|
write("stdout", splitters.stdout.flush());
|
|
1416
1654
|
write("stderr", splitters.stderr.flush());
|
|
1417
1655
|
if (command.kind === "spawn-failed")
|
|
1418
|
-
return { kind: "spawn_failed", executable:
|
|
1656
|
+
return { kind: "spawn_failed", executable: argv[0] ?? "", message: command.message };
|
|
1419
1657
|
await progress.emit({
|
|
1420
1658
|
kind: "command-ended",
|
|
1421
|
-
command:
|
|
1659
|
+
command: posix2.basename(argv[0] ?? ""),
|
|
1422
1660
|
outcome: command,
|
|
1423
1661
|
ms: commandEndedAt.getTime() - commandStartedAt.getTime()
|
|
1424
1662
|
});
|
|
1425
1663
|
return { kind: "command-ended", resources: resourcesRan(instances), command, runner: void 0 };
|
|
1426
1664
|
}
|
|
1427
|
-
function
|
|
1428
|
-
|
|
1429
|
-
return outcome.kind === "aborted" ? "stopped" : "failed";
|
|
1430
|
-
}
|
|
1431
|
-
function runnerStopped(outcome) {
|
|
1432
|
-
if (outcome.kind === "failed") return { kind: "runner_failed", failure: outcome.failure };
|
|
1433
|
-
if (outcome.kind === "snapshot-gone")
|
|
1434
|
-
return { kind: "snapshot_gone", entry: outcome.entry, removal: outcome.removal };
|
|
1435
|
-
return void 0;
|
|
1436
|
-
}
|
|
1437
|
-
async function runSandboxed(context, request, instances, control, progress, cleanup) {
|
|
1665
|
+
async function runInVercelSandboxSession(context, runner, input) {
|
|
1666
|
+
const { argv, verbose, instances, control, progress, cleanup } = input;
|
|
1438
1667
|
const runnerProgress = { emit: (event) => progress.emit({ kind: "runner", event }) };
|
|
1439
|
-
const session = openRunnerSession(context,
|
|
1668
|
+
const session = openRunnerSession(context, runner.session, { signal: control.signal, cleanup }, runnerProgress);
|
|
1440
1669
|
try {
|
|
1441
|
-
const ended = await
|
|
1670
|
+
const ended = await runInVercelSandbox(context, runner, { argv, verbose, instances, session, control, progress });
|
|
1442
1671
|
return { ended, runnerCleanup: await session.cleanUp() };
|
|
1443
1672
|
} finally {
|
|
1444
1673
|
await session.cleanUp();
|
|
1445
1674
|
}
|
|
1446
1675
|
}
|
|
1447
|
-
async function
|
|
1448
|
-
const {
|
|
1449
|
-
const
|
|
1450
|
-
const credential = await mintCredential(context, runner.target, control.signal, progress);
|
|
1676
|
+
async function runInVercelSandbox(context, runner, input) {
|
|
1677
|
+
const { argv, verbose, instances, session, control, progress } = input;
|
|
1678
|
+
const credential = await obtainRunnerCredential(context, runner.credential, control.signal, progress);
|
|
1451
1679
|
if (!credential.ok) return credential.outcome;
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1680
|
+
await emitLanesStarted(instances, progress);
|
|
1681
|
+
const setup = await coordinateSetup({
|
|
1682
|
+
cancelSignal: control.signal,
|
|
1683
|
+
runResources: async (stopSignal) => {
|
|
1684
|
+
const acquired = await acquireResources(instances, {
|
|
1685
|
+
credential: credential.mint,
|
|
1686
|
+
cancelSignal: control.signal,
|
|
1687
|
+
stopSignal,
|
|
1688
|
+
progress
|
|
1689
|
+
});
|
|
1690
|
+
if (acquired.kind === "acquired") return { kind: "ready", value: void 0 };
|
|
1691
|
+
return acquired;
|
|
1457
1692
|
},
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1693
|
+
runRunner: async (stopSignal) => {
|
|
1694
|
+
let readied;
|
|
1695
|
+
let laneOutcome;
|
|
1696
|
+
try {
|
|
1697
|
+
readied = await session.ready(credential.access, AbortSignal.any([control.signal, stopSignal]));
|
|
1698
|
+
laneOutcome = runnerLaneOutcome(readied);
|
|
1699
|
+
await progress.emit({ kind: "lane-ended", lane: "runner", resource: null, outcome: laneOutcome });
|
|
1700
|
+
} catch (error) {
|
|
1701
|
+
if (laneOutcome === void 0)
|
|
1702
|
+
await progress.emit({ kind: "lane-ended", lane: "runner", resource: null, outcome: "failed" }).catch(() => void 0);
|
|
1703
|
+
throw error;
|
|
1704
|
+
}
|
|
1705
|
+
if (readied.kind === "ready") return { kind: "ready", value: readied.runner };
|
|
1706
|
+
const stopped = runnerStopped(readied);
|
|
1707
|
+
if (stopped !== void 0) return { kind: "stopped", outcome: stopped };
|
|
1708
|
+
return control.signal.aborted ? { kind: "canceled" } : { kind: "internal-stopped" };
|
|
1709
|
+
}
|
|
1710
|
+
});
|
|
1711
|
+
if (setup.kind === "threw") throw setup.error;
|
|
1712
|
+
if (setup.kind === "stopped") {
|
|
1713
|
+
const { outcome } = setup;
|
|
1463
1714
|
return outcome.kind === "canceled" ? { ...outcome, commandStopped: false } : outcome;
|
|
1464
1715
|
}
|
|
1465
|
-
const
|
|
1466
|
-
|
|
1467
|
-
const ready = readied.runner;
|
|
1468
|
-
const credentials = resourcesCredentials(instances, runner.credentials).map(({ credential: credential2 }) => credential2);
|
|
1716
|
+
const ready = setup.runner;
|
|
1717
|
+
const credentials = resourcesCredentials(instances, runner.session.credentials).map(({ credential: c }) => c);
|
|
1469
1718
|
await announceAcquired(instances, progress);
|
|
1470
1719
|
const ran = await runCommandInSandbox(
|
|
1471
1720
|
session,
|
|
1472
1721
|
{
|
|
1473
|
-
argv
|
|
1722
|
+
argv,
|
|
1474
1723
|
runPayload: JSON.stringify(
|
|
1475
1724
|
runPayload(resourcesPayload(instances), {
|
|
1476
1725
|
testEvents: SANDBOX_TEST_EVENTS_PATH,
|
|
1477
|
-
...
|
|
1726
|
+
...verbose === void 0 ? {} : { verbose }
|
|
1478
1727
|
})
|
|
1479
1728
|
),
|
|
1480
1729
|
credentials
|
|
@@ -1483,11 +1732,10 @@ async function runInSandbox(context, request, instances, session, control, progr
|
|
|
1483
1732
|
progress
|
|
1484
1733
|
);
|
|
1485
1734
|
if (!ran.ok) return ran.outcome;
|
|
1486
|
-
const { command } = ran;
|
|
1487
1735
|
return {
|
|
1488
1736
|
kind: "command-ended",
|
|
1489
1737
|
resources: resourcesRan(instances),
|
|
1490
|
-
command,
|
|
1738
|
+
command: ran.command,
|
|
1491
1739
|
runner: {
|
|
1492
1740
|
snapshotId: ready.snapshotId,
|
|
1493
1741
|
base: ready.base,
|
|
@@ -1501,130 +1749,6 @@ async function runInSandbox(context, request, instances, session, control, progr
|
|
|
1501
1749
|
}
|
|
1502
1750
|
};
|
|
1503
1751
|
}
|
|
1504
|
-
async function readyBoth(request, control, progress) {
|
|
1505
|
-
await progress.emit({ kind: "lanes-started" });
|
|
1506
|
-
return await acquireResources(request.instances, {
|
|
1507
|
-
credential: request.credential,
|
|
1508
|
-
signal: control.signal,
|
|
1509
|
-
progress,
|
|
1510
|
-
beside: {
|
|
1511
|
-
lane: { lane: "runner", resource: null },
|
|
1512
|
-
start: request.ready,
|
|
1513
|
-
outcomeOf: runnerLaneOutcome,
|
|
1514
|
-
stopped: runnerStopped
|
|
1515
|
-
}
|
|
1516
|
-
});
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
// src/core/sandbox-end.ts
|
|
1520
|
-
function acrossSandboxesExitStatus(sandboxes) {
|
|
1521
|
-
return sandboxes.every(({ state }) => state === "passed") ? 0 : 1;
|
|
1522
|
-
}
|
|
1523
|
-
function sandboxEndFacts(end, commandStarted) {
|
|
1524
|
-
const short = (cause, failedStage, started = commandStarted) => ({
|
|
1525
|
-
state: started ? "failed" : "not-started",
|
|
1526
|
-
failedStage,
|
|
1527
|
-
exitCode: null,
|
|
1528
|
-
cause: oneLine(cause)
|
|
1529
|
-
});
|
|
1530
|
-
switch (end.kind) {
|
|
1531
|
-
case "ran": {
|
|
1532
|
-
const { command } = end;
|
|
1533
|
-
if (command.kind === "exited")
|
|
1534
|
-
return {
|
|
1535
|
-
state: command.code === 0 ? "passed" : "failed",
|
|
1536
|
-
failedStage: command.code === 0 ? null : "command",
|
|
1537
|
-
exitCode: command.code,
|
|
1538
|
-
cause: null
|
|
1539
|
-
};
|
|
1540
|
-
return {
|
|
1541
|
-
state: "failed",
|
|
1542
|
-
failedStage: "command",
|
|
1543
|
-
exitCode: null,
|
|
1544
|
-
cause: command.kind === "signaled" ? `signaled: ${command.signal}` : "no-exit-code"
|
|
1545
|
-
};
|
|
1546
|
-
}
|
|
1547
|
-
case "canceled":
|
|
1548
|
-
return { state: "canceled", failedStage: null, exitCode: null, cause: "canceled" };
|
|
1549
|
-
case "runner_failed": {
|
|
1550
|
-
const { failure } = end;
|
|
1551
|
-
const ranCommand = failure.kind === "sandbox-api-failed" && failure.operation === "run-command";
|
|
1552
|
-
return short(runnerFailureCause(failure), runnerFailureStage(failure), commandStarted || ranCommand);
|
|
1553
|
-
}
|
|
1554
|
-
case "mint_failed":
|
|
1555
|
-
return short(`mint-failed: ${describeMintFailure(end.failure, end.target).cause}`, "mint");
|
|
1556
|
-
case "snapshot_gone":
|
|
1557
|
-
return short("snapshot-gone", "snapshot");
|
|
1558
|
-
case "spawn_failed":
|
|
1559
|
-
return short(`spawn-failed: ${end.message}`, "command");
|
|
1560
|
-
case "resource_refused":
|
|
1561
|
-
return short(`resource-refused: ${end.resource}: ${end.refusal.message}`, "resource");
|
|
1562
|
-
case "threw":
|
|
1563
|
-
return short(`threw: ${end.message}`, "storm");
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
function runnerFailureStage(failure) {
|
|
1567
|
-
switch (failure.kind) {
|
|
1568
|
-
case "snapshot-build-step-failed":
|
|
1569
|
-
return "snapshot";
|
|
1570
|
-
case "apply-failed":
|
|
1571
|
-
return "apply";
|
|
1572
|
-
case "install-failed":
|
|
1573
|
-
return "install";
|
|
1574
|
-
case "build-failed":
|
|
1575
|
-
return "build";
|
|
1576
|
-
case "checkout-failed":
|
|
1577
|
-
return "checkout";
|
|
1578
|
-
case "credential-claims-missing":
|
|
1579
|
-
return "mint";
|
|
1580
|
-
case "sandbox-api-failed":
|
|
1581
|
-
switch (failure.operation) {
|
|
1582
|
-
case "start-build-sandbox":
|
|
1583
|
-
case "save-snapshot":
|
|
1584
|
-
return "snapshot";
|
|
1585
|
-
case "start-runner-sandbox":
|
|
1586
|
-
case "login-path":
|
|
1587
|
-
case "run-script":
|
|
1588
|
-
return "start";
|
|
1589
|
-
case "upload":
|
|
1590
|
-
return "upload";
|
|
1591
|
-
case "run-command":
|
|
1592
|
-
return "command";
|
|
1593
|
-
}
|
|
1594
|
-
// A policy write fails at the stage it guards: a snapshot build's steps or save, the install and build steps, or
|
|
1595
|
-
// the command.
|
|
1596
|
-
case "network-policy-failed":
|
|
1597
|
-
switch (failure.around) {
|
|
1598
|
-
case "snapshot-steps":
|
|
1599
|
-
case "snapshot-save":
|
|
1600
|
-
return "snapshot";
|
|
1601
|
-
case "run-steps":
|
|
1602
|
-
return "install";
|
|
1603
|
-
case "command":
|
|
1604
|
-
return "command";
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
function runnerFailureCause(failure) {
|
|
1609
|
-
switch (failure.kind) {
|
|
1610
|
-
case "sandbox-api-failed":
|
|
1611
|
-
return `${failure.operation}: ${failure.message}`;
|
|
1612
|
-
case "checkout-failed":
|
|
1613
|
-
return `checkout-failed: ${failure.failure.message}`;
|
|
1614
|
-
case "credential-claims-missing":
|
|
1615
|
-
return `credential-claims-missing: ${failure.target.team}/${failure.target.project}`;
|
|
1616
|
-
case "snapshot-build-step-failed":
|
|
1617
|
-
case "apply-failed":
|
|
1618
|
-
case "install-failed":
|
|
1619
|
-
case "build-failed":
|
|
1620
|
-
return `${failure.kind}: ${failure.exitCode === null ? "no exit code" : `exited ${failure.exitCode}`}`;
|
|
1621
|
-
case "network-policy-failed":
|
|
1622
|
-
return `network-policy-failed: ${failure.operation} around ${failure.around}: ${failure.status === null ? "" : `HTTP ${failure.status}: `}${failure.message}`;
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
function oneLine(text) {
|
|
1626
|
-
return text.trim().replace(/\s*\n\s*/g, " ");
|
|
1627
|
-
}
|
|
1628
1752
|
|
|
1629
1753
|
// src/core/across-sandboxes.ts
|
|
1630
1754
|
async function executeAcrossSandboxes(definitionSet, context, resourceContexts2, request, control, progress) {
|
|
@@ -1643,7 +1767,7 @@ async function executeAcrossSandboxes(definitionSet, context, resourceContexts2,
|
|
|
1643
1767
|
return all;
|
|
1644
1768
|
}
|
|
1645
1769
|
);
|
|
1646
|
-
const runnerCleanup =
|
|
1770
|
+
const runnerCleanup = mergedRunnerCleanup(runner.target, ended.runnerCleanups);
|
|
1647
1771
|
await progress.emit({
|
|
1648
1772
|
kind: "cleanup-finished",
|
|
1649
1773
|
resourceWarnings: resourceWarnings(resourceCleanup),
|
|
@@ -1666,135 +1790,139 @@ async function executeAcrossSandboxes(definitionSet, context, resourceContexts2,
|
|
|
1666
1790
|
return { kind: "snapshot_gone", entry: first.end.entry, removal: first.end.removal, ...cleanup };
|
|
1667
1791
|
return { kind: "sandboxes_ran", sandboxes, snapshot: ended.snapshot, resources: resourcesRan(instances), ...cleanup };
|
|
1668
1792
|
}
|
|
1669
|
-
function rankSetupEnd(canceled, snapshotFailure, resources) {
|
|
1670
|
-
if (canceled) return canceledStop();
|
|
1671
|
-
if (snapshotFailure !== void 0) return snapshotFailure;
|
|
1672
|
-
if (resources.kind === "stopped" && resources.stop.kind !== "canceled") return resources.stop;
|
|
1673
|
-
if (resources.kind === "threw") return { kind: "threw", message: errorMessage(resources.error) };
|
|
1674
|
-
return canceledStop();
|
|
1675
|
-
}
|
|
1676
1793
|
function errorMessage(error) {
|
|
1677
1794
|
return error instanceof Error ? error.message : String(error);
|
|
1678
1795
|
}
|
|
1796
|
+
function gateEndFromResources(cancelSignal, settled) {
|
|
1797
|
+
if (cancelSignal.aborted) return canceledStop();
|
|
1798
|
+
if (settled.kind === "stopped") return settled.outcome;
|
|
1799
|
+
if (settled.kind === "threw") return { kind: "threw", message: errorMessage(settled.error) };
|
|
1800
|
+
return canceledStop();
|
|
1801
|
+
}
|
|
1679
1802
|
async function runAll(context, request, instances, cancelSignal, progress) {
|
|
1680
1803
|
const count = request.sandboxes.length;
|
|
1681
|
-
const credential = await
|
|
1804
|
+
const credential = await obtainRunnerCredential(context, request.credential, cancelSignal, progress);
|
|
1682
1805
|
if (!credential.ok) return stoppedBeforeSandboxes(count, credential.outcome, [], void 0, progress);
|
|
1683
1806
|
const { access: access2, mint } = credential;
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
kind: "
|
|
1730
|
-
lane: "runner",
|
|
1731
|
-
resource: null,
|
|
1732
|
-
outcome: chosen.kind === "aborted" ? "stopped" : "failed"
|
|
1807
|
+
let choiceCleanup;
|
|
1808
|
+
let snapshotFailure;
|
|
1809
|
+
let sandboxesResult;
|
|
1810
|
+
await emitLanesStarted(instances, progress);
|
|
1811
|
+
const setup = await coordinateSetup({
|
|
1812
|
+
cancelSignal,
|
|
1813
|
+
runResources: (stopSignal) => acquireAndSplit(instances, {
|
|
1814
|
+
credential: mint,
|
|
1815
|
+
cancelSignal,
|
|
1816
|
+
stopSignal,
|
|
1817
|
+
progress,
|
|
1818
|
+
sandboxes: count,
|
|
1819
|
+
runnerCredentials: request.runner.credentials
|
|
1820
|
+
}),
|
|
1821
|
+
runRunner: async (stopSignal, settledResources, stopResources) => {
|
|
1822
|
+
const runnerProgress = { emit: (event) => progress.emit({ kind: "runner", event }) };
|
|
1823
|
+
const chosen = await chooseSnapshotForRun(
|
|
1824
|
+
context,
|
|
1825
|
+
{
|
|
1826
|
+
prepared: request.runner.prepared,
|
|
1827
|
+
access: access2,
|
|
1828
|
+
user: request.runner.user,
|
|
1829
|
+
credentials: request.runner.credentials
|
|
1830
|
+
},
|
|
1831
|
+
{ signal: cancelSignal, stop: stopSignal },
|
|
1832
|
+
runnerProgress
|
|
1833
|
+
);
|
|
1834
|
+
choiceCleanup = { ...chosen.cleanup, target: request.runner.target };
|
|
1835
|
+
if (chosen.kind !== "chosen") {
|
|
1836
|
+
snapshotFailure = chosen.kind === "failed" ? { kind: "runner_failed", failure: chosen.failure } : void 0;
|
|
1837
|
+
await progress.emit({
|
|
1838
|
+
kind: "lane-ended",
|
|
1839
|
+
lane: "runner",
|
|
1840
|
+
resource: null,
|
|
1841
|
+
outcome: chosen.kind === "aborted" ? "stopped" : "failed"
|
|
1842
|
+
});
|
|
1843
|
+
if (snapshotFailure !== void 0) return { kind: "stopped", outcome: snapshotFailure };
|
|
1844
|
+
return cancelSignal.aborted ? { kind: "canceled" } : { kind: "internal-stopped" };
|
|
1845
|
+
}
|
|
1846
|
+
const stageSignal = AbortSignal.any([cancelSignal, stopSignal]);
|
|
1847
|
+
const gateOf = (index) => settledResources.then((settled) => {
|
|
1848
|
+
if (settled.kind === "ready") {
|
|
1849
|
+
const resources = settled.value.parts[index];
|
|
1850
|
+
if (resources !== void 0) return { kind: "ready", resources, credentials: settled.value.credentials };
|
|
1851
|
+
}
|
|
1852
|
+
return { kind: "stopped", end: gateEndFromResources(cancelSignal, settled) };
|
|
1733
1853
|
});
|
|
1734
|
-
const
|
|
1735
|
-
|
|
1736
|
-
const
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
},
|
|
1755
|
-
progress
|
|
1854
|
+
const tracker = sandboxFenceTracker();
|
|
1855
|
+
await progress.emit({ kind: "sandboxes-started", sandboxes: count });
|
|
1856
|
+
const ran = await Promise.all(
|
|
1857
|
+
request.sandboxes.map(
|
|
1858
|
+
(sandboxSpec, index) => runOneSandbox(
|
|
1859
|
+
context,
|
|
1860
|
+
{
|
|
1861
|
+
sandbox: index,
|
|
1862
|
+
count,
|
|
1863
|
+
sandboxSpec,
|
|
1864
|
+
access: access2,
|
|
1865
|
+
snapshot: chosen.snapshot,
|
|
1866
|
+
request,
|
|
1867
|
+
gate: gateOf(index),
|
|
1868
|
+
cancelSignal,
|
|
1869
|
+
stageSignal,
|
|
1870
|
+
tracker
|
|
1871
|
+
},
|
|
1872
|
+
progress
|
|
1873
|
+
)
|
|
1756
1874
|
)
|
|
1757
|
-
)
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1875
|
+
);
|
|
1876
|
+
stopResources();
|
|
1877
|
+
sandboxesResult = { snapshot: chosen.snapshot, ran, allFenced: tracker.allFenced() };
|
|
1878
|
+
return { kind: "ready", value: sandboxesResult };
|
|
1879
|
+
}
|
|
1880
|
+
});
|
|
1881
|
+
if (setup.kind === "threw" && setup.lane === "runner") throw setup.error;
|
|
1882
|
+
const finishSandboxes = (finished) => {
|
|
1883
|
+
const { snapshot, ran, allFenced } = finished;
|
|
1884
|
+
const sandboxes = ran.map(({ ended }) => ended);
|
|
1885
|
+
const runnerCleanups2 = [
|
|
1886
|
+
...choiceCleanup === void 0 ? [] : [choiceCleanup],
|
|
1766
1887
|
...sandboxes.flatMap(({ runnerCleanup }) => runnerCleanup === null ? [] : [runnerCleanup])
|
|
1767
1888
|
];
|
|
1768
|
-
if (
|
|
1889
|
+
if (setup.kind === "threw")
|
|
1890
|
+
return { kind: "threw", error: setup.error, runnerSandboxesFenced: allFenced, runnerCleanups: runnerCleanups2 };
|
|
1891
|
+
const progressFailure = ran.find((sandbox) => sandbox.progressFailure !== void 0)?.progressFailure;
|
|
1769
1892
|
if (progressFailure !== void 0)
|
|
1770
|
-
return { kind: "threw", error: progressFailure.error, runnerSandboxesFenced, runnerCleanups };
|
|
1893
|
+
return { kind: "threw", error: progressFailure.error, runnerSandboxesFenced: allFenced, runnerCleanups: runnerCleanups2 };
|
|
1771
1894
|
return {
|
|
1772
1895
|
kind: "sandboxes",
|
|
1773
1896
|
sandboxes,
|
|
1774
|
-
snapshot
|
|
1775
|
-
failed:
|
|
1776
|
-
canceled: ran.some(({ canceled }) => canceled),
|
|
1777
|
-
runnerSandboxesFenced,
|
|
1778
|
-
runnerCleanups
|
|
1897
|
+
snapshot,
|
|
1898
|
+
failed: setup.kind === "stopped" && setup.outcome.kind !== "canceled" ? setup.outcome : void 0,
|
|
1899
|
+
canceled: setup.kind === "stopped" && setup.outcome.kind === "canceled" || ran.some(({ canceled }) => canceled),
|
|
1900
|
+
runnerSandboxesFenced: allFenced,
|
|
1901
|
+
runnerCleanups: runnerCleanups2
|
|
1779
1902
|
};
|
|
1780
|
-
}
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1903
|
+
};
|
|
1904
|
+
if (setup.kind === "ready") return finishSandboxes(setup.runner);
|
|
1905
|
+
if (sandboxesResult !== void 0) return finishSandboxes(sandboxesResult);
|
|
1906
|
+
const runnerCleanups = choiceCleanup === void 0 ? [] : [choiceCleanup];
|
|
1907
|
+
if (setup.kind === "threw") {
|
|
1908
|
+
const ending = cancelSignal.aborted ? canceledStop() : snapshotFailure ?? { kind: "threw", message: errorMessage(setup.error) };
|
|
1909
|
+
return stoppedBeforeSandboxes(count, ending, runnerCleanups, { error: setup.error }, progress);
|
|
1784
1910
|
}
|
|
1911
|
+
return stoppedBeforeSandboxes(count, setup.outcome, runnerCleanups, void 0, progress);
|
|
1785
1912
|
}
|
|
1786
1913
|
async function acquireAndSplit(instances, input) {
|
|
1787
1914
|
const acquisition = await acquireResources(instances, {
|
|
1788
1915
|
credential: input.credential,
|
|
1789
|
-
|
|
1916
|
+
cancelSignal: input.cancelSignal,
|
|
1917
|
+
stopSignal: input.stopSignal,
|
|
1790
1918
|
progress: input.progress
|
|
1791
1919
|
});
|
|
1792
|
-
if (acquisition.kind
|
|
1920
|
+
if (acquisition.kind !== "acquired") return acquisition;
|
|
1793
1921
|
const split = splitAcquired(instances, input.sandboxes);
|
|
1794
|
-
if (split.kind === "refused") return { kind: "stopped",
|
|
1922
|
+
if (split.kind === "refused") return { kind: "stopped", outcome: split.outcome };
|
|
1795
1923
|
const credentials = resourcesCredentials(instances, input.runnerCredentials).map(({ credential }) => credential);
|
|
1796
1924
|
await announceAcquired(instances, input.progress);
|
|
1797
|
-
return {
|
|
1925
|
+
return { kind: "ready", value: { parts: split.parts, credentials } };
|
|
1798
1926
|
}
|
|
1799
1927
|
async function stoppedBeforeSandboxes(count, end, runnerCleanups, thrown, progress) {
|
|
1800
1928
|
const facts = sandboxEndFacts(end, false);
|
|
@@ -1806,18 +1934,11 @@ async function stoppedBeforeSandboxes(count, end, runnerCleanups, thrown, progre
|
|
|
1806
1934
|
return { kind: "stopped", stop: end, runnerCleanups, runnerSandboxesFenced: true };
|
|
1807
1935
|
}
|
|
1808
1936
|
async function runOneSandbox(context, input, progress) {
|
|
1809
|
-
const { sandbox, count, sandboxSpec, request, cancelSignal, stageSignal } = input;
|
|
1937
|
+
const { sandbox, count, sandboxSpec, request, cancelSignal, stageSignal, tracker } = input;
|
|
1810
1938
|
const { argv } = sandboxSpec;
|
|
1811
1939
|
const emitSandbox = async (event) => await progress.emit({ kind: "sandbox", sandbox, event });
|
|
1812
1940
|
const ownProgress = { emit: emitSandbox };
|
|
1813
1941
|
const runnerProgress = { emit: (event) => emitSandbox({ kind: "runner", event }) };
|
|
1814
|
-
let cleanupStarted = false;
|
|
1815
|
-
let fenced = false;
|
|
1816
|
-
const startCleanup = async () => {
|
|
1817
|
-
if (cleanupStarted) return;
|
|
1818
|
-
cleanupStarted = true;
|
|
1819
|
-
await emitSandbox({ kind: "cleanup-started", keepMs: request.runner.keepMs, resources: [] });
|
|
1820
|
-
};
|
|
1821
1942
|
const session = openRunnerSession(
|
|
1822
1943
|
{ ...context, runnerTerminal: context.sandboxTerminal(sandbox) },
|
|
1823
1944
|
{ ...request.runner, snapshot: input.snapshot },
|
|
@@ -1826,12 +1947,9 @@ async function runOneSandbox(context, input, progress) {
|
|
|
1826
1947
|
// command's cancel signal, never storm's internal sibling-stop signal.
|
|
1827
1948
|
{
|
|
1828
1949
|
signal: cancelSignal,
|
|
1829
|
-
cleanup:
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
fenced = fence.runnerSandboxFenced;
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1950
|
+
cleanup: tracker.sessionCleanup(
|
|
1951
|
+
() => emitSandbox({ kind: "cleanup-started", keepMs: request.runner.keepMs, resources: [] })
|
|
1952
|
+
)
|
|
1835
1953
|
},
|
|
1836
1954
|
runnerProgress
|
|
1837
1955
|
);
|
|
@@ -1866,7 +1984,7 @@ async function runOneSandbox(context, input, progress) {
|
|
|
1866
1984
|
notDeleted: runnerCleanup.notDeleted.length
|
|
1867
1985
|
});
|
|
1868
1986
|
} catch (error) {
|
|
1869
|
-
end = { kind: "threw", message:
|
|
1987
|
+
end = { kind: "threw", message: errorMessage(error) };
|
|
1870
1988
|
canceled = cancelSignal.aborted;
|
|
1871
1989
|
runnerCleanup = await session.cleanUp().catch(() => runnerCleanup);
|
|
1872
1990
|
}
|
|
@@ -1874,9 +1992,9 @@ async function runOneSandbox(context, input, progress) {
|
|
|
1874
1992
|
const ended = { sandbox, argv, end, ...facts, runnerCleanup };
|
|
1875
1993
|
try {
|
|
1876
1994
|
await progress.emit({ kind: "sandbox-ended", sandbox, ...facts });
|
|
1877
|
-
return { ended, progressFailure: void 0,
|
|
1995
|
+
return { ended, progressFailure: void 0, canceled };
|
|
1878
1996
|
} catch (error) {
|
|
1879
|
-
return { ended, progressFailure: { error },
|
|
1997
|
+
return { ended, progressFailure: { error }, canceled };
|
|
1880
1998
|
}
|
|
1881
1999
|
}
|
|
1882
2000
|
async function sandboxBody(input, progress, started) {
|
|
@@ -1888,7 +2006,7 @@ async function sandboxBody(input, progress, started) {
|
|
|
1888
2006
|
};
|
|
1889
2007
|
if (stageSignal.aborted) return await stopped();
|
|
1890
2008
|
const readied = await session.ready(input.access, stageSignal);
|
|
1891
|
-
await progress.emit({ kind: "lane-ended", lane: "runner", resource: null, outcome:
|
|
2009
|
+
await progress.emit({ kind: "lane-ended", lane: "runner", resource: null, outcome: runnerLaneOutcome(readied) });
|
|
1892
2010
|
if (readied.kind === "aborted") return await stopped();
|
|
1893
2011
|
if (readied.kind === "failed") return { kind: "runner_failed", failure: readied.failure };
|
|
1894
2012
|
if (readied.kind === "snapshot-gone")
|
|
@@ -1912,19 +2030,6 @@ async function sandboxBody(input, progress, started) {
|
|
|
1912
2030
|
if (!ran.ok) return ran.outcome;
|
|
1913
2031
|
return { kind: "ran", command: ran.command };
|
|
1914
2032
|
}
|
|
1915
|
-
function runnerLaneOutcome2(outcome) {
|
|
1916
|
-
if (outcome.kind === "ready") return "ready";
|
|
1917
|
-
return outcome.kind === "aborted" ? "stopped" : "failed";
|
|
1918
|
-
}
|
|
1919
|
-
function mergedCleanup(target, cleanups) {
|
|
1920
|
-
return {
|
|
1921
|
-
kept: null,
|
|
1922
|
-
notKept: null,
|
|
1923
|
-
notStopped: cleanups.flatMap(({ notStopped }) => notStopped),
|
|
1924
|
-
notDeleted: cleanups.flatMap(({ notDeleted }) => notDeleted),
|
|
1925
|
-
target
|
|
1926
|
-
};
|
|
1927
|
-
}
|
|
1928
2033
|
|
|
1929
2034
|
export {
|
|
1930
2035
|
warningTally,
|
|
@@ -1950,8 +2055,8 @@ export {
|
|
|
1950
2055
|
liveJobSummaryGateway,
|
|
1951
2056
|
liveProgressTerminal,
|
|
1952
2057
|
livePackageBinGateway,
|
|
1953
|
-
executeRun,
|
|
1954
2058
|
acrossSandboxesExitStatus,
|
|
1955
2059
|
sandboxEndFacts,
|
|
2060
|
+
executeRun,
|
|
1956
2061
|
executeAcrossSandboxes
|
|
1957
2062
|
};
|