hammerkit 2.2.0-next.1 → 2.2.0-next.3
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/cache/backends/registry/push-credentials.js +50 -0
- package/dist/cache/backends/registry/registry-client.js +41 -10
- package/dist/cache/backends/registry-cache-backend.js +6 -1
- package/dist/cache/cache-inventory.js +3 -0
- package/dist/dashboard/assets/{graph-canvas-D6GMgkoe.js → graph-canvas-D2f3lNda.js} +1 -1
- package/dist/dashboard/assets/{index-BNq9j5Jo.js → index-DE3NTbjw.js} +4 -4
- package/dist/dashboard/index.html +1 -1
- package/dist/executer/deadline.js +2 -3
- package/dist/executer/event-cache.js +2 -0
- package/dist/executer/execute-work-task.js +8 -0
- package/dist/remote/remote-status.js +2 -3
- package/dist/remote/remote-work-commands.js +16 -6
- package/dist/server/cache-push.js +50 -0
- package/dist/server/executor.js +15 -2
- package/dist/server/plan.js +38 -7
- package/dist/server/proposal-store.js +94 -0
- package/dist/server/proposals-api.js +3 -0
- package/dist/server/proposals.js +168 -19
- package/dist/server/run-worker.js +40 -9
- package/dist/server/runs.js +23 -18
- package/dist/server/server-config.js +66 -2
- package/dist/server/server.js +37 -3
- package/dist/utils/long-timer.js +33 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.workerMain = exports.readInput = exports.ChangeQueue = exports.applyChanges = exports.parseChanges = exports.syncLine = exports.syncServices = exports.taskCommands = exports.taskCauses = exports.describeFailures = exports.failedTasks = exports.runTasks = exports.relayStatus = exports.removeCommandsOfRun = exports.getRunnerCommands = exports.getLogEvent = exports.getEndpointTargets = exports.publishEndpoints = exports.getRunNetwork = exports.workerInputSchema = void 0;
|
|
3
|
+
exports.workerMain = exports.readInput = exports.ChangeQueue = exports.applyChanges = exports.parseChanges = exports.syncLine = exports.syncServices = exports.taskCommands = exports.taskCauses = exports.describeFailures = exports.failedTasks = exports.runTasks = exports.relayStatus = exports.getRunHosted = exports.createRunSecrets = exports.removeCommandsOfRun = exports.getRunnerCommands = exports.getLogEvent = 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");
|
|
@@ -63,6 +63,19 @@ exports.workerInputSchema = zod_1.z
|
|
|
63
63
|
// on the server's docker host, the runtime a container that adds capabilities runs in
|
|
64
64
|
// (`backend.capabilities.runtime`)
|
|
65
65
|
capabilityRuntime: zod_1.z.string().min(1).optional(),
|
|
66
|
+
// the server's credential to write a registry cache with, for a trusted run only (`cache.push`,
|
|
67
|
+
// see cache-push.ts); left out for any other run, which may only read the caches
|
|
68
|
+
cachePush: zod_1.z
|
|
69
|
+
.object({
|
|
70
|
+
repository: zod_1.z.string().min(1),
|
|
71
|
+
username: zod_1.z.string().min(1),
|
|
72
|
+
password: zod_1.z.string().min(1),
|
|
73
|
+
})
|
|
74
|
+
.strict()
|
|
75
|
+
.optional(),
|
|
76
|
+
// the registry hosts the run may read its caches from (`cache.registries`, and each `cache.push`
|
|
77
|
+
// rule's registry): a build file's cache of any other is refused
|
|
78
|
+
cacheRegistries: zod_1.z.array(zod_1.z.string().min(1)).optional(),
|
|
66
79
|
// the most any task or service reaches besides its needs, as `--network`: `runs.network`
|
|
67
80
|
network: network_schema_1.networkSchema.optional(),
|
|
68
81
|
// for a run on a sandbox, `sandboxes.network`: the run gets the lower of the two
|
|
@@ -229,6 +242,30 @@ async function removeCommandsOfRun(input, commands, emit) {
|
|
|
229
242
|
}
|
|
230
243
|
}
|
|
231
244
|
exports.removeCommandsOfRun = removeCommandsOfRun;
|
|
245
|
+
// The secrets of a run, masked in what it logs: the password of its cache push, as a secret of a
|
|
246
|
+
// task is (ADR-0010).
|
|
247
|
+
function createRunSecrets(input) {
|
|
248
|
+
const secrets = (0, redact_1.createSecretRegistry)();
|
|
249
|
+
if (input.cachePush) {
|
|
250
|
+
secrets.register(input.cachePush.password);
|
|
251
|
+
}
|
|
252
|
+
return secrets;
|
|
253
|
+
}
|
|
254
|
+
exports.createRunSecrets = createRunSecrets;
|
|
255
|
+
// What the engine of a run knows of its server: the credential to write a cache with, and the
|
|
256
|
+
// registries it may read, which only a server run has (see HostedPolicy).
|
|
257
|
+
function getRunHosted(input, commands) {
|
|
258
|
+
return {
|
|
259
|
+
catalog: input.catalog,
|
|
260
|
+
accounts: input.accounts,
|
|
261
|
+
kubernetes: input.kubernetes,
|
|
262
|
+
capabilityRuntime: input.capabilityRuntime,
|
|
263
|
+
runnerCommands: commands,
|
|
264
|
+
cacheRegistries: input.cacheRegistries ?? [],
|
|
265
|
+
...(input.cachePush ? { cachePush: input.cachePush } : {}),
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
exports.getRunHosted = getRunHosted;
|
|
232
269
|
// What a task says in the process of a run, as events: the lines it prints (with where the log
|
|
233
270
|
// of its pod got to) and its warnings and errors, in the order they come. The `output` events
|
|
234
271
|
// of the commands in a runner are emitted after the lines they count, on the same way (see
|
|
@@ -257,7 +294,7 @@ commands = getRunnerCommands(input, emit),
|
|
|
257
294
|
// a service run: hands the changed files of its sandbox to the services that are up while
|
|
258
295
|
// they are up (undefined once they are not)
|
|
259
296
|
register) {
|
|
260
|
-
const secrets = (
|
|
297
|
+
const secrets = createRunSecrets(input);
|
|
261
298
|
const status = (0, work_item_status_1.statusConsole)((0, empty_writable_1.emptyWritable)(), secrets);
|
|
262
299
|
// the process starts in a directory of the server, the tasks work on the run's files
|
|
263
300
|
const work = input.directory?.work ?? cwd;
|
|
@@ -265,13 +302,7 @@ register) {
|
|
|
265
302
|
// is what is streamed: it is redacted with the secrets of this run
|
|
266
303
|
const environment = {
|
|
267
304
|
processEnvs,
|
|
268
|
-
hosted:
|
|
269
|
-
catalog: input.catalog,
|
|
270
|
-
accounts: input.accounts,
|
|
271
|
-
kubernetes: input.kubernetes,
|
|
272
|
-
capabilityRuntime: input.capabilityRuntime,
|
|
273
|
-
runnerCommands: commands,
|
|
274
|
-
},
|
|
305
|
+
hosted: getRunHosted(input, commands),
|
|
275
306
|
abortCtrl,
|
|
276
307
|
cwd: work,
|
|
277
308
|
file: (0, get_file_context_1.getFileContext)(work),
|
package/dist/server/runs.js
CHANGED
|
@@ -6,6 +6,7 @@ const oauth_1 = require("./oauth");
|
|
|
6
6
|
const runner_commands_1 = require("../executer/runner-commands");
|
|
7
7
|
const run_logs_1 = require("./run-logs");
|
|
8
8
|
const units_1 = require("../utils/units");
|
|
9
|
+
const long_timer_1 = require("../utils/long-timer");
|
|
9
10
|
const FINAL_STATES = ['succeeded', 'failed', 'cancelled', 'rejected'];
|
|
10
11
|
function isFinal(state) {
|
|
11
12
|
return FINAL_STATES.includes(state);
|
|
@@ -306,7 +307,7 @@ class RunRegistry {
|
|
|
306
307
|
this.keep = options.keep ?? 200;
|
|
307
308
|
this.maxEvents = options.maxEvents ?? 5000;
|
|
308
309
|
this.maxWaiting = options.maxWaiting ?? 100;
|
|
309
|
-
this.approvalTimeout = options.approvalTimeout
|
|
310
|
+
this.approvalTimeout = options.approvalTimeout;
|
|
310
311
|
this.now = options.now ?? Date.now;
|
|
311
312
|
this.maxLogBytes = options.maxLogBytes ?? Infinity;
|
|
312
313
|
}
|
|
@@ -344,13 +345,18 @@ class RunRegistry {
|
|
|
344
345
|
};
|
|
345
346
|
this.entries.set(run.id, entry);
|
|
346
347
|
if (run.state === 'awaiting-approval') {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
348
|
+
// no expiry means no time limit: it waits until somebody decides. An expiry that can not
|
|
349
|
+
// be read rejects it, as a fail-safe; one that is past rejects it too
|
|
350
|
+
const expiresAt = run.approvals?.[0]?.expiresAt;
|
|
351
|
+
if (expiresAt !== undefined) {
|
|
352
|
+
const at = Date.parse(expiresAt);
|
|
353
|
+
const now = this.now();
|
|
354
|
+
if (!Number.isFinite(at) || at <= now) {
|
|
355
|
+
this.finish(entry, 'rejected', 'nobody approved it in time');
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
entry.timer = (0, long_timer_1.setLongTimeout)(() => this.expire(entry), at - now);
|
|
359
|
+
}
|
|
354
360
|
}
|
|
355
361
|
}
|
|
356
362
|
else if (run.state === 'asleep') {
|
|
@@ -503,13 +509,14 @@ class RunRegistry {
|
|
|
503
509
|
this.entries.set(run.id, entry);
|
|
504
510
|
if (waiting) {
|
|
505
511
|
// before the first event, which is written down with the run
|
|
506
|
-
const expiresAt = new Date(this.now() + this.approvalTimeout).toISOString();
|
|
507
|
-
run.approvals = approvalAccounts.map((account) => ({ account, expiresAt }));
|
|
512
|
+
const expiresAt = this.approvalTimeout === undefined ? undefined : new Date(this.now() + this.approvalTimeout).toISOString();
|
|
513
|
+
run.approvals = approvalAccounts.map((account) => ({ account, ...(expiresAt ? { expiresAt } : {}) }));
|
|
508
514
|
}
|
|
509
515
|
this.record(entry, { type: 'state', state: run.state });
|
|
510
516
|
if (waiting) {
|
|
511
|
-
|
|
512
|
-
|
|
517
|
+
if (this.approvalTimeout !== undefined) {
|
|
518
|
+
entry.timer = (0, long_timer_1.setLongTimeout)(() => this.expire(entry), this.approvalTimeout);
|
|
519
|
+
}
|
|
513
520
|
}
|
|
514
521
|
else {
|
|
515
522
|
this.queue.push(entry);
|
|
@@ -993,7 +1000,7 @@ class RunRegistry {
|
|
|
993
1000
|
}
|
|
994
1001
|
clearTimer(entry) {
|
|
995
1002
|
if (entry.timer) {
|
|
996
|
-
|
|
1003
|
+
entry.timer();
|
|
997
1004
|
entry.timer = undefined;
|
|
998
1005
|
}
|
|
999
1006
|
}
|
|
@@ -1702,14 +1709,13 @@ class RunRegistry {
|
|
|
1702
1709
|
this.queue.push(entry);
|
|
1703
1710
|
this.dispatch();
|
|
1704
1711
|
}
|
|
1705
|
-
// Stops a service run at its expiry, and puts one that is up to sleep at its sleepsAt.
|
|
1706
|
-
// timer can't wait longer than about 24 days, so a longer one looks again then.
|
|
1712
|
+
// Stops a service run at its expiry, and puts one that is up to sleep at its sleepsAt.
|
|
1707
1713
|
expireLater(entry) {
|
|
1708
1714
|
this.clearTimer(entry);
|
|
1709
1715
|
const expiresAt = Date.parse(entry.run.expiresAt ?? '');
|
|
1710
1716
|
const sleepsAt = entry.run.state === 'up' ? Date.parse(entry.run.sleepsAt ?? '') : NaN;
|
|
1711
1717
|
const next = Number.isFinite(sleepsAt) ? Math.min(expiresAt, sleepsAt) : expiresAt;
|
|
1712
|
-
entry.timer =
|
|
1718
|
+
entry.timer = (0, long_timer_1.setLongTimeout)(() => {
|
|
1713
1719
|
var _a;
|
|
1714
1720
|
if (isFinal(entry.run.state)) {
|
|
1715
1721
|
return;
|
|
@@ -1740,8 +1746,7 @@ class RunRegistry {
|
|
|
1740
1746
|
return;
|
|
1741
1747
|
}
|
|
1742
1748
|
this.expireLater(entry);
|
|
1743
|
-
}, Math.max(0,
|
|
1744
|
-
entry.timer.unref();
|
|
1749
|
+
}, Math.max(0, next - this.now()));
|
|
1745
1750
|
}
|
|
1746
1751
|
keepsVolumes() {
|
|
1747
1752
|
return this.options.up?.keepVolumes !== false;
|
|
@@ -14,6 +14,7 @@ const capabilities_schema_1 = require("../schema/capabilities-schema");
|
|
|
14
14
|
const build_file_secret_provider_schema_1 = require("../schema/build-file-secret-provider-schema");
|
|
15
15
|
const repo_1 = require("./repo");
|
|
16
16
|
const work_network_1 = require("../planner/work-network");
|
|
17
|
+
const registry_reference_1 = require("../cache/backends/registry/registry-reference");
|
|
17
18
|
const LOOPBACK_HOSTS = ['127.0.0.1', 'localhost', '::1'];
|
|
18
19
|
exports.serverPlatformSchema = zod_1.z
|
|
19
20
|
.object({
|
|
@@ -427,6 +428,41 @@ exports.sourceSchema = zod_1.z
|
|
|
427
428
|
.optional(),
|
|
428
429
|
})
|
|
429
430
|
.strict();
|
|
431
|
+
// A trusted run of these repositories and branches writes a registry cache, with the credential
|
|
432
|
+
// of its registry. A build file can name the registry it reads from, never the credential; a run
|
|
433
|
+
// writes only the registry of the first rule that covers it, and only with that credential.
|
|
434
|
+
const cachePushSchema = zod_1.z
|
|
435
|
+
.object({
|
|
436
|
+
// the repositories, as a pattern of `host/path`, such as github.com/corp/*
|
|
437
|
+
repo: repoPatternSchema,
|
|
438
|
+
// the branches a trusted run is from: the default branch, such as `main` or `release/*`. A
|
|
439
|
+
// commit is never one, nor a tag, so a sandbox and an upload never are.
|
|
440
|
+
refs: zod_1.z.array(branchPatternSchema).min(1),
|
|
441
|
+
registry: zod_1.z
|
|
442
|
+
.object({
|
|
443
|
+
// the repository of the build file's `backend.repository`, written the same way; a password
|
|
444
|
+
// goes over https only, so a registry on localhost is refused here
|
|
445
|
+
repository: zod_1.z
|
|
446
|
+
.string()
|
|
447
|
+
.min(1)
|
|
448
|
+
.superRefine((value, ctx) => {
|
|
449
|
+
try {
|
|
450
|
+
if ((0, registry_reference_1.parseRegistryReference)(value).insecure) {
|
|
451
|
+
ctx.addIssue({ code: zod_1.z.ZodIssueCode.custom, message: 'a push credential goes over https only' });
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
catch (e) {
|
|
455
|
+
ctx.addIssue({ code: zod_1.z.ZodIssueCode.custom, message: (0, log_1.getErrorMessage)(e) });
|
|
456
|
+
}
|
|
457
|
+
}),
|
|
458
|
+
username: zod_1.z.string().min(1),
|
|
459
|
+
// the variable of the server's environment that holds its password or token; it is read
|
|
460
|
+
// by the server and passed to the one run that pushes, never to a task
|
|
461
|
+
passwordEnv: zod_1.z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),
|
|
462
|
+
})
|
|
463
|
+
.strict(),
|
|
464
|
+
})
|
|
465
|
+
.strict();
|
|
430
466
|
// The server config is written by an operator and reviewed like code, so a typo
|
|
431
467
|
// is an error and not a silently ignored key.
|
|
432
468
|
exports.serverConfigSchema = zod_1.z
|
|
@@ -457,10 +493,14 @@ exports.serverConfigSchema = zod_1.z
|
|
|
457
493
|
entitlements: zod_1.z.array(exports.entitlementSchema).default([]),
|
|
458
494
|
approvals: zod_1.z
|
|
459
495
|
.object({
|
|
460
|
-
// how long a run waits for its approval before it is rejected
|
|
461
|
-
|
|
496
|
+
// how long a run waits for its approval before it is rejected, and a proposed version
|
|
497
|
+
// for its decision; unset, they wait until somebody decides
|
|
498
|
+
timeout: duration.optional(),
|
|
462
499
|
// runs waiting at the same time, more are refused
|
|
463
500
|
maxWaiting: zod_1.z.number().int().min(1).default(100),
|
|
501
|
+
// proposed build file versions one proposer may have waiting at the same time, more are
|
|
502
|
+
// refused: without a time limit they wait until somebody decides
|
|
503
|
+
maxWaitingPerProposer: zod_1.z.number().int().min(1).default(10),
|
|
464
504
|
// after a version was rejected, who proposed it can not propose that build
|
|
465
505
|
// file again, and nobody that version, for this long
|
|
466
506
|
cooldown: duration.default('10m'),
|
|
@@ -479,6 +519,19 @@ exports.serverConfigSchema = zod_1.z
|
|
|
479
519
|
.array(zod_1.z.enum(['docker', 'local']))
|
|
480
520
|
.min(1)
|
|
481
521
|
.default(['docker']),
|
|
522
|
+
// the registry caches of the build files a server runs: the hosts a run may read from
|
|
523
|
+
// (`registries`, besides those of the `push` rules, which are allowed already), and the rules
|
|
524
|
+
// by which a trusted run writes one (see cachePushSchema). A registry is read anonymously
|
|
525
|
+
// unless a rule of `push` writes it; nothing is read from a host not listed here.
|
|
526
|
+
cache: zod_1.z
|
|
527
|
+
.object({
|
|
528
|
+
registries: zod_1.z
|
|
529
|
+
.array(zod_1.z.string().regex(/^[A-Za-z0-9.-]+(:[0-9]{1,5})?$/, 'a registry host, such as ghcr.io'))
|
|
530
|
+
.default([]),
|
|
531
|
+
push: zod_1.z.array(cachePushSchema).default([]),
|
|
532
|
+
})
|
|
533
|
+
.strict()
|
|
534
|
+
.default({}),
|
|
482
535
|
// where the server keeps what must survive a restart: the published build files
|
|
483
536
|
storage: zod_1.z
|
|
484
537
|
.object({ directory: zod_1.z.string().min(1).optional() })
|
|
@@ -693,6 +746,17 @@ exports.serverConfigSchema = zod_1.z
|
|
|
693
746
|
})
|
|
694
747
|
.strict()
|
|
695
748
|
.superRefine((config, ctx) => {
|
|
749
|
+
// the password of a cache push is the server's alone: a variable a run sees would reach its tasks
|
|
750
|
+
config.cache.push.forEach((rule, index) => {
|
|
751
|
+
const name = rule.registry.passwordEnv;
|
|
752
|
+
if (config.runs.env.allow.includes(name) || Object.prototype.hasOwnProperty.call(config.runs.env.set, name)) {
|
|
753
|
+
ctx.addIssue({
|
|
754
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
755
|
+
path: ['cache', 'push', index, 'registry', 'passwordEnv'],
|
|
756
|
+
message: `${name} is seen by the runs (runs.env), the password of a cache push may not be`,
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
});
|
|
696
760
|
const issuers = config.issuers.map((i) => i.issuer);
|
|
697
761
|
config.entitlements.forEach((entitlement, index) => {
|
|
698
762
|
const iss = (entitlement.subject ?? entitlement.group ?? entitlement.claims)?.iss;
|
package/dist/server/server.js
CHANGED
|
@@ -10,6 +10,7 @@ const server_config_1 = require("./server-config");
|
|
|
10
10
|
const discovery_1 = require("./discovery");
|
|
11
11
|
const oauth_1 = require("./oauth");
|
|
12
12
|
const policy_1 = require("./policy");
|
|
13
|
+
const cache_push_1 = require("./cache-push");
|
|
13
14
|
const repo_1 = require("./repo");
|
|
14
15
|
const run_store_1 = require("./run-store");
|
|
15
16
|
const runs_1 = require("./runs");
|
|
@@ -34,6 +35,7 @@ const definitions_api_1 = require("./definitions-api");
|
|
|
34
35
|
const approvals_api_1 = require("./approvals-api");
|
|
35
36
|
const proposals_api_1 = require("./proposals-api");
|
|
36
37
|
const proposals_1 = require("./proposals");
|
|
38
|
+
const proposal_store_1 = require("./proposal-store");
|
|
37
39
|
const sources_1 = require("./sources");
|
|
38
40
|
const sources_api_1 = require("./sources-api");
|
|
39
41
|
const sandbox_follow_1 = require("./sandbox-follow");
|
|
@@ -89,6 +91,8 @@ const MAX_WAIT_MS = 50000;
|
|
|
89
91
|
const CHECK_SWEEP_MS = 6 * 60 * 60 * 1000;
|
|
90
92
|
// how often the outputs of runs that are over their time are removed
|
|
91
93
|
const ARTIFACT_SWEEP_MS = 60 * 60 * 1000;
|
|
94
|
+
// how long a run or a proposed version waits for its approval, unset: until somebody decides
|
|
95
|
+
const approvalTimeoutOf = (config) => config.approvals.timeout === undefined ? undefined : (0, units_1.parseDuration)(config.approvals.timeout);
|
|
92
96
|
// Server-sent events: `id` is the sequence number, so a client that lost the
|
|
93
97
|
// connection continues with Last-Event-ID (or ?after=) and misses nothing.
|
|
94
98
|
function streamEvents(registry, config, principal, id, req, res, url) {
|
|
@@ -398,6 +402,8 @@ function listRun(registry, definitions, viewer, run) {
|
|
|
398
402
|
}
|
|
399
403
|
// where in its repository the build file of a version is
|
|
400
404
|
const entryOf = (definitions) => (definition) => definitions.find(definition)?.entry;
|
|
405
|
+
// a full commit hash, 40 or 64 hex digits: the ref of a run that names its commit
|
|
406
|
+
const FULL_COMMIT = /^[0-9a-f]{40}([0-9a-f]{24})?$/i;
|
|
401
407
|
async function submitRun(config, registry, definitions, sources, sandboxes, planning, repos, endpointUrl, log, principal, req, res) {
|
|
402
408
|
const parsed = run_request_1.runRequestSchema.safeParse(await (0, http_2.readJson)(req));
|
|
403
409
|
if (!parsed.success) {
|
|
@@ -636,7 +642,18 @@ async function startRun(config, registry, definitions, sources, sandboxes, plann
|
|
|
636
642
|
(0, http_2.send)(res, 409, { error });
|
|
637
643
|
return;
|
|
638
644
|
}
|
|
639
|
-
|
|
645
|
+
// a branch at that commit, or a tag or a commit: only a branch's run may write a cache. A
|
|
646
|
+
// full commit names no branch, whatever the repository says of it.
|
|
647
|
+
const branch = FULL_COMMIT.test(request.source.ref)
|
|
648
|
+
? false
|
|
649
|
+
: await repos.resolve(request.source.repo, request.source.ref, undefined, 'branch').then((found) => found === commit, () => false);
|
|
650
|
+
source = {
|
|
651
|
+
type: 'ref',
|
|
652
|
+
repo: request.source.repo,
|
|
653
|
+
ref: request.source.ref,
|
|
654
|
+
commit,
|
|
655
|
+
...(branch ? { branch: true } : {}),
|
|
656
|
+
};
|
|
640
657
|
}
|
|
641
658
|
catch (e) {
|
|
642
659
|
const message = e instanceof Error ? e.message : String(e);
|
|
@@ -950,6 +967,8 @@ async function startServer(config, environment, options = {}) {
|
|
|
950
967
|
},
|
|
951
968
|
policy: {
|
|
952
969
|
envs: config.runs.env.allow,
|
|
970
|
+
// the registries a build file's cache may name: the operator's, see cache-push.ts
|
|
971
|
+
cacheRegistries: (0, cache_push_1.cacheRegistriesOf)(config),
|
|
953
972
|
reserved: (0, server_config_1.getServerAccounts)(config),
|
|
954
973
|
runtimes: config.runtimes,
|
|
955
974
|
backend: config.backend.type,
|
|
@@ -1044,6 +1063,9 @@ async function startServer(config, environment, options = {}) {
|
|
|
1044
1063
|
syncFailed: (runId) => sandboxSync.failed(runId),
|
|
1045
1064
|
},
|
|
1046
1065
|
localTasksOnHost,
|
|
1066
|
+
// the registry a trusted run writes its cache to, with the password of this server's environment
|
|
1067
|
+
cachePush: (run) => (0, cache_push_1.cachePushOf)(run, config, environment.processEnvs),
|
|
1068
|
+
cacheRegistries: (0, cache_push_1.cacheRegistriesOf)(config),
|
|
1047
1069
|
...(config.backend.type === 'host' && config.backend.capabilities
|
|
1048
1070
|
? { capabilityRuntime: config.backend.capabilities.runtime }
|
|
1049
1071
|
: {}),
|
|
@@ -1074,7 +1096,7 @@ async function startServer(config, environment, options = {}) {
|
|
|
1074
1096
|
maxConcurrent: config.runs.maxConcurrent,
|
|
1075
1097
|
keep: config.runs.keep,
|
|
1076
1098
|
maxWaiting: config.approvals.maxWaiting,
|
|
1077
|
-
approvalTimeout: (
|
|
1099
|
+
approvalTimeout: approvalTimeoutOf(config),
|
|
1078
1100
|
limits: config.runs.limits,
|
|
1079
1101
|
maxDuration: (0, units_1.parseDuration)(config.runs.maxDuration),
|
|
1080
1102
|
maxLogBytes: config.runs.maxLogBytes,
|
|
@@ -1123,9 +1145,20 @@ async function startServer(config, environment, options = {}) {
|
|
|
1123
1145
|
void sweepArtifacts();
|
|
1124
1146
|
const proposals = new proposals_1.ProposalRegistry({
|
|
1125
1147
|
maxWaiting: config.approvals.maxWaiting,
|
|
1126
|
-
|
|
1148
|
+
maxWaitingPerProposer: config.approvals.maxWaitingPerProposer,
|
|
1149
|
+
timeout: approvalTimeoutOf(config),
|
|
1127
1150
|
cooldown: (0, units_1.parseDuration)(config.approvals.cooldown),
|
|
1151
|
+
store: new proposal_store_1.FileProposalStore((0, path_1.join)(storage, 'proposals')),
|
|
1152
|
+
// what waited reads its files again, as a proposal does (no fetch from git). The principal
|
|
1153
|
+
// { iss: 'restart', sub: 'restart' } is a placeholder: prepare only reads the files, and
|
|
1154
|
+
// nothing is recorded as its doing
|
|
1155
|
+
prepare: (bundle) => definitions
|
|
1156
|
+
.prepare(bundle, { iss: 'restart', sub: 'restart' }, { noRemote: 'proposal' })
|
|
1157
|
+
.then(({ version }) => version),
|
|
1158
|
+
log,
|
|
1128
1159
|
});
|
|
1160
|
+
// take back what waited when the server last stopped, with its cooldowns
|
|
1161
|
+
await proposals.restore();
|
|
1129
1162
|
const login = config.endpoints?.login;
|
|
1130
1163
|
const gateway = config.endpoints
|
|
1131
1164
|
? new endpoints_1.EndpointGateway(config, registry, {
|
|
@@ -1268,6 +1301,7 @@ async function startServer(config, environment, options = {}) {
|
|
|
1268
1301
|
clearInterval(sweeping);
|
|
1269
1302
|
clearInterval(sweepingArtifacts);
|
|
1270
1303
|
proposals.close();
|
|
1304
|
+
await proposals.flush();
|
|
1271
1305
|
follower.close();
|
|
1272
1306
|
sandboxSync.close();
|
|
1273
1307
|
await registry.close();
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setLongTimeout = exports.MAX_TIMER_MS = void 0;
|
|
4
|
+
// the longest delay of setTimeout: Node fires a longer one after 1 ms
|
|
5
|
+
exports.MAX_TIMER_MS = 2 ** 31 - 1;
|
|
6
|
+
// setTimeout for any delay. A delay longer than a timer can wait (about 24.8 days) waits
|
|
7
|
+
// in steps of the longest one, then fires at its time. The timers do not keep the process
|
|
8
|
+
// alive. Returns what cancels the delay.
|
|
9
|
+
function setLongTimeout(callback, ms) {
|
|
10
|
+
let timer;
|
|
11
|
+
const wait = (left) => {
|
|
12
|
+
const step = Math.min(left, exports.MAX_TIMER_MS);
|
|
13
|
+
timer = setTimeout(() => {
|
|
14
|
+
timer = undefined;
|
|
15
|
+
if (left > step) {
|
|
16
|
+
wait(left - step);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
callback();
|
|
20
|
+
}
|
|
21
|
+
}, step);
|
|
22
|
+
timer.unref();
|
|
23
|
+
};
|
|
24
|
+
wait(Math.max(0, ms));
|
|
25
|
+
return () => {
|
|
26
|
+
if (timer) {
|
|
27
|
+
clearTimeout(timer);
|
|
28
|
+
timer = undefined;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.setLongTimeout = setLongTimeout;
|
|
33
|
+
//# sourceMappingURL=long-timer.js.map
|
package/package.json
CHANGED