hammerkit 2.0.0-next.8 → 2.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/build.schema.json +228 -63
- package/dist/cache/backends/registry/registry-client.js +8 -2
- package/dist/cache/explain.js +5 -0
- package/dist/cache/last-resolved.js +11 -0
- package/dist/cli.js +4 -1
- package/dist/dashboard/assets/{graph-canvas-HmkW_-XJ.js → graph-canvas-DtJSpova.js} +1 -1
- package/dist/dashboard/assets/index-BndChMep.css +2 -0
- package/dist/dashboard/assets/{index-vE22S5E_.js → index-DRSwIRXd.js} +9 -9
- package/dist/dashboard/index.html +2 -2
- package/dist/docker/item-network.js +51 -18
- package/dist/docker/package.js +85 -76
- package/dist/docker/server-tools.js +96 -0
- package/dist/docker/stream.js +15 -7
- package/dist/environment/replace-env-variables.js +1 -1
- package/dist/environment/run-source-envs.js +18 -0
- package/dist/executer/check-container-binds.js +158 -0
- package/dist/executer/docker-service.js +42 -3
- package/dist/executer/docker-task.js +33 -6
- package/dist/executer/execute-command.js +9 -15
- package/dist/executer/execute-work-task.js +11 -1
- package/dist/executer/execute-work-tree.js +2 -1
- package/dist/executer/execution-steps.js +6 -2
- package/dist/executer/get-container-binds.js +2 -0
- package/dist/executer/print-container-options.js +10 -10
- package/dist/executer/process-manager.js +84 -5
- package/dist/executer/scheduler/state-key.js +19 -1
- package/dist/executer/task-priority.js +131 -0
- package/dist/file/stat-beneath.js +66 -0
- package/dist/file/within-root.js +13 -4
- package/dist/harness/connect.js +1 -6
- package/dist/harness/mcp-command.js +1 -1
- package/dist/harness/sandbox-client.js +39 -4
- package/dist/harness/service-tools.js +2 -2
- package/dist/kubernetes/await-running-state.js +42 -26
- package/dist/kubernetes/ensure-persistent-data.js +22 -7
- package/dist/kubernetes/follow-pod-logs.js +5 -3
- package/dist/kubernetes/network-gate.js +74 -11
- package/dist/kubernetes/network-policy.js +32 -10
- package/dist/kubernetes/remove-stale-items.js +15 -2
- package/dist/kubernetes/restore-kubernetes-data.js +3 -2
- package/dist/kubernetes/sandbox-runner.js +3 -4
- package/dist/kubernetes/store-kubernetes-data.js +3 -2
- package/dist/kubernetes/transfer-tools.js +66 -0
- package/dist/kubernetes/volumes.js +52 -10
- package/dist/optimizer/check-key.js +7 -0
- package/dist/optimizer/check-keys.js +19 -5
- package/dist/optimizer/get-work-cache-stats.js +19 -7
- package/dist/optimizer/work-task-cache-description.js +42 -8
- package/dist/parser/read-build-file.js +8 -3
- package/dist/planner/image-build.js +172 -0
- package/dist/planner/utils/append-work-dependencies.js +14 -1
- package/dist/planner/utils/append-work-service.js +1 -1
- package/dist/planner/utils/append-work-task.js +51 -1
- package/dist/planner/utils/assert-item-paths.js +6 -7
- package/dist/planner/utils/dependency-outputs.js +18 -0
- package/dist/planner/utils/template-value.js +20 -4
- package/dist/planner/work-runtime-docker.js +48 -50
- package/dist/planner/work-runtime-kubernetes.js +1 -0
- package/dist/planner/work-runtime-local.js +3 -7
- package/dist/planner/work-secret.js +135 -13
- package/dist/planner/work-tree.js +10 -0
- package/dist/remote/collect-bundle.js +9 -1
- package/dist/remote/host-config.js +49 -3
- package/dist/remote/location.js +5 -5
- package/dist/remote/remote-commands.js +12 -14
- package/dist/remote/remote-work-commands.js +20 -8
- package/dist/schema/build-file-image-build-schema.js +77 -0
- package/dist/schema/build-file-task-schema.js +9 -2
- package/dist/schema/reference-parser.js +10 -1
- package/dist/schema/schema-parser.js +46 -2
- package/dist/schema/work-scope-parser.js +16 -1
- package/dist/secrets/secret-catalog.js +8 -1
- package/dist/server/dashboard.js +8 -5
- package/dist/server/executor.js +58 -35
- package/dist/server/kubernetes-backend.js +29 -4
- package/dist/server/kubernetes-sandbox-storage.js +14 -4
- package/dist/server/overview.js +20 -2
- package/dist/server/plan.js +31 -3
- package/dist/server/policy.js +14 -7
- package/dist/server/repo-access.js +4 -3
- package/dist/server/run-environment.js +5 -2
- package/dist/server/run-plan.js +18 -6
- package/dist/server/run-retry.js +57 -0
- package/dist/server/run-source-environment.js +39 -0
- package/dist/server/run-worker.js +38 -9
- package/dist/server/runs.js +59 -1
- package/dist/server/sandbox-files.js +339 -55
- package/dist/server/sandbox-patch.js +43 -17
- package/dist/server/sandboxes.js +57 -23
- package/dist/server/server-config.js +24 -4
- package/dist/server/server.js +107 -12
- package/dist/server/service-runs.js +42 -4
- package/dist/server/sources.js +68 -11
- package/dist/utils/buffer-context.js +30 -20
- package/dist/utils/line-splitter.js +52 -0
- package/dist/utils/read-lines.js +65 -0
- package/dist/utils/tar.js +51 -1
- package/package.json +1 -1
- package/dist/dashboard/assets/index-gIBDC_m8.css +0 -2
|
@@ -12,6 +12,7 @@ const capacity_1 = require("./capacity");
|
|
|
12
12
|
const kubernetes_instance_1 = require("../kubernetes/kubernetes-instance");
|
|
13
13
|
const log_1 = require("../log");
|
|
14
14
|
const network_policy_1 = require("../kubernetes/network-policy");
|
|
15
|
+
const network_gate_1 = require("../kubernetes/network-gate");
|
|
15
16
|
const sleep_1 = require("../utils/sleep");
|
|
16
17
|
const version_1 = require("../version");
|
|
17
18
|
const executor_1 = require("./executor");
|
|
@@ -98,6 +99,8 @@ function readInClusterNamespace() {
|
|
|
98
99
|
* Policies add up, so neither selects the pods of a limited item: its own policy (see
|
|
99
100
|
* buildNetworkPolicy) is all it may reach, DNS left out, and all that may reach it. An
|
|
100
101
|
* egress proxy takes connections from its item only (buildProxyPolicy).
|
|
102
|
+
* - the pods that copy files into and out of claims: no network at all (they are limited,
|
|
103
|
+
* and the policies of the items whose labels they carry leave them out)
|
|
101
104
|
*/
|
|
102
105
|
function getNamespacePolicies(namespace, deniedEgress, allowedEgress = []) {
|
|
103
106
|
const metadata = (name) => ({
|
|
@@ -157,6 +160,17 @@ function getNamespacePolicies(namespace, deniedEgress, allowedEgress = []) {
|
|
|
157
160
|
ingress: [],
|
|
158
161
|
},
|
|
159
162
|
},
|
|
163
|
+
{
|
|
164
|
+
apiVersion: 'networking.k8s.io/v1',
|
|
165
|
+
kind: 'NetworkPolicy',
|
|
166
|
+
metadata: metadata('hammerkit-transfer'),
|
|
167
|
+
spec: {
|
|
168
|
+
// the pods that copy files into and out of a claim, which are reached through the
|
|
169
|
+
// API (exec): nothing in or out
|
|
170
|
+
podSelector: { matchLabels: { [network_policy_1.TRANSFER_LABEL]: 'true' } },
|
|
171
|
+
policyTypes: ['Ingress', 'Egress'],
|
|
172
|
+
},
|
|
173
|
+
},
|
|
160
174
|
];
|
|
161
175
|
}
|
|
162
176
|
exports.getNamespacePolicies = getNamespacePolicies;
|
|
@@ -565,6 +579,7 @@ class KubernetesExecutor {
|
|
|
565
579
|
// The cluster as the process of a run sees it: the namespace its tasks and services go in.
|
|
566
580
|
environmentOf(run, namespace, work, capabilitiesProblem) {
|
|
567
581
|
const backend = this.config.backend;
|
|
582
|
+
const openGate = (0, network_gate_1.getOpenNetworkGate)(backend);
|
|
568
583
|
return {
|
|
569
584
|
type: 'kubernetes',
|
|
570
585
|
namespace,
|
|
@@ -585,6 +600,7 @@ class KubernetesExecutor {
|
|
|
585
600
|
// the claims of a service run go with its namespace
|
|
586
601
|
...(this.keep > 0 && !run.up ? { volumeScope: getVolumeScope(run) } : {}),
|
|
587
602
|
...(run.up ? { serviceRun: true } : {}),
|
|
603
|
+
...(openGate ? { openGate } : {}),
|
|
588
604
|
...(backend.capabilities
|
|
589
605
|
? {
|
|
590
606
|
capabilities: {
|
|
@@ -720,12 +736,21 @@ function getPrivilegedNamespaceProblem(namespace, labels, backend) {
|
|
|
720
736
|
`${namespace} ${ENFORCE_LABEL}=baseline ${AUDIT_LABEL}- --overwrite`);
|
|
721
737
|
}
|
|
722
738
|
exports.getPrivilegedNamespaceProblem = getPrivilegedNamespaceProblem;
|
|
723
|
-
// What may mount a claim a run kept: the runs of the same
|
|
724
|
-
// cache,
|
|
725
|
-
//
|
|
739
|
+
// What may mount a claim a run kept: the runs of the same branch or tag of a repository,
|
|
740
|
+
// which share its cache, so that the runs of two branches go side by side and the runs of one find what
|
|
741
|
+
// the last one left; on a sandbox the runs of that sandbox only, whose claim is on the same
|
|
742
|
+
// node or zone as the kept ones. An approved run on a sandbox keeps nothing with those runs,
|
|
743
|
+
// whose outputs nobody approved, as its cache is apart from theirs: it has a scope of its own,
|
|
744
|
+
// per sandbox, so that approved runs on two sandboxes go side by side. The owner is the namespace's.
|
|
726
745
|
function getVolumeScope(run) {
|
|
727
746
|
if (run.source.type === 'sandbox' && !run.source.check) {
|
|
728
|
-
|
|
747
|
+
const id = (0, crypto_1.createHash)('sha256').update(run.source.id).digest('hex').slice(0, 24);
|
|
748
|
+
return (run.approvals?.length ?? 0) > 0 ? `approved-${id}` : `sandbox-${id}`;
|
|
749
|
+
}
|
|
750
|
+
// a ref given as a commit hash names no branch: its runs keep the repository's claims
|
|
751
|
+
if (run.source.type === 'ref' && !/^[0-9a-f]{40}([0-9a-f]{24})?$/i.test(run.source.ref)) {
|
|
752
|
+
const key = `ref\0${run.source.repo}\0${run.source.ref}`;
|
|
753
|
+
return `ref-${(0, crypto_1.createHash)('sha256').update(key).digest('hex').slice(0, 24)}`;
|
|
729
754
|
}
|
|
730
755
|
return (0, executor_1.cacheNamespace)(run);
|
|
731
756
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPushRefusal = exports.KubernetesSandboxStorage = exports.getSandboxNames = void 0;
|
|
3
|
+
exports.AnswerReader = exports.getPushRefusal = exports.KubernetesSandboxStorage = exports.getSandboxNames = void 0;
|
|
4
4
|
const crypto_1 = require("crypto");
|
|
5
5
|
const promises_1 = require("fs/promises");
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -542,7 +542,9 @@ class KubernetesSandboxStorage {
|
|
|
542
542
|
// the process ends when the server stops waiting for it: closing the connection does
|
|
543
543
|
// not end a command in a pod
|
|
544
544
|
const seconds = Math.ceil((['create', 'fetch', 'move', 'archive'].includes(request.op) ? FETCH_TIMEOUT_MS : REQUEST_TIMEOUT_MS) / 1000);
|
|
545
|
-
const done = this.withPod(key, (pod) => this.exec(pod, ['timeout', String(seconds), 'hammerkit', 'server-sandbox', CLAIM_PATH], stream_1.Readable.from([Buffer.from(JSON.stringify(encoded))]), reader,
|
|
545
|
+
const done = this.withPod(key, (pod) => this.exec(pod, ['timeout', String(seconds), 'hammerkit', 'server-sandbox', CLAIM_PATH], stream_1.Readable.from([Buffer.from(JSON.stringify(encoded))]), reader,
|
|
546
|
+
// a request that failed (an answer too large) stops the command too
|
|
547
|
+
AbortSignal.any([signal, reader.stopped])));
|
|
546
548
|
done.then(() => reader.complete(), (e) => reader.fail(e));
|
|
547
549
|
const answer = await reader.answer;
|
|
548
550
|
if (!answer.header.ok) {
|
|
@@ -911,16 +913,22 @@ function holdBack(socket, stdout) {
|
|
|
911
913
|
* memory, unless the first line says it is a stream: then it is passed on as it comes.
|
|
912
914
|
*/
|
|
913
915
|
class AnswerReader extends stream_1.Writable {
|
|
914
|
-
constructor(body) {
|
|
916
|
+
constructor(body, maxBytes = MAX_ANSWER_BYTES) {
|
|
915
917
|
super();
|
|
916
918
|
this.body = body;
|
|
919
|
+
this.maxBytes = maxBytes;
|
|
917
920
|
this.chunks = [];
|
|
918
921
|
this.size = 0;
|
|
922
|
+
this.stop = new AbortController();
|
|
923
|
+
// aborted once the answer failed: nothing reads the rest
|
|
924
|
+
this.stopped = this.stop.signal;
|
|
919
925
|
this.answer = new Promise((resolve, reject) => {
|
|
920
926
|
this.resolveAnswer = resolve;
|
|
921
927
|
this.rejectAnswer = reject;
|
|
922
928
|
});
|
|
923
929
|
this.answer.catch(() => undefined);
|
|
930
|
+
// an answer that is too large or no answer at all fails the request, not the server
|
|
931
|
+
this.on('error', (e) => this.fail(e));
|
|
924
932
|
}
|
|
925
933
|
_write(chunk, _encoding, callback) {
|
|
926
934
|
if (this.stream) {
|
|
@@ -933,7 +941,7 @@ class AnswerReader extends stream_1.Writable {
|
|
|
933
941
|
return;
|
|
934
942
|
}
|
|
935
943
|
this.size += chunk.length;
|
|
936
|
-
if (this.size >
|
|
944
|
+
if (this.size > this.maxBytes) {
|
|
937
945
|
callback(new Error('the answer of the pod of the sandbox is too large'));
|
|
938
946
|
return;
|
|
939
947
|
}
|
|
@@ -986,6 +994,7 @@ class AnswerReader extends stream_1.Writable {
|
|
|
986
994
|
}
|
|
987
995
|
}
|
|
988
996
|
fail(e) {
|
|
997
|
+
this.stop.abort();
|
|
989
998
|
const error = e instanceof Error ? e : new Error(String(e));
|
|
990
999
|
if (this.stream) {
|
|
991
1000
|
this.stream.destroy(error);
|
|
@@ -993,6 +1002,7 @@ class AnswerReader extends stream_1.Writable {
|
|
|
993
1002
|
this.rejectAnswer(error);
|
|
994
1003
|
}
|
|
995
1004
|
}
|
|
1005
|
+
exports.AnswerReader = AnswerReader;
|
|
996
1006
|
// The files of a sandbox on a cluster: each call is a request to the pod of its files.
|
|
997
1007
|
class KubernetesSandboxFiles {
|
|
998
1008
|
constructor(request, rawFile) {
|
package/dist/server/overview.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.visibleCapacity = exports.filterRuns = exports.FilterRefused = exports.parseRunFilter = exports.getOverview = exports.queuePlace = exports.visibleReason = exports.toListedRun = exports.mayRead = exports.seesActivityOf = exports.seesActivity = exports.maySee = exports.decides = exports.owns = exports.mayDecide = exports.runActions = exports.getViewer = exports.describeWait = void 0;
|
|
3
|
+
exports.visibleCapacity = exports.filterRuns = exports.FilterRefused = exports.parseRunFilter = exports.getOverview = exports.queuePlace = exports.visibleReason = exports.toListedRun = exports.mayRead = exports.seesActivityOf = exports.seesActivity = exports.maySee = exports.decides = exports.owns = exports.mayDecide = exports.mayRetry = exports.runActions = exports.getViewer = exports.describeWait = void 0;
|
|
4
4
|
const policy_1 = require("./policy");
|
|
5
5
|
const runs_1 = require("./runs");
|
|
6
6
|
const service_runs_1 = require("./service-runs");
|
|
@@ -19,7 +19,7 @@ function getViewer(config, principal) {
|
|
|
19
19
|
exports.getViewer = getViewer;
|
|
20
20
|
function runActions(viewer, run) {
|
|
21
21
|
if ((0, runs_1.isFinal)(run.state)) {
|
|
22
|
-
return undefined;
|
|
22
|
+
return mayRetry(viewer, run) ? { retry: true } : undefined;
|
|
23
23
|
}
|
|
24
24
|
const mine = owns(viewer, run);
|
|
25
25
|
const may = {
|
|
@@ -35,6 +35,24 @@ function runActions(viewer, run) {
|
|
|
35
35
|
return Object.keys(may).length > 0 ? may : undefined;
|
|
36
36
|
}
|
|
37
37
|
exports.runActions = runActions;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the caller may start a run again, as far as the run tells: it is over, they read it
|
|
40
|
+
* whole (what a retry runs again is what they read, its arguments too), they may run anything,
|
|
41
|
+
* and from where it ran: a repository of their entitlements, or a sandbox of their own. Which
|
|
42
|
+
* accounts they may use, and whether they need an approval, is decided when they retry it.
|
|
43
|
+
*/
|
|
44
|
+
function mayRetry(viewer, run) {
|
|
45
|
+
if (!(0, runs_1.isFinal)(run.state) || !mayRead(viewer, run) || !(0, policy_1.mayRun)(viewer.grant)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (run.source.type === 'ref') {
|
|
49
|
+
return (0, repo_1.matchesAnyRepo)(viewer.grant.repos, run.source.repo);
|
|
50
|
+
}
|
|
51
|
+
// a sandbox is its owner's, while they may still keep sandboxes of its repository
|
|
52
|
+
const repo = run.source.type === 'sandbox' ? run.source.repo : undefined;
|
|
53
|
+
return (repo !== undefined && owns(viewer, run) && viewer.grant.sandboxes.some((sandbox) => (0, repo_1.matchesRepo)(sandbox.repo, repo)));
|
|
54
|
+
}
|
|
55
|
+
exports.mayRetry = mayRetry;
|
|
38
56
|
// A run that waits for an approval the caller may give: not their own.
|
|
39
57
|
function mayDecide(viewer, run) {
|
|
40
58
|
return (run.state === 'awaiting-approval' &&
|
package/dist/server/plan.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inspectBundle = exports.planBundle = exports.getCredentialReads = exports.PLAIN_SERVER_ENVS = exports.DefinitionError = void 0;
|
|
3
|
+
exports.inspectBundle = exports.planBundle = exports.getCredentialReads = exports.withSymbolicValues = exports.PLAIN_SERVER_ENVS = exports.DefinitionError = void 0;
|
|
4
4
|
const promises_1 = require("fs/promises");
|
|
5
5
|
const os_1 = require("os");
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -18,12 +18,24 @@ const log_1 = require("../log");
|
|
|
18
18
|
const parse_error_1 = require("../schema/parse-error");
|
|
19
19
|
const task_arguments_1 = require("../planner/utils/task-arguments");
|
|
20
20
|
const work_network_1 = require("../planner/work-network");
|
|
21
|
+
const run_source_envs_1 = require("../environment/run-source-envs");
|
|
21
22
|
class DefinitionError extends Error {
|
|
22
23
|
}
|
|
23
24
|
exports.DefinitionError = DefinitionError;
|
|
24
25
|
// Variables of a server that hold no credential (FR-008): a task may read these and
|
|
25
|
-
// still take arguments, or reach any network.
|
|
26
|
-
exports.PLAIN_SERVER_ENVS = ['PATH', 'HOME', 'CI'];
|
|
26
|
+
// still take arguments, or reach any network. The ones of the run's source are set for each run.
|
|
27
|
+
exports.PLAIN_SERVER_ENVS = ['PATH', 'HOME', 'CI', ...run_source_envs_1.RUN_SOURCE_ENVS];
|
|
28
|
+
// The environment of runs as a build file is read before anybody runs it (a publish, a
|
|
29
|
+
// proposal, POST /v1/definitions/plan): each variable but the plain ones stands for its name,
|
|
30
|
+
// `${NAME}`. What the server answers about a build file, a description or an image that reads
|
|
31
|
+
// `$NAME` included, then never holds a value a run would see. The tasks of a run read the values.
|
|
32
|
+
function withSymbolicValues(processEnvs) {
|
|
33
|
+
return Object.fromEntries(Object.entries(processEnvs).map(([name, value]) => [
|
|
34
|
+
name,
|
|
35
|
+
value === undefined || exports.PLAIN_SERVER_ENVS.includes(name.toUpperCase()) ? value : `\${${name}}`,
|
|
36
|
+
]));
|
|
37
|
+
}
|
|
38
|
+
exports.withSymbolicValues = withSymbolicValues;
|
|
27
39
|
// What an item holds that its command must not hand out: its secrets, and the variables
|
|
28
40
|
// of the server its `envs` read, but the plain ones.
|
|
29
41
|
function getCredentialReads(item) {
|
|
@@ -200,6 +212,12 @@ function findItemPolicyProblems(item, policy, root) {
|
|
|
200
212
|
? `which this server does not allow (${from}: ${policy.capabilities.join(', ')})`
|
|
201
213
|
: `and this server allows none (${from})`));
|
|
202
214
|
}
|
|
215
|
+
// BuildKit adds SYS_ADMIN and reads the files of the run; on a server's docker host a task
|
|
216
|
+
// that adds capabilities may bind none of them (refuseUncheckableBinds), so a server builds
|
|
217
|
+
// images only on a cluster for now
|
|
218
|
+
if (policy.backend === 'host' && (0, work_task_1.isWorkTask)(data) && 'build' in data && data.build) {
|
|
219
|
+
problems.push(`${item.name}: builds an image, which a server builds only with a kubernetes backend for now (backend.type: host)`);
|
|
220
|
+
}
|
|
203
221
|
// what a task reads and writes is the bundle's: `src: ../..` would have the server
|
|
204
222
|
// copy its own files (its credentials, other callers' caches) into the task
|
|
205
223
|
for (const source of 'src' in data ? data.src : []) {
|
|
@@ -255,6 +273,15 @@ function findItemPolicyProblems(item, policy, root) {
|
|
|
255
273
|
problems.push(`${item.name}: volume ${volume.name} is not a volume name, a path of the server can't be mounted`);
|
|
256
274
|
}
|
|
257
275
|
}
|
|
276
|
+
if (policy.readableEnvs) {
|
|
277
|
+
const allowed = policy.readableEnvs;
|
|
278
|
+
const refusedEnvs = ('envs' in data ? data.envs.processNames ?? [] : []).filter((name) => !exports.PLAIN_SERVER_ENVS.includes(name.toUpperCase()) && !allowed.includes(name));
|
|
279
|
+
if (refusedEnvs.length > 0) {
|
|
280
|
+
problems.push(`${item.name}: reads ${refusedEnvs
|
|
281
|
+
.map((name) => `$${name}`)
|
|
282
|
+
.join(', ')} of the server, which it does not list in ${policy.envsFrom ?? 'runs.env.allow'}`);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
258
285
|
for (const secret of secretsOf(item)) {
|
|
259
286
|
const source = secret.source;
|
|
260
287
|
if (policy.backend === 'kubernetes' && source.type === 'provider') {
|
|
@@ -340,6 +367,7 @@ function toPlan(root, item) {
|
|
|
340
367
|
deps: item.deps.map((dep) => dep.name).sort(),
|
|
341
368
|
// by their names in the plan, not the names the task reaches them at (`postgres` of an include)
|
|
342
369
|
needs: item.needs.map((need) => need.service.name).sort(),
|
|
370
|
+
...((0, work_service_1.isContainerWorkService)(data) && data.init ? { init: data.init.task.name } : {}),
|
|
343
371
|
accounts,
|
|
344
372
|
secrets,
|
|
345
373
|
serverEnvs: 'envs' in data ? data.envs.processNames ?? [] : [],
|
package/dist/server/policy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decideRun = exports.sandboxRepos = exports.decideSandbox = exports.sandboxPushBranches = exports.sandboxBranchType = exports.endpointLevel = exports.getGrant = exports.usedAccounts = exports.mayYank = exports.canUse = exports.maySeeDefinitions = exports.mayPublish = exports.mayPropose = exports.mayReadChecks = exports.mayRun = exports.matches = exports.subjectName = void 0;
|
|
3
|
+
exports.decideRun = exports.sandboxRepos = exports.decideSandbox = exports.sandboxPushBranches = exports.sandboxBranchType = exports.endpointLevel = exports.getGrant = exports.usedAccounts = exports.mayYank = exports.accountLevel = exports.canUse = exports.maySeeDefinitions = exports.mayPublish = exports.mayPropose = exports.mayReadChecks = exports.mayRun = exports.matches = exports.subjectName = void 0;
|
|
4
4
|
const repo_1 = require("./repo");
|
|
5
5
|
const BUILDS_ORDER = ['run', 'propose', 'publish'];
|
|
6
6
|
// The name an entitlement gives a subject, for the pages to name its runs by when its tokens
|
|
@@ -47,9 +47,15 @@ function maySeeDefinitions(grant) {
|
|
|
47
47
|
exports.maySeeDefinitions = maySeeDefinitions;
|
|
48
48
|
// `use` includes deciding about the runs others request on the account.
|
|
49
49
|
function canUse(grant, account) {
|
|
50
|
-
return grant
|
|
50
|
+
return accountLevel(grant, account) === 'use';
|
|
51
51
|
}
|
|
52
52
|
exports.canUse = canUse;
|
|
53
|
+
// The level the caller has for an account, only when an entitlement names it: an account
|
|
54
|
+
// called `constructor` or `toString` is not found on the prototype of the record.
|
|
55
|
+
function accountLevel(grant, account) {
|
|
56
|
+
return Object.prototype.hasOwnProperty.call(grant.accounts, account) ? grant.accounts[account] : undefined;
|
|
57
|
+
}
|
|
58
|
+
exports.accountLevel = accountLevel;
|
|
53
59
|
// Pulling a version back is a safe thing to do, so it is open to who publishes the build
|
|
54
60
|
// file, and to who uses an account the version works with: they are the ones who
|
|
55
61
|
// answer for what runs as it.
|
|
@@ -58,13 +64,14 @@ function mayYank(grant, version) {
|
|
|
58
64
|
}
|
|
59
65
|
exports.mayYank = mayYank;
|
|
60
66
|
function usedAccounts(grant) {
|
|
61
|
-
return Object.keys(grant.accounts).filter((account) => grant
|
|
67
|
+
return Object.keys(grant.accounts).filter((account) => canUse(grant, account));
|
|
62
68
|
}
|
|
63
69
|
exports.usedAccounts = usedAccounts;
|
|
64
70
|
// Default deny: a caller without a matching entitlement gets nothing.
|
|
65
71
|
function getGrant(entitlements, principal) {
|
|
66
72
|
const matched = [];
|
|
67
|
-
|
|
73
|
+
// no prototype: an account named like one of its properties (`__proto__`) is a key like any other
|
|
74
|
+
const accounts = Object.create(null);
|
|
68
75
|
const repos = [];
|
|
69
76
|
const sandboxes = [];
|
|
70
77
|
const endpoints = [];
|
|
@@ -79,7 +86,7 @@ function getGrant(entitlements, principal) {
|
|
|
79
86
|
checks = checks || entitlement.checks === 'read';
|
|
80
87
|
observe = observe || entitlement.observe === true;
|
|
81
88
|
for (const [account, level] of Object.entries(entitlement.accounts)) {
|
|
82
|
-
if (accounts
|
|
89
|
+
if (accountLevel({ accounts }, account) !== 'use') {
|
|
83
90
|
accounts[account] = level;
|
|
84
91
|
}
|
|
85
92
|
}
|
|
@@ -233,11 +240,11 @@ function decideRun(input) {
|
|
|
233
240
|
}
|
|
234
241
|
const request = [];
|
|
235
242
|
for (const account of accounts) {
|
|
236
|
-
const level = grant
|
|
243
|
+
const level = accountLevel(grant, account);
|
|
237
244
|
if (level === undefined) {
|
|
238
245
|
return { type: 'refuse', status: 403, error: `you may not use the account ${account}, it needs use or request` };
|
|
239
246
|
}
|
|
240
|
-
const rules = catalog[account];
|
|
247
|
+
const rules = Object.prototype.hasOwnProperty.call(catalog, account) ? catalog[account] : undefined;
|
|
241
248
|
// a sandbox holds changes nobody reviewed: an account takes its runs only when it says so
|
|
242
249
|
const sources = rules?.source ?? ['ref', 'upload'];
|
|
243
250
|
if (!sources.includes(source.type)) {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RepoAccess = void 0;
|
|
4
4
|
const redact_1 = require("../utils/redact");
|
|
5
5
|
const provider_values_1 = require("../secrets/provider-values");
|
|
6
|
+
const secret_catalog_1 = require("../secrets/secret-catalog");
|
|
6
7
|
const git_checkout_1 = require("./git-checkout");
|
|
7
8
|
const repo_1 = require("./repo");
|
|
8
9
|
// A token is read again after this long, so a short-lived one (a GitHub App
|
|
@@ -119,9 +120,9 @@ class RepoAccess {
|
|
|
119
120
|
const catalog = this.environment.hosted?.catalog;
|
|
120
121
|
const kind = secret.from.substring(0, secret.from.indexOf(':'));
|
|
121
122
|
const ref = secret.from.substring(secret.from.indexOf(':') + 1);
|
|
122
|
-
const provider = catalog.providers
|
|
123
|
-
const account = catalog.accounts
|
|
124
|
-
const credentials = account
|
|
123
|
+
const provider = (0, secret_catalog_1.declared)(catalog.providers, kind);
|
|
124
|
+
const account = (0, secret_catalog_1.declared)(catalog.accounts, secret.account);
|
|
125
|
+
const credentials = account ? (0, secret_catalog_1.declared)(account.providers, kind) : undefined;
|
|
125
126
|
if (!provider || !credentials) {
|
|
126
127
|
throw new Error(`the source credential ${secret.from} as ${secret.account} is not defined`);
|
|
127
128
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runEnvironment = void 0;
|
|
4
|
+
const run_source_envs_1 = require("../environment/run-source-envs");
|
|
4
5
|
// What a run sees of the server's environment: the variables the operator listed
|
|
5
6
|
// in `runs.env.allow`, and the fixed ones of `runs.env.set`. The credentials of a
|
|
6
|
-
// run are not among them, they exist only as the secrets of an account.
|
|
7
|
+
// run are not among them, they exist only as the secrets of an account. The variables of
|
|
8
|
+
// what a run is from are the run's own (the config refuses them, see run-source-envs.ts).
|
|
7
9
|
function runEnvironment(config, processEnvs) {
|
|
8
10
|
const passed = {};
|
|
9
11
|
for (const name of config.runs.env.allow) {
|
|
@@ -14,7 +16,8 @@ function runEnvironment(config, processEnvs) {
|
|
|
14
16
|
passed[name] = processEnvs[key];
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
const all = { ...passed, ...config.runs.env.set };
|
|
20
|
+
return Object.fromEntries(Object.entries(all).filter(([name]) => !(0, run_source_envs_1.isRunSourceEnv)(name)));
|
|
18
21
|
}
|
|
19
22
|
exports.runEnvironment = runEnvironment;
|
|
20
23
|
//# sourceMappingURL=run-environment.js.map
|
package/dist/server/run-plan.js
CHANGED
|
@@ -6,7 +6,8 @@ const plan_1 = require("./plan");
|
|
|
6
6
|
function labels(values) {
|
|
7
7
|
return values && values.length > 0 ? (0, parse_label_arguments_1.parseLabelArguments)(values) : undefined;
|
|
8
8
|
}
|
|
9
|
-
// The tasks
|
|
9
|
+
// The tasks named, as one scope: they are planned together and run side by side as far
|
|
10
|
+
// as their dependencies allow, in no particular order; by labels when none is named. A
|
|
10
11
|
// service run is one scope of its services.
|
|
11
12
|
// The arguments, if any, go to the one task named (the request allows no more). That
|
|
12
13
|
// task runs uncached unless the request names a `cache` method, as `run --cache` does.
|
|
@@ -17,11 +18,22 @@ function getRunScopes(tasks, options, services = []) {
|
|
|
17
18
|
const args = options.args && options.args.length > 0
|
|
18
19
|
? { values: options.args, services: false, cache: options.cache !== undefined }
|
|
19
20
|
: undefined;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const named = [...new Set(tasks)];
|
|
22
|
+
if (named.length === 1) {
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
name: named[0],
|
|
26
|
+
scope: { taskName: named[0], environmentName: options.env ?? null, ...(args ? { args } : {}) },
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
return named.length > 0
|
|
31
|
+
? [
|
|
32
|
+
{
|
|
33
|
+
name: named.join(', '),
|
|
34
|
+
scope: { taskNames: named, environmentName: options.env ?? null, ...(args ? { args } : {}) },
|
|
35
|
+
},
|
|
36
|
+
]
|
|
25
37
|
: [
|
|
26
38
|
{
|
|
27
39
|
name: 'labels',
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRetryRequest = void 0;
|
|
4
|
+
const runs_1 = require("./runs");
|
|
5
|
+
const run_request_1 = require("./run-request");
|
|
6
|
+
/**
|
|
7
|
+
* A retry (`POST /v1/runs/<id>/retry`) is the request the run was started with, sent again by
|
|
8
|
+
* who retries it: the same published build file, tasks or services, settings and arguments,
|
|
9
|
+
* from the same source. A run from a branch runs the commit it ran: the server refuses the
|
|
10
|
+
* retry once the branch moved on, so the accounts of a branch never run a commit that is no
|
|
11
|
+
* longer on it. A run on a sandbox runs on the files the sandbox holds now, the work of its
|
|
12
|
+
* owner, who alone may retry it.
|
|
13
|
+
*
|
|
14
|
+
* It names every task the run named, not only those that failed: the tasks that passed are
|
|
15
|
+
* read from the cache, and a run that was stopped or rejected has no failed ones to tell.
|
|
16
|
+
*/
|
|
17
|
+
function getRetryRequest(run, owner) {
|
|
18
|
+
if (!(0, runs_1.isFinal)(run.state)) {
|
|
19
|
+
return { error: `${run.id} is ${run.state}, a run is retried once it is over` };
|
|
20
|
+
}
|
|
21
|
+
let source;
|
|
22
|
+
if (run.source.type === 'ref') {
|
|
23
|
+
source = { type: 'ref', repo: run.source.repo, ref: run.source.ref, commit: run.source.commit };
|
|
24
|
+
}
|
|
25
|
+
else if (run.source.type === 'sandbox') {
|
|
26
|
+
// a sandbox is its owner's: nobody else may run from it
|
|
27
|
+
if (!owner) {
|
|
28
|
+
return { error: `${run.id} ran from a sandbox of its owner, only they may retry it` };
|
|
29
|
+
}
|
|
30
|
+
source = { type: 'sandbox', id: run.source.id, ...(run.source.check ? { check: true } : {}) };
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return { error: `${run.id} ran from uploaded files, which a run is not retried from` };
|
|
34
|
+
}
|
|
35
|
+
const parsed = run_request_1.runRequestSchema.safeParse({
|
|
36
|
+
definition: run.definition,
|
|
37
|
+
tasks: run.tasks,
|
|
38
|
+
source,
|
|
39
|
+
options: run.options ?? {},
|
|
40
|
+
...(run.up
|
|
41
|
+
? {
|
|
42
|
+
services: run.up.services,
|
|
43
|
+
ttl: `${run.up.ttl}ms`,
|
|
44
|
+
...(run.up.sleepTtl ? { sleepTtl: `${run.up.sleepTtl}ms` } : {}),
|
|
45
|
+
name: run.up.name,
|
|
46
|
+
endpoints: run.up.endpoints.map(({ service, port }) => ({ service, port })),
|
|
47
|
+
}
|
|
48
|
+
: {}),
|
|
49
|
+
});
|
|
50
|
+
if (!parsed.success) {
|
|
51
|
+
const issue = parsed.error.issues[0];
|
|
52
|
+
return { error: `${run.id} can not be started again: ${issue.path.join('.') || 'request'}: ${issue.message}` };
|
|
53
|
+
}
|
|
54
|
+
return { request: parsed.data };
|
|
55
|
+
}
|
|
56
|
+
exports.getRetryRequest = getRetryRequest;
|
|
57
|
+
//# sourceMappingURL=run-retry.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runPlanningEnvironment = exports.withRunSource = exports.runSourceEnvironment = exports.RUN_SOURCE_ENVS = void 0;
|
|
4
|
+
const run_source_envs_1 = require("../environment/run-source-envs");
|
|
5
|
+
Object.defineProperty(exports, "RUN_SOURCE_ENVS", { enumerable: true, get: function () { return run_source_envs_1.RUN_SOURCE_ENVS; } });
|
|
6
|
+
// a ref may name a commit, which is no branch or tag (see git-checkout.ts)
|
|
7
|
+
const COMMIT = /^[0-9a-f]{40}([0-9a-f]{24})?$/i;
|
|
8
|
+
// What a run is from, for the `envs` of its tasks and services (`$HAMMERKIT_RUN_REF`): the
|
|
9
|
+
// repository, and the branch or tag and the commit it was pinned to, or the repository and the
|
|
10
|
+
// sandbox. None of them is a credential, so a task that reads them still takes arguments and
|
|
11
|
+
// keeps its network (see PLAIN_SERVER_ENVS). A sandbox has no commit: its files may hold
|
|
12
|
+
// changes. A run from an upload has none of them.
|
|
13
|
+
function runSourceEnvironment(source) {
|
|
14
|
+
if (source.type === 'ref') {
|
|
15
|
+
return {
|
|
16
|
+
HAMMERKIT_RUN_REPO: source.repo,
|
|
17
|
+
...(COMMIT.test(source.ref) ? {} : { HAMMERKIT_RUN_REF: source.ref }),
|
|
18
|
+
...(source.commit ? { HAMMERKIT_RUN_COMMIT: source.commit } : {}),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (source.type === 'sandbox') {
|
|
22
|
+
return { HAMMERKIT_RUN_REPO: source.repo, HAMMERKIT_RUN_SANDBOX: source.id };
|
|
23
|
+
}
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
exports.runSourceEnvironment = runSourceEnvironment;
|
|
27
|
+
// The variables of a process, and the run's own in place of any of the same name, in any case.
|
|
28
|
+
function withRunSource(envs, source) {
|
|
29
|
+
const kept = Object.fromEntries(Object.entries(envs).filter(([name]) => !(0, run_source_envs_1.isRunSourceEnv)(name)));
|
|
30
|
+
return { ...kept, ...runSourceEnvironment(source) };
|
|
31
|
+
}
|
|
32
|
+
exports.withRunSource = withRunSource;
|
|
33
|
+
// The environment a run's files are read with, on the server, before its process starts: so
|
|
34
|
+
// the plan an approver reads shows what the tasks will see.
|
|
35
|
+
function runPlanningEnvironment(environment, source) {
|
|
36
|
+
return { ...environment, processEnvs: withRunSource(environment.processEnvs, source) };
|
|
37
|
+
}
|
|
38
|
+
exports.runPlanningEnvironment = runPlanningEnvironment;
|
|
39
|
+
//# sourceMappingURL=run-source-environment.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.workerMain = exports.readInput = exports.taskCommands = exports.taskCauses = exports.describeFailures = exports.runTasks = exports.getEndpointTargets = exports.publishEndpoints = exports.getRunNetwork = exports.workerInputSchema = void 0;
|
|
3
|
+
exports.workerMain = exports.readInput = exports.taskCommands = exports.taskCauses = exports.describeFailures = exports.failedTasks = exports.runTasks = exports.getEndpointTargets = exports.publishEndpoints = exports.getRunNetwork = exports.workerInputSchema = void 0;
|
|
4
4
|
const readline_1 = require("readline");
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
const cli_1 = require("../cli");
|
|
@@ -80,6 +80,8 @@ exports.workerInputSchema = zod_1.z
|
|
|
80
80
|
.optional(),
|
|
81
81
|
// the run's results count as checks: report each task's check key before it runs
|
|
82
82
|
check: zod_1.z.boolean().optional(),
|
|
83
|
+
// what its tasks took in past runs, in ms by name, so the longest chain starts first
|
|
84
|
+
durations: zod_1.z.record(zod_1.z.number().nonnegative()).optional(),
|
|
83
85
|
})
|
|
84
86
|
.strict();
|
|
85
87
|
// The ceiling of the run, combined here and not in the server: the lower of two allow lists
|
|
@@ -206,6 +208,7 @@ up) {
|
|
|
206
208
|
maxTimeout: options.maxTimeout ? (0, units_1.parseDuration)(options.maxTimeout) : null,
|
|
207
209
|
skipDeps: options.skipDeps !== false,
|
|
208
210
|
network: getRunNetwork(input),
|
|
211
|
+
...(input.durations ? { durations: input.durations } : {}),
|
|
209
212
|
// why a task was not taken from the cache goes into its result
|
|
210
213
|
explain: true,
|
|
211
214
|
};
|
|
@@ -214,17 +217,25 @@ up) {
|
|
|
214
217
|
// the files as they are before any task wrote to them, a second task's too: a first
|
|
215
218
|
// one that formats or generates into src would key it by files no commit holds
|
|
216
219
|
for (const { scope } of scopes) {
|
|
217
|
-
for (const [task, { key }] of Object.entries(await (0, check_keys_1.getCheckKeys)(input.entry, environment, scope))) {
|
|
220
|
+
for (const [task, { key }] of Object.entries(await (0, check_keys_1.getCheckKeys)(input.entry, environment, scope, input.directory))) {
|
|
218
221
|
emit({ type: 'key', task, key });
|
|
219
222
|
}
|
|
220
223
|
}
|
|
221
224
|
}
|
|
222
|
-
|
|
225
|
+
// every scope is planned before any task runs: what the run executes is read from the
|
|
226
|
+
// published files as they were when it started, whatever a task does to its files
|
|
227
|
+
const planned = [];
|
|
223
228
|
for (const { name, scope } of scopes) {
|
|
224
229
|
const { ctx, scope: parsed } = await (0, schema_parser_1.createParseContext)(input.entry, environment, {
|
|
225
230
|
directory: input.directory,
|
|
226
231
|
});
|
|
227
|
-
|
|
232
|
+
planned.push({
|
|
233
|
+
name,
|
|
234
|
+
workTree: (0, work_scope_parser_1.getWorkContext)(await (0, reference_parser_1.parseReferences)(ctx, parsed, environment), scope, environment),
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
let started = false;
|
|
238
|
+
for (const { name, workTree } of planned) {
|
|
228
239
|
await (0, assert_item_paths_1.assertWorkTreePathsWithinRoot)(workTree, work);
|
|
229
240
|
if (input.volumeScope && !input.kubernetes) {
|
|
230
241
|
(0, hosted_volumes_1.scopeServiceVolumes)(workTree, input.volumeScope);
|
|
@@ -236,9 +247,9 @@ up) {
|
|
|
236
247
|
if (cli.tasks().length === 0 && (!input.up || cli.services().length === 0)) {
|
|
237
248
|
throw new Error(`no tasks found for ${name}`);
|
|
238
249
|
}
|
|
239
|
-
if (!
|
|
250
|
+
if (!started) {
|
|
240
251
|
// from the start of this process, which the executor started for the run
|
|
241
|
-
|
|
252
|
+
started = true;
|
|
242
253
|
emit({
|
|
243
254
|
type: 'phase',
|
|
244
255
|
phase: 'plan',
|
|
@@ -273,14 +284,19 @@ up) {
|
|
|
273
284
|
if (input.kubernetes.server?.serviceRun) {
|
|
274
285
|
// a run that moved here from another commit: what it made for items it has no more
|
|
275
286
|
const ids = [...Object.values(workTree.tasks), ...Object.values(workTree.services)].map((item) => item.id());
|
|
276
|
-
await (0, remove_stale_items_1.removeStaleItems)((0, kubernetes_instance_1.createKubernetesInstances)(input.kubernetes), input.kubernetes, ids
|
|
287
|
+
await (0, remove_stale_items_1.removeStaleItems)((0, kubernetes_instance_1.createKubernetesInstances)(input.kubernetes), input.kubernetes, ids, {
|
|
288
|
+
signal: abortCtrl.signal,
|
|
289
|
+
}).catch((e) => emit({
|
|
277
290
|
type: 'log',
|
|
278
291
|
task: 'hammerkit',
|
|
279
292
|
stream: 'stderr',
|
|
280
293
|
text: `what the run made at its previous commit could not be removed: ${(0, log_1.getErrorMessage)(e)}`,
|
|
281
294
|
}));
|
|
282
295
|
}
|
|
283
|
-
|
|
296
|
+
// stopped while the old pods ended, or up until it is stopped
|
|
297
|
+
if (!abortCtrl.signal.aborted) {
|
|
298
|
+
await new Promise((resolve) => abortCtrl.signal.addEventListener('abort', () => resolve(), { once: true }));
|
|
299
|
+
}
|
|
284
300
|
return;
|
|
285
301
|
}
|
|
286
302
|
if (input.up && ready) {
|
|
@@ -299,7 +315,7 @@ up) {
|
|
|
299
315
|
}
|
|
300
316
|
// a service run names what failed and why: its services have no results of their own
|
|
301
317
|
const failures = input.up ? describeFailures(execution.state.current, (text) => secrets.redact(text)) : [];
|
|
302
|
-
throw new Error(failures.length > 0 ? failures.join('; ').slice(0, runs_1.MAX_TASK_ERROR) : `${name} failed`);
|
|
318
|
+
throw new Error(failures.length > 0 ? failures.join('; ').slice(0, runs_1.MAX_TASK_ERROR) : `${failedTasks(workTree, name)} failed`);
|
|
303
319
|
}
|
|
304
320
|
}
|
|
305
321
|
finally {
|
|
@@ -363,6 +379,19 @@ function lastError(item) {
|
|
|
363
379
|
}
|
|
364
380
|
return last;
|
|
365
381
|
}
|
|
382
|
+
// Of several tasks named, the ones that failed: those named first, else the dependencies
|
|
383
|
+
// that failed under them. One task named is the run's name, as before.
|
|
384
|
+
function failedTasks(workTree, name) {
|
|
385
|
+
const requested = workTree.requested ?? [];
|
|
386
|
+
if (requested.length < 2) {
|
|
387
|
+
return name;
|
|
388
|
+
}
|
|
389
|
+
const failed = [...(0, plan_work_tasks_1.iterateWorkTasks)(workTree)].filter((task) => task.state.current.type === 'error' || task.state.current.type === 'crash');
|
|
390
|
+
const named = failed.filter((task) => requested.includes(task.name));
|
|
391
|
+
const names = (named.length > 0 ? named : failed).map((task) => task.name);
|
|
392
|
+
return names.length > 0 ? names.join(', ') : name;
|
|
393
|
+
}
|
|
394
|
+
exports.failedTasks = failedTasks;
|
|
366
395
|
/**
|
|
367
396
|
* What failed in a run, one line each, for its error: the services and tasks that failed,
|
|
368
397
|
* with their reason. Those that only stopped because another failed are left out.
|