@impz/testing 7.6.1 → 7.8.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/index.js +526 -419
- package/dist/test-token.d.ts +1 -1
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -18923,79 +18923,11 @@ var BACKUP_TREE = {
|
|
|
18923
18923
|
buildImageDir: (digest) => join("images", toDigestHex(digest))
|
|
18924
18924
|
};
|
|
18925
18925
|
|
|
18926
|
-
// packages/
|
|
18926
|
+
// packages/testing/src/stand-in/start-test-impd.ts
|
|
18927
18927
|
import { copyFileSync as copyFileSync5, mkdirSync as mkdirSync32, mkdtempSync, writeFileSync as writeFileSync18 } from "fs";
|
|
18928
18928
|
import { rm as rm2 } from "fs/promises";
|
|
18929
18929
|
import { tmpdir } from "os";
|
|
18930
18930
|
|
|
18931
|
-
// packages/shared/src/test-utils/claim-free-ports.ts
|
|
18932
|
-
import { onTestFinished } from "bun:test";
|
|
18933
|
-
import { randomInt } from "crypto";
|
|
18934
|
-
import { existsSync, readFileSync } from "fs";
|
|
18935
|
-
var PICK_SPAN = 4000;
|
|
18936
|
-
function claimFreePorts(count, options = {}) {
|
|
18937
|
-
const top = readEphemeralStart();
|
|
18938
|
-
const pick = options.pick ?? (() => randomInt(top - PICK_SPAN, top));
|
|
18939
|
-
const claims = [];
|
|
18940
|
-
const ports = [];
|
|
18941
|
-
const onRelease = options.onRelease ?? onTestFinished;
|
|
18942
|
-
onRelease(() => {
|
|
18943
|
-
for (const claim of claims) {
|
|
18944
|
-
claim.stop(true);
|
|
18945
|
-
}
|
|
18946
|
-
});
|
|
18947
|
-
while (ports.length < count) {
|
|
18948
|
-
const port = pick();
|
|
18949
|
-
const claim = claimPort(port);
|
|
18950
|
-
if (claim === null) {
|
|
18951
|
-
continue;
|
|
18952
|
-
}
|
|
18953
|
-
claims.push(claim);
|
|
18954
|
-
if (!readBusyPorts().has(port)) {
|
|
18955
|
-
ports.push(port);
|
|
18956
|
-
}
|
|
18957
|
-
}
|
|
18958
|
-
return {
|
|
18959
|
-
take: () => {
|
|
18960
|
-
const port = ports.shift();
|
|
18961
|
-
if (port === undefined) {
|
|
18962
|
-
throw new Error(`only ${String(count)} free ports were asked for`);
|
|
18963
|
-
}
|
|
18964
|
-
return port;
|
|
18965
|
-
}
|
|
18966
|
-
};
|
|
18967
|
-
}
|
|
18968
|
-
function readEphemeralStart() {
|
|
18969
|
-
const range = readFileSync("/proc/sys/net/ipv4/ip_local_port_range", "utf8");
|
|
18970
|
-
return Number(range.trim().split(/\s+/u)[0]);
|
|
18971
|
-
}
|
|
18972
|
-
function claimPort(port) {
|
|
18973
|
-
try {
|
|
18974
|
-
return Bun.listen({ unix: `\x00imp-test-port-${String(port)}`, socket: { data: () => {} } });
|
|
18975
|
-
} catch {
|
|
18976
|
-
return null;
|
|
18977
|
-
}
|
|
18978
|
-
}
|
|
18979
|
-
var SOCKET_TABLES = ["tcp", "tcp6", "udp", "udp6"].map((name) => `/proc/net/${name}`);
|
|
18980
|
-
function readBusyPorts() {
|
|
18981
|
-
const busy = new Set;
|
|
18982
|
-
for (const table of SOCKET_TABLES.filter((path) => existsSync(path))) {
|
|
18983
|
-
const lines = readFileSync(table, "utf8").trim().split(`
|
|
18984
|
-
`);
|
|
18985
|
-
for (const line of lines.slice(1)) {
|
|
18986
|
-
const local = line.trim().split(/\s+/u)[1] ?? "";
|
|
18987
|
-
const hexPort = local.slice(local.lastIndexOf(":") + 1);
|
|
18988
|
-
busy.add(Number.parseInt(hexPort, 16));
|
|
18989
|
-
}
|
|
18990
|
-
}
|
|
18991
|
-
return busy;
|
|
18992
|
-
}
|
|
18993
|
-
|
|
18994
|
-
// packages/daemon/src/test-utils/start-test-impd.ts
|
|
18995
|
-
import { createORPCClient as createORPCClient2 } from "@orpc/client";
|
|
18996
|
-
import { RPCLink } from "@orpc/client/fetch";
|
|
18997
|
-
import invariant16 from "tiny-invariant";
|
|
18998
|
-
|
|
18999
18931
|
// packages/daemon/src/config.ts
|
|
19000
18932
|
import { join as join4 } from "path";
|
|
19001
18933
|
// packages/api/src/schemas/lease-schema.ts
|
|
@@ -19051,7 +18983,8 @@ var ImageSchema = z4.object({
|
|
|
19051
18983
|
source: ImageSourceSchema,
|
|
19052
18984
|
createdAt: z4.date(),
|
|
19053
18985
|
sizeBytes: z4.int().nonnegative(),
|
|
19054
|
-
pinned: z4.boolean().default(false)
|
|
18986
|
+
pinned: z4.boolean().default(false),
|
|
18987
|
+
aliases: z4.array(NameSchema).default([])
|
|
19055
18988
|
});
|
|
19056
18989
|
|
|
19057
18990
|
// packages/api/src/schemas/image-op-event-schema.ts
|
|
@@ -20232,6 +20165,7 @@ var SystemFeaturesSchema = z34.object({
|
|
|
20232
20165
|
execDropSysAdmin: z34.boolean().optional(),
|
|
20233
20166
|
guestScratch: z34.boolean().optional(),
|
|
20234
20167
|
imagePins: z34.boolean().optional(),
|
|
20168
|
+
imageAliases: z34.boolean().optional(),
|
|
20235
20169
|
buildContextUpload: z34.boolean().optional(),
|
|
20236
20170
|
destroyIdCheck: z34.boolean().optional(),
|
|
20237
20171
|
secretIdentity: z34.boolean().optional(),
|
|
@@ -20607,7 +20541,9 @@ var callerContract = {
|
|
|
20607
20541
|
builds: contractBase.meta(ACCESS.readHost).output(z43.array(ImageBuildRunSchema)),
|
|
20608
20542
|
delete: contractBase.meta(ACCESS.manageHost).input(NameInputSchema).output(EmptySchema),
|
|
20609
20543
|
pin: contractBase.meta(ACCESS.manageHeldImage).input(NameInputSchema).output(ImageSchema),
|
|
20610
|
-
unpin: contractBase.meta(ACCESS.manageHeldImage).input(NameInputSchema).output(ImageSchema)
|
|
20544
|
+
unpin: contractBase.meta(ACCESS.manageHeldImage).input(NameInputSchema).output(ImageSchema),
|
|
20545
|
+
alias: contractBase.meta(ACCESS.manageHost).input(z43.object({ alias: NameSchema, image: NameSchema })).output(ImageSchema),
|
|
20546
|
+
unalias: contractBase.meta(ACCESS.manageHost).input(z43.object({ alias: NameSchema })).output(EmptySchema)
|
|
20611
20547
|
},
|
|
20612
20548
|
exec: {
|
|
20613
20549
|
ticket: contractBase.meta({ access: { scope: "exec", on: "imp", fields: ["name"], audit: false } }).input(NameInputSchema).output(z43.object({ ticket: z43.string(), expiresAt: z43.date() }))
|
|
@@ -21150,7 +21086,7 @@ function toHexByte(octet) {
|
|
|
21150
21086
|
|
|
21151
21087
|
// packages/daemon/src/host-net/net/ipv6-plan.ts
|
|
21152
21088
|
import { randomBytes } from "crypto";
|
|
21153
|
-
import { existsSync
|
|
21089
|
+
import { existsSync, mkdirSync as mkdirSync2, readFileSync, writeFileSync } from "fs";
|
|
21154
21090
|
import { dirname, join as join2 } from "path";
|
|
21155
21091
|
|
|
21156
21092
|
// packages/daemon/src/platform/process/get-impd-logger.ts
|
|
@@ -21297,14 +21233,14 @@ async function checkHostRules6(procSys = "/proc/sys/net/ipv6/conf", run = runCom
|
|
|
21297
21233
|
}
|
|
21298
21234
|
function readSysctl(path) {
|
|
21299
21235
|
try {
|
|
21300
|
-
return
|
|
21236
|
+
return readFileSync(path, "utf8").trim();
|
|
21301
21237
|
} catch {
|
|
21302
21238
|
return null;
|
|
21303
21239
|
}
|
|
21304
21240
|
}
|
|
21305
21241
|
function readOrCreateUlaPrefix(path) {
|
|
21306
|
-
if (
|
|
21307
|
-
const prefix = parsePrefix64(
|
|
21242
|
+
if (existsSync(path)) {
|
|
21243
|
+
const prefix = parsePrefix64(readFileSync(path, "utf8").trim());
|
|
21308
21244
|
if (prefix !== null) {
|
|
21309
21245
|
return prefix;
|
|
21310
21246
|
}
|
|
@@ -21622,7 +21558,7 @@ function checkPublicPorts(ports, others, slotPorts) {
|
|
|
21622
21558
|
}
|
|
21623
21559
|
|
|
21624
21560
|
// packages/daemon/src/network/https/https-config.ts
|
|
21625
|
-
import { existsSync as
|
|
21561
|
+
import { existsSync as existsSync2 } from "fs";
|
|
21626
21562
|
import * as z52 from "zod";
|
|
21627
21563
|
var LETS_ENCRYPT_DIRECTORY = "https://acme-v02.api.letsencrypt.org/directory";
|
|
21628
21564
|
var DomainSchema = z52.string().transform((value) => value.toLowerCase().replace(/\.$/u, "")).pipe(z52.string().regex(/^(?:[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?\.)+[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?$/u, "IMP_DOMAIN must be a domain name such as imp.example.com"));
|
|
@@ -21667,7 +21603,7 @@ function readHttpsConfig(env) {
|
|
|
21667
21603
|
if (env.IMP_DNS_PROVIDER === "cloudflare" && env.IMP_DNS_API_URL !== undefined) {
|
|
21668
21604
|
checkSecureUrl(env.IMP_DNS_API_URL);
|
|
21669
21605
|
}
|
|
21670
|
-
if (env.IMP_ACME_CA_FILE !== undefined && !
|
|
21606
|
+
if (env.IMP_ACME_CA_FILE !== undefined && !existsSync2(env.IMP_ACME_CA_FILE)) {
|
|
21671
21607
|
throw new Error(`IMP_ACME_CA_FILE ${env.IMP_ACME_CA_FILE} does not exist`);
|
|
21672
21608
|
}
|
|
21673
21609
|
if (env.IMP_HTTPS_PORT === env.IMP_HTTP_PORT) {
|
|
@@ -22209,23 +22145,60 @@ function readHostAddresses() {
|
|
|
22209
22145
|
}
|
|
22210
22146
|
|
|
22211
22147
|
// packages/daemon/src/impd/create-impd.ts
|
|
22212
|
-
import { readFileSync as
|
|
22148
|
+
import { readFileSync as readFileSync38 } from "fs";
|
|
22213
22149
|
import { release as release2 } from "os";
|
|
22214
22150
|
import { join as join49 } from "path";
|
|
22215
22151
|
// packages/daemon/package.json
|
|
22216
22152
|
var package_default = {
|
|
22217
22153
|
name: "@impz/daemon",
|
|
22218
|
-
version: "7.
|
|
22154
|
+
version: "7.8.0",
|
|
22219
22155
|
private: true,
|
|
22220
22156
|
description: "impd: the imp host daemon",
|
|
22221
22157
|
type: "module",
|
|
22222
22158
|
exports: {
|
|
22223
22159
|
".": "./src/index.ts",
|
|
22224
22160
|
"./read-text": "./src/platform/process/read-text.ts",
|
|
22225
|
-
"./real-clock": "./src/platform/process/real-clock.ts",
|
|
22226
22161
|
"./test-utils": "./src/test-utils/index.ts",
|
|
22227
|
-
"./test-utils/data-layout": "./src/vm/storage/build-imp-paths.ts",
|
|
22228
22162
|
"./test-utils/*": "./src/test-utils/*.ts",
|
|
22163
|
+
"./host/config": "./src/config.ts",
|
|
22164
|
+
"./host/host-net/net/derive-slot-address": "./src/host-net/net/derive-slot-address.ts",
|
|
22165
|
+
"./host/host-net/net/ipv6-plan": "./src/host-net/net/ipv6-plan.ts",
|
|
22166
|
+
"./host/host-net/net/read-uplinks": "./src/host-net/net/read-uplinks.ts",
|
|
22167
|
+
"./host/host-net/net/resolve-tunnel-target": "./src/host-net/net/resolve-tunnel-target.ts",
|
|
22168
|
+
"./host/host-net/net/tailscale-status": "./src/host-net/net/tailscale-status.ts",
|
|
22169
|
+
"./host/impd/create-impd": "./src/impd/create-impd.ts",
|
|
22170
|
+
"./host/impd/impd-deps": "./src/impd/impd-deps.ts",
|
|
22171
|
+
"./host/impd/impd-startup-steps": "./src/impd/impd-startup-steps.ts",
|
|
22172
|
+
"./host/imps/imps/kernel-oops-watch": "./src/imps/imps/kernel-oops-watch.ts",
|
|
22173
|
+
"./host/network/broker/guest/guest-trust": "./src/network/broker/guest/guest-trust.ts",
|
|
22174
|
+
"./host/network/broker/secrets/oauth-refresher": "./src/network/broker/secrets/oauth-refresher.ts",
|
|
22175
|
+
"./host/platform/db/create-image": "./src/platform/db/create-image.ts",
|
|
22176
|
+
"./host/platform/db/list-imps": "./src/platform/db/list-imps.ts",
|
|
22177
|
+
"./host/platform/db/open-database": "./src/platform/db/open-database.ts",
|
|
22178
|
+
"./host/platform/db/read-names": "./src/platform/db/read-names.ts",
|
|
22179
|
+
"./host/platform/db/run-migrations": "./src/platform/db/run-migrations.ts",
|
|
22180
|
+
"./host/platform/process/start-timer": "./src/platform/process/start-timer.ts",
|
|
22181
|
+
"./host/platform/process/get-impd-logger": "./src/platform/process/get-impd-logger.ts",
|
|
22182
|
+
"./host/platform/process/read-host-load": "./src/platform/process/read-host-load.ts",
|
|
22183
|
+
"./host/platform/process/read-text": "./src/platform/process/read-text.ts",
|
|
22184
|
+
"./host/platform/process/setup-logging": "./src/platform/process/setup-logging.ts",
|
|
22185
|
+
"./host/platform/process/ticker": "./src/platform/process/ticker.ts",
|
|
22186
|
+
"./host/vm/agent-client/agent-connection": "./src/vm/agent-client/agent-connection.ts",
|
|
22187
|
+
"./host/vm/agent-client/build-agent-outdated-error": "./src/vm/agent-client/build-agent-outdated-error.ts",
|
|
22188
|
+
"./host/vm/sleep/snapshot-meta": "./src/vm/sleep/snapshot-meta.ts",
|
|
22189
|
+
"./host/vm/sleep/vm-identity": "./src/vm/sleep/vm-identity.ts",
|
|
22190
|
+
"./host/vm/storage/build-imp-paths": "./src/vm/storage/build-imp-paths.ts",
|
|
22191
|
+
"./host/vm/storage/create-xfs-backend": "./src/vm/storage/create-xfs-backend.ts",
|
|
22192
|
+
"./host/vm/storage/storage-backend": "./src/vm/storage/storage-backend.ts",
|
|
22193
|
+
"./host/vm/vmm/cpu-cgroups": "./src/vm/vmm/cpu-cgroups.ts",
|
|
22194
|
+
"./host/vm/vmm/create-jails": "./src/vm/vmm/create-jails.ts",
|
|
22195
|
+
"./host/vm/vmm/create-template-vm": "./src/vm/vmm/create-template-vm.ts",
|
|
22196
|
+
"./host/vm/vmm/firecracker-client": "./src/vm/vmm/firecracker-client.ts",
|
|
22197
|
+
"./host/vm/vmm/read-ksm-host-stats": "./src/vm/vmm/read-ksm-host-stats.ts",
|
|
22198
|
+
"./host/vm/vmm/read-vm-memory": "./src/vm/vmm/read-vm-memory.ts",
|
|
22199
|
+
"./host/vm/vmm/start-firecracker": "./src/vm/vmm/start-firecracker.ts",
|
|
22200
|
+
"./host/vm/vmm/start-uffd-handler": "./src/vm/vmm/start-uffd-handler.ts",
|
|
22201
|
+
"./host/vm/vmm/vm-runner": "./src/vm/vmm/vm-runner.ts",
|
|
22229
22202
|
"./package.json": "./package.json"
|
|
22230
22203
|
},
|
|
22231
22204
|
dependencies: {
|
|
@@ -22270,6 +22243,8 @@ var package_default = {
|
|
|
22270
22243
|
"@faker-js/faker": "catalog:",
|
|
22271
22244
|
"@impz/cli": "workspace:*",
|
|
22272
22245
|
"@impz/e2e-harness": "workspace:*",
|
|
22246
|
+
"@impz/scripts": "workspace:*",
|
|
22247
|
+
"@impz/testing": "workspace:*",
|
|
22273
22248
|
"@modelcontextprotocol/client": "catalog:",
|
|
22274
22249
|
"@msw/data": "catalog:",
|
|
22275
22250
|
"@types/dns-packet": "catalog:",
|
|
@@ -22336,7 +22311,7 @@ function createStatusCache(read, now) {
|
|
|
22336
22311
|
}
|
|
22337
22312
|
|
|
22338
22313
|
// packages/daemon/src/identity/token.ts
|
|
22339
|
-
import { existsSync as
|
|
22314
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
22340
22315
|
import { join as join5 } from "path";
|
|
22341
22316
|
|
|
22342
22317
|
// packages/daemon/src/platform/secrets/mint-secret.ts
|
|
@@ -22349,8 +22324,8 @@ function mintSecret() {
|
|
|
22349
22324
|
// packages/daemon/src/identity/token.ts
|
|
22350
22325
|
function token(dataDir) {
|
|
22351
22326
|
const path = join5(dataDir, "token");
|
|
22352
|
-
if (
|
|
22353
|
-
return
|
|
22327
|
+
if (existsSync3(path)) {
|
|
22328
|
+
return readFileSync2(path, "utf8").trim();
|
|
22354
22329
|
}
|
|
22355
22330
|
const secret = mintSecret();
|
|
22356
22331
|
writeFileSync2(path, `${secret}
|
|
@@ -22363,7 +22338,7 @@ import {
|
|
|
22363
22338
|
chmodSync as chmodSync2,
|
|
22364
22339
|
copyFileSync as copyFileSync2,
|
|
22365
22340
|
mkdirSync as mkdirSync5,
|
|
22366
|
-
readFileSync as
|
|
22341
|
+
readFileSync as readFileSync9,
|
|
22367
22342
|
rmSync as rmSync9,
|
|
22368
22343
|
statSync as statSync2,
|
|
22369
22344
|
writeFileSync as writeFileSync3
|
|
@@ -22631,7 +22606,7 @@ import {
|
|
|
22631
22606
|
ftruncateSync,
|
|
22632
22607
|
lstatSync,
|
|
22633
22608
|
openSync,
|
|
22634
|
-
readFileSync as
|
|
22609
|
+
readFileSync as readFileSync3,
|
|
22635
22610
|
rmSync,
|
|
22636
22611
|
writeSync
|
|
22637
22612
|
} from "fs";
|
|
@@ -22681,7 +22656,7 @@ function readRegularFile(path) {
|
|
|
22681
22656
|
if (!fstatSync(fd).isFile()) {
|
|
22682
22657
|
throw new Error(`${path} is not a regular file`);
|
|
22683
22658
|
}
|
|
22684
|
-
return
|
|
22659
|
+
return readFileSync3(fd, "utf8");
|
|
22685
22660
|
} finally {
|
|
22686
22661
|
closeSync(fd);
|
|
22687
22662
|
}
|
|
@@ -25415,17 +25390,23 @@ async function writeChangedBlocks(source, target) {
|
|
|
25415
25390
|
|
|
25416
25391
|
// packages/daemon/src/platform/db/create-image.ts
|
|
25417
25392
|
async function createImage(db, image, now = Date.now()) {
|
|
25418
|
-
const row = await db.
|
|
25419
|
-
|
|
25420
|
-
|
|
25421
|
-
|
|
25422
|
-
|
|
25423
|
-
|
|
25424
|
-
|
|
25425
|
-
|
|
25426
|
-
|
|
25427
|
-
|
|
25428
|
-
|
|
25393
|
+
const row = await db.transaction().execute(async (trx) => {
|
|
25394
|
+
const alias = await trx.selectFrom("image_aliases").select("name").where("name", "=", image.name).executeTakeFirst();
|
|
25395
|
+
if (alias !== undefined) {
|
|
25396
|
+
throw buildConflictError("image", image.name, `image name ${image.name} is held by an alias; remove the alias first`);
|
|
25397
|
+
}
|
|
25398
|
+
return trx.insertInto("images").values({
|
|
25399
|
+
id: Bun.randomUUIDv7(),
|
|
25400
|
+
name: image.name,
|
|
25401
|
+
ref: image.ref,
|
|
25402
|
+
digest: image.digest,
|
|
25403
|
+
size_bytes: image.sizeBytes,
|
|
25404
|
+
source: image.source ?? "oci",
|
|
25405
|
+
source_imp: image.sourceImp ?? null,
|
|
25406
|
+
created_at: now,
|
|
25407
|
+
last_used_at: now
|
|
25408
|
+
}).returningAll().executeTakeFirstOrThrow();
|
|
25409
|
+
});
|
|
25429
25410
|
return toImageRecord(row);
|
|
25430
25411
|
}
|
|
25431
25412
|
async function readImageByName(db, name) {
|
|
@@ -25507,7 +25488,8 @@ async function listImageUses(db) {
|
|
|
25507
25488
|
"images.size_bytes",
|
|
25508
25489
|
"images.last_used_at",
|
|
25509
25490
|
"images.pinned",
|
|
25510
|
-
eb.fn.count("imps.id").as("imp_count")
|
|
25491
|
+
eb.fn.count("imps.id").as("imp_count"),
|
|
25492
|
+
eb.exists(eb.selectFrom("image_aliases").select("image_aliases.name").whereRef("image_aliases.image_id", "=", "images.id")).as("is_aliased")
|
|
25511
25493
|
]).groupBy("images.id").orderBy("images.name").execute();
|
|
25512
25494
|
return rows.map((row) => ({
|
|
25513
25495
|
id: row.id,
|
|
@@ -25517,12 +25499,13 @@ async function listImageUses(db) {
|
|
|
25517
25499
|
sizeBytes: row.size_bytes,
|
|
25518
25500
|
lastUsedAt: row.last_used_at,
|
|
25519
25501
|
impCount: row.imp_count,
|
|
25520
|
-
isPinned: row.pinned === 1
|
|
25502
|
+
isPinned: row.pinned === 1,
|
|
25503
|
+
isAliased: Boolean(row.is_aliased)
|
|
25521
25504
|
}));
|
|
25522
25505
|
}
|
|
25523
25506
|
function removeUnusedImage(db, id, lastUsedAt) {
|
|
25524
25507
|
return db.transaction().execute(async (trx) => {
|
|
25525
|
-
const row = await trx.deleteFrom("images").where("id", "=", id).where("last_used_at", "=", lastUsedAt).where("pinned", "=", 0).where((eb) => eb.not(eb.exists(eb.selectFrom("imps").select("imps.id").whereRef("imps.image_id", "=", "images.id")))).returning("digest").executeTakeFirst();
|
|
25508
|
+
const row = await trx.deleteFrom("images").where("id", "=", id).where("last_used_at", "=", lastUsedAt).where("pinned", "=", 0).where((eb) => eb.not(eb.exists(eb.selectFrom("imps").select("imps.id").whereRef("imps.image_id", "=", "images.id")))).where((eb) => eb.not(eb.exists(eb.selectFrom("image_aliases").select("image_aliases.name").whereRef("image_aliases.image_id", "=", "images.id")))).returning("digest").executeTakeFirst();
|
|
25526
25509
|
if (row === undefined) {
|
|
25527
25510
|
return false;
|
|
25528
25511
|
}
|
|
@@ -25541,6 +25524,12 @@ async function removeImageRemoval(db, digest) {
|
|
|
25541
25524
|
await db.deleteFrom("image_removals").where("digest", "=", digest).execute();
|
|
25542
25525
|
}
|
|
25543
25526
|
|
|
25527
|
+
// packages/daemon/src/platform/db/probe-image-alias.ts
|
|
25528
|
+
async function probeImageAlias(db, name) {
|
|
25529
|
+
const row = await db.selectFrom("image_aliases").select("name").where("name", "=", name).executeTakeFirst();
|
|
25530
|
+
return row !== undefined;
|
|
25531
|
+
}
|
|
25532
|
+
|
|
25544
25533
|
// packages/daemon/src/imp-ops/imp-import/build-digest-tag.ts
|
|
25545
25534
|
function buildDigestTag(digest) {
|
|
25546
25535
|
if (digest.startsWith("imp-")) {
|
|
@@ -25551,17 +25540,24 @@ function buildDigestTag(digest) {
|
|
|
25551
25540
|
|
|
25552
25541
|
// packages/daemon/src/imp-ops/imp-import/resolve-imported-image-name.ts
|
|
25553
25542
|
async function resolveImportedImageName(db, name, digest) {
|
|
25554
|
-
const
|
|
25555
|
-
if (
|
|
25543
|
+
const isTaken = await probeNameTaken(db, name);
|
|
25544
|
+
if (!isTaken) {
|
|
25556
25545
|
return name;
|
|
25557
25546
|
}
|
|
25558
25547
|
const fallback = `${name.slice(0, 22)}-${buildDigestTag(digest)}`;
|
|
25559
|
-
const
|
|
25560
|
-
if (
|
|
25561
|
-
throw buildConflictError("image", fallback, `images ${name} and ${fallback} both exist; remove one to import this image`);
|
|
25548
|
+
const isFallbackTaken = await probeNameTaken(db, fallback);
|
|
25549
|
+
if (isFallbackTaken) {
|
|
25550
|
+
throw buildConflictError("image", fallback, `images ${name} and ${fallback} both exist, or an alias holds one of them; remove one to import this image`);
|
|
25562
25551
|
}
|
|
25563
25552
|
return fallback;
|
|
25564
25553
|
}
|
|
25554
|
+
async function probeNameTaken(db, name) {
|
|
25555
|
+
const image = await readImageByName(db, name);
|
|
25556
|
+
if (image !== undefined) {
|
|
25557
|
+
return true;
|
|
25558
|
+
}
|
|
25559
|
+
return probeImageAlias(db, name);
|
|
25560
|
+
}
|
|
25565
25561
|
|
|
25566
25562
|
// packages/daemon/src/imp-ops/imp-import/create-image-from-file.ts
|
|
25567
25563
|
function createImageFromFile(deps, image) {
|
|
@@ -25575,7 +25571,10 @@ function createImageFromFile(deps, image) {
|
|
|
25575
25571
|
sizeBytes: image.sizeBytes,
|
|
25576
25572
|
source: image.source,
|
|
25577
25573
|
sourceImp: image.sourceImp
|
|
25578
|
-
}, deps.now())
|
|
25574
|
+
}, deps.now()).catch(async (error) => {
|
|
25575
|
+
await deps.images.removeIdleRootfs(image.digest);
|
|
25576
|
+
throw error;
|
|
25577
|
+
});
|
|
25579
25578
|
return name;
|
|
25580
25579
|
});
|
|
25581
25580
|
}
|
|
@@ -25734,13 +25733,13 @@ function buildBootCauseValues(change) {
|
|
|
25734
25733
|
}
|
|
25735
25734
|
|
|
25736
25735
|
// packages/daemon/src/vm/sleep/snapshot-meta.ts
|
|
25737
|
-
import { existsSync as
|
|
25736
|
+
import { existsSync as existsSync4, rmSync as rmSync5 } from "fs";
|
|
25738
25737
|
import { toJson as toJson3 } from "@bufbuild/protobuf";
|
|
25739
25738
|
import * as z62 from "zod";
|
|
25740
25739
|
|
|
25741
25740
|
// packages/daemon/src/vm/sleep/cpu-identity.ts
|
|
25742
25741
|
import { createHash } from "crypto";
|
|
25743
|
-
import { readFileSync as
|
|
25742
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
25744
25743
|
var UNKNOWN_CPU = "unknown";
|
|
25745
25744
|
function parseCpuInfo(text) {
|
|
25746
25745
|
const first = text.split(/\n\s*\n/u)[0] ?? "";
|
|
@@ -25762,7 +25761,7 @@ function parseCpuInfo(text) {
|
|
|
25762
25761
|
}
|
|
25763
25762
|
function readCpuIdentity(path = "/proc/cpuinfo") {
|
|
25764
25763
|
try {
|
|
25765
|
-
return parseCpuInfo(
|
|
25764
|
+
return parseCpuInfo(readFileSync4(path, "utf8"));
|
|
25766
25765
|
} catch {
|
|
25767
25766
|
return { cpuModel: UNKNOWN_CPU, cpuFlags: UNKNOWN_CPU };
|
|
25768
25767
|
}
|
|
@@ -25893,7 +25892,7 @@ function readLoadingMeta(paths) {
|
|
|
25893
25892
|
}
|
|
25894
25893
|
}
|
|
25895
25894
|
function readSnapshotMeta(paths) {
|
|
25896
|
-
if (!
|
|
25895
|
+
if (!existsSync4(paths.vmstate) || !existsSync4(paths.memFile)) {
|
|
25897
25896
|
return null;
|
|
25898
25897
|
}
|
|
25899
25898
|
try {
|
|
@@ -25923,7 +25922,7 @@ function readColdBootReason(meta, host) {
|
|
|
25923
25922
|
if (typeof meta.ipv6Prefix === "string" && meta.ipv6Prefix !== hostPrefix) {
|
|
25924
25923
|
return `the IPv6 prefix changed (${meta.ipv6Prefix} \u2192 ${hostPrefix ?? "off"})`;
|
|
25925
25924
|
}
|
|
25926
|
-
if (!
|
|
25925
|
+
if (!existsSync4(meta.systemDrivePath)) {
|
|
25927
25926
|
return `its agent drive ${meta.systemDrive.slice(0, 12)} is gone`;
|
|
25928
25927
|
}
|
|
25929
25928
|
return null;
|
|
@@ -25933,17 +25932,18 @@ function removeSnapshot(paths) {
|
|
|
25933
25932
|
}
|
|
25934
25933
|
|
|
25935
25934
|
// packages/daemon/src/vm/vmm/start-firecracker.ts
|
|
25936
|
-
import { closeSync as closeSync6, existsSync as
|
|
25935
|
+
import { closeSync as closeSync6, existsSync as existsSync5, readFileSync as readFileSync7, rmSync as rmSync6 } from "fs";
|
|
25937
25936
|
import { basename } from "path";
|
|
25937
|
+
import { systemClock } from "@zgeoff/std";
|
|
25938
25938
|
|
|
25939
25939
|
// packages/daemon/src/platform/process/impd-user.ts
|
|
25940
25940
|
var IMPD_USER = { uid: process.getuid?.() ?? 0, gid: process.getgid?.() ?? 0 };
|
|
25941
25941
|
|
|
25942
25942
|
// packages/daemon/src/platform/process/read-stat-fields.ts
|
|
25943
|
-
import { readFileSync as
|
|
25943
|
+
import { readFileSync as readFileSync5, readdirSync } from "fs";
|
|
25944
25944
|
function readStatFields(pid, procRoot = "/proc") {
|
|
25945
25945
|
try {
|
|
25946
|
-
const stat =
|
|
25946
|
+
const stat = readFileSync5(`${procRoot}/${String(pid)}/stat`, "utf8");
|
|
25947
25947
|
return stat.slice(stat.lastIndexOf(")") + 2).trimEnd().split(" ");
|
|
25948
25948
|
} catch {
|
|
25949
25949
|
return null;
|
|
@@ -25958,15 +25958,8 @@ function stopPid(pid, signal = "SIGKILL") {
|
|
|
25958
25958
|
} catch {}
|
|
25959
25959
|
}
|
|
25960
25960
|
|
|
25961
|
-
// packages/daemon/src/platform/process/real-clock.ts
|
|
25962
|
-
var REAL_CLOCK = {
|
|
25963
|
-
now: () => Date.now(),
|
|
25964
|
-
startTimer: startRealTimer,
|
|
25965
|
-
sleep: (durationMs) => Bun.sleep(durationMs)
|
|
25966
|
-
};
|
|
25967
|
-
|
|
25968
25961
|
// packages/daemon/src/vm/vmm/read-process-uid.ts
|
|
25969
|
-
import { closeSync as closeSync5, readFileSync as
|
|
25962
|
+
import { closeSync as closeSync5, readFileSync as readFileSync6 } from "fs";
|
|
25970
25963
|
import { join as join7 } from "path";
|
|
25971
25964
|
function readProcessUid(pid, procRoot = "/proc") {
|
|
25972
25965
|
const uids = readProcessUids(pid, procRoot);
|
|
@@ -25974,7 +25967,7 @@ function readProcessUid(pid, procRoot = "/proc") {
|
|
|
25974
25967
|
}
|
|
25975
25968
|
function readProcessUids(pid, procRoot = "/proc") {
|
|
25976
25969
|
try {
|
|
25977
|
-
const status =
|
|
25970
|
+
const status = readFileSync6(join7(procRoot, String(pid), "status"), "utf8");
|
|
25978
25971
|
const uids = /^Uid:\s+(?<real>\d+)\s+(?<effective>\d+)/mu.exec(status)?.groups;
|
|
25979
25972
|
return uids === undefined ? null : { real: Number(uids["real"]), effective: Number(uids["effective"]) };
|
|
25980
25973
|
} catch {
|
|
@@ -25983,7 +25976,7 @@ function readProcessUids(pid, procRoot = "/proc") {
|
|
|
25983
25976
|
}
|
|
25984
25977
|
function readProcessCgroup(pid, procRoot = "/proc") {
|
|
25985
25978
|
try {
|
|
25986
|
-
const text =
|
|
25979
|
+
const text = readFileSync6(join7(procRoot, String(pid), "cgroup"), "utf8");
|
|
25987
25980
|
return text.trim().replace(/^0::/u, "");
|
|
25988
25981
|
} catch {
|
|
25989
25982
|
return null;
|
|
@@ -26073,7 +26066,7 @@ async function startFirecracker(command, paths, cgroupProcs = null, mergeWrapper
|
|
|
26073
26066
|
return child.pid;
|
|
26074
26067
|
}
|
|
26075
26068
|
async function probeListening(socketPath) {
|
|
26076
|
-
if (!
|
|
26069
|
+
if (!existsSync5(socketPath)) {
|
|
26077
26070
|
return false;
|
|
26078
26071
|
}
|
|
26079
26072
|
try {
|
|
@@ -26090,14 +26083,14 @@ function probeProcessAlive(pid, socket, procRoot = "/proc") {
|
|
|
26090
26083
|
return false;
|
|
26091
26084
|
}
|
|
26092
26085
|
try {
|
|
26093
|
-
const cmdline =
|
|
26086
|
+
const cmdline = readFileSync7(`${procRoot}/${String(pid)}/cmdline`, "utf8").split("\x00");
|
|
26094
26087
|
return cmdline.includes(socket);
|
|
26095
26088
|
} catch {
|
|
26096
26089
|
return false;
|
|
26097
26090
|
}
|
|
26098
26091
|
}
|
|
26099
26092
|
async function waitForExit(pid, apiSocket, timeoutMs, watch = {}) {
|
|
26100
|
-
const clock = watch.clock ??
|
|
26093
|
+
const clock = watch.clock ?? systemClock;
|
|
26101
26094
|
const deadline = clock.now() + timeoutMs;
|
|
26102
26095
|
while (probeProcessAlive(pid, apiSocket, watch.procRoot)) {
|
|
26103
26096
|
if (clock.now() > deadline) {
|
|
@@ -26141,7 +26134,7 @@ function readVmOwner(pid, procRoot = "/proc") {
|
|
|
26141
26134
|
}
|
|
26142
26135
|
function readCommandLine(pid, procRoot) {
|
|
26143
26136
|
try {
|
|
26144
|
-
return
|
|
26137
|
+
return readFileSync7(`${procRoot}/${String(pid)}/cmdline`, "utf8").split("\x00");
|
|
26145
26138
|
} catch {
|
|
26146
26139
|
return [];
|
|
26147
26140
|
}
|
|
@@ -26154,7 +26147,7 @@ function probeJailedFirecracker(pid, procRoot = "/proc") {
|
|
|
26154
26147
|
}
|
|
26155
26148
|
|
|
26156
26149
|
// packages/daemon/src/imps/imps/kernel-oops-watch.ts
|
|
26157
|
-
import { closeSync as closeSync7, constants as constants3, openSync as openSync5, readFileSync as
|
|
26150
|
+
import { closeSync as closeSync7, constants as constants3, openSync as openSync5, readFileSync as readFileSync8, readSync, readlinkSync } from "fs";
|
|
26158
26151
|
var KERNEL_OOPS_TRIGGER = "a kernel oops killed firecracker";
|
|
26159
26152
|
var KERNEL_OOPS_REASON = "a kernel oops";
|
|
26160
26153
|
var OOPS_TAINT = 128;
|
|
@@ -26223,7 +26216,7 @@ function createKernelOopsWatch(path = "/proc/sys/kernel/tainted", now = Date.now
|
|
|
26223
26216
|
function readTaint(path) {
|
|
26224
26217
|
let text;
|
|
26225
26218
|
try {
|
|
26226
|
-
text =
|
|
26219
|
+
text = readFileSync8(path, "utf8").trim();
|
|
26227
26220
|
} catch {
|
|
26228
26221
|
return null;
|
|
26229
26222
|
}
|
|
@@ -26233,7 +26226,7 @@ function readTaint(path) {
|
|
|
26233
26226
|
function readBootId(path) {
|
|
26234
26227
|
let text;
|
|
26235
26228
|
try {
|
|
26236
|
-
text =
|
|
26229
|
+
text = readFileSync8(path, "utf8").trim();
|
|
26237
26230
|
} catch {
|
|
26238
26231
|
return null;
|
|
26239
26232
|
}
|
|
@@ -26737,7 +26730,7 @@ function createCheckpointService(deps) {
|
|
|
26737
26730
|
try {
|
|
26738
26731
|
const fork = await deps.imps.createImp({
|
|
26739
26732
|
name: input.name,
|
|
26740
|
-
image: source.imp.image,
|
|
26733
|
+
image: await deps.images.resolveImage(source.imp.image),
|
|
26741
26734
|
imageDigest: source.imageDigest,
|
|
26742
26735
|
vcpus: source.imp.vcpus,
|
|
26743
26736
|
memoryMib: source.imp.memoryMib,
|
|
@@ -28219,6 +28212,14 @@ var MIGRATION_046_MOVE_GRANTS_TO_MCP_AUTH = {
|
|
|
28219
28212
|
}
|
|
28220
28213
|
};
|
|
28221
28214
|
|
|
28215
|
+
// packages/daemon/src/platform/db/migrations/migration-047-add-image-aliases.ts
|
|
28216
|
+
var MIGRATION_047_ADD_IMAGE_ALIASES = {
|
|
28217
|
+
async up(db) {
|
|
28218
|
+
await db.schema.createTable("image_aliases").addColumn("name", "text", (column) => column.primaryKey()).addColumn("image_id", "text", (column) => column.notNull().references("images.id")).addColumn("updated_at", "integer", (column) => column.notNull()).execute();
|
|
28219
|
+
await db.schema.createIndex("image_aliases_image_id").on("image_aliases").column("image_id").execute();
|
|
28220
|
+
}
|
|
28221
|
+
};
|
|
28222
|
+
|
|
28222
28223
|
// packages/daemon/src/platform/db/read-names.ts
|
|
28223
28224
|
import * as z68 from "zod";
|
|
28224
28225
|
var NameRowsSchema = z68.array(z68.object({ name: z68.string() }));
|
|
@@ -28273,7 +28274,8 @@ var MIGRATIONS = {
|
|
|
28273
28274
|
"043_merge_secret_kinds": MIGRATION_043_MERGE_SECRET_KINDS,
|
|
28274
28275
|
"044_add_imp_image_digests": MIGRATION_044_ADD_IMP_IMAGE_DIGESTS,
|
|
28275
28276
|
"045_add_imp_last_request": MIGRATION_045_ADD_IMP_LAST_REQUEST,
|
|
28276
|
-
"046_move_grants_to_mcp_auth": MIGRATION_046_MOVE_GRANTS_TO_MCP_AUTH
|
|
28277
|
+
"046_move_grants_to_mcp_auth": MIGRATION_046_MOVE_GRANTS_TO_MCP_AUTH,
|
|
28278
|
+
"047_add_image_aliases": MIGRATION_047_ADD_IMAGE_ALIASES
|
|
28277
28279
|
};
|
|
28278
28280
|
var DURABLE_MIGRATION_TABLE = "kysely_migration_durable";
|
|
28279
28281
|
async function runMigrations(db) {
|
|
@@ -28558,7 +28560,7 @@ async function createRestoredImp(deps, options) {
|
|
|
28558
28560
|
...imp.clonedDigest !== undefined && { imageDigest: imp.clonedDigest },
|
|
28559
28561
|
name: target.name,
|
|
28560
28562
|
networkIds: networks.ids,
|
|
28561
|
-
image: target.image,
|
|
28563
|
+
image: await deps.images.resolveImage(target.image),
|
|
28562
28564
|
vcpus: imp.vcpus,
|
|
28563
28565
|
memoryMib: imp.memoryMib,
|
|
28564
28566
|
maxMemoryMib: imp.maxMemoryMib ?? undefined,
|
|
@@ -28634,7 +28636,7 @@ function createBackupService(deps) {
|
|
|
28634
28636
|
};
|
|
28635
28637
|
const readState = () => {
|
|
28636
28638
|
try {
|
|
28637
|
-
return BackupStateSchema.parse(JSON.parse(
|
|
28639
|
+
return BackupStateSchema.parse(JSON.parse(readFileSync9(paths.state, "utf8")));
|
|
28638
28640
|
} catch {
|
|
28639
28641
|
return BackupStateSchema.parse({});
|
|
28640
28642
|
}
|
|
@@ -28894,7 +28896,7 @@ function createBackupService(deps) {
|
|
|
28894
28896
|
}
|
|
28895
28897
|
|
|
28896
28898
|
// packages/daemon/src/vm/vmm/read-vm-memory.ts
|
|
28897
|
-
import { readFileSync as
|
|
28899
|
+
import { readFileSync as readFileSync10, readdirSync as readdirSync2 } from "fs";
|
|
28898
28900
|
import { readFile } from "fs/promises";
|
|
28899
28901
|
var KIB_PER_MIB = 1024;
|
|
28900
28902
|
function parseProcFields(text) {
|
|
@@ -28983,8 +28985,8 @@ function readVmSmaps(pid, apiSocket, procRoot) {
|
|
|
28983
28985
|
return null;
|
|
28984
28986
|
}
|
|
28985
28987
|
try {
|
|
28986
|
-
const rollup =
|
|
28987
|
-
const status =
|
|
28988
|
+
const rollup = readFileSync10(`${procRoot}/${String(pid)}/smaps_rollup`, "utf8");
|
|
28989
|
+
const status = readFileSync10(`${procRoot}/${String(pid)}/status`, "utf8");
|
|
28988
28990
|
return addHugetlbPages(parseProcFields(rollup), status);
|
|
28989
28991
|
} catch {
|
|
28990
28992
|
return null;
|
|
@@ -29118,6 +29120,9 @@ function createIdleLoop(deps) {
|
|
|
29118
29120
|
};
|
|
29119
29121
|
}
|
|
29120
29122
|
|
|
29123
|
+
// packages/daemon/src/imps/images/builders/create-builders.ts
|
|
29124
|
+
import { systemClock as systemClock2 } from "@zgeoff/std";
|
|
29125
|
+
|
|
29121
29126
|
// packages/daemon/src/imps/images/builders/guest-exec.ts
|
|
29122
29127
|
var STDOUT_MAX_BYTES = 1024 ** 2;
|
|
29123
29128
|
var STDERR_TAIL_BYTES = 64 * 1024;
|
|
@@ -29243,7 +29248,7 @@ var BUILDER_IMAGE = "imp-builder";
|
|
|
29243
29248
|
var REMOVE_RETRY_MS = 30000;
|
|
29244
29249
|
function createBuilders(deps) {
|
|
29245
29250
|
const startTimer = deps.startTimer ?? ((fire, durationMs) => startRealTimer(fire, durationMs, { isUnref: true }));
|
|
29246
|
-
const clock = deps.clock ??
|
|
29251
|
+
const clock = deps.clock ?? systemClock2;
|
|
29247
29252
|
const pickBuilderName = deps.pickBuilderName ?? pickRandomBuilderName;
|
|
29248
29253
|
const logger = getImpdLogger("image");
|
|
29249
29254
|
const retrying = new Set;
|
|
@@ -29293,7 +29298,7 @@ function createBuilders(deps) {
|
|
|
29293
29298
|
await deps.imps.createImp({
|
|
29294
29299
|
id,
|
|
29295
29300
|
name,
|
|
29296
|
-
image: BUILDER_IMAGE,
|
|
29301
|
+
image: await deps.images.resolveImage(BUILDER_IMAGE),
|
|
29297
29302
|
memoryMib: deps.config.build.memoryMib,
|
|
29298
29303
|
maxMemoryMib: deps.config.build.maxMemoryMib ?? undefined,
|
|
29299
29304
|
diskMib: Math.ceil(deps.config.build.diskBytes / 1024 ** 2),
|
|
@@ -29399,7 +29404,7 @@ async function writeTestRegistry(exec, registry, signal) {
|
|
|
29399
29404
|
}
|
|
29400
29405
|
|
|
29401
29406
|
// packages/daemon/src/imps/images/rootfs/assert-unpacked.ts
|
|
29402
|
-
import { readFileSync as
|
|
29407
|
+
import { readFileSync as readFileSync11 } from "fs";
|
|
29403
29408
|
var CAP_SETFCAP_BIT = 31n;
|
|
29404
29409
|
var SETFCAP_HELP = "imp-host needs CAP_SETFCAP (docs/architecture/host.md#privileges)";
|
|
29405
29410
|
var UNPACK_TAR_ARGS = [
|
|
@@ -29441,7 +29446,7 @@ function findXattrFailure(stderr) {
|
|
|
29441
29446
|
});
|
|
29442
29447
|
return failures.find((failure) => failure.missingSetfcap) ?? failures[0] ?? null;
|
|
29443
29448
|
}
|
|
29444
|
-
function readSetfcapWarning(status =
|
|
29449
|
+
function readSetfcapWarning(status = readFileSync11("/proc/self/status", "utf8")) {
|
|
29445
29450
|
const effective = /^CapEff:\s*(?<mask>[0-9a-f]+)$/mu.exec(status)?.groups?.["mask"] ?? "0";
|
|
29446
29451
|
if (BigInt(`0x${effective}`) >> CAP_SETFCAP_BIT & 1n) {
|
|
29447
29452
|
return null;
|
|
@@ -29453,7 +29458,7 @@ function readSetfcapWarning(status = readFileSync12("/proc/self/status", "utf8")
|
|
|
29453
29458
|
import { basename as basename2 } from "path";
|
|
29454
29459
|
|
|
29455
29460
|
// packages/daemon/src/vm/sleep/vm-identity.ts
|
|
29456
|
-
import { existsSync as
|
|
29461
|
+
import { existsSync as existsSync6, readFileSync as readFileSync12 } from "fs";
|
|
29457
29462
|
import { release } from "os";
|
|
29458
29463
|
import * as z70 from "zod";
|
|
29459
29464
|
var VmIdentitySchema = z70.object({
|
|
@@ -29487,11 +29492,11 @@ function writeVmIdentity(paths, identity) {
|
|
|
29487
29492
|
`);
|
|
29488
29493
|
}
|
|
29489
29494
|
function readVmIdentity(paths) {
|
|
29490
|
-
if (!
|
|
29495
|
+
if (!existsSync6(paths.vmIdentity)) {
|
|
29491
29496
|
return null;
|
|
29492
29497
|
}
|
|
29493
29498
|
try {
|
|
29494
|
-
return VmIdentitySchema.parse(JSON.parse(
|
|
29499
|
+
return VmIdentitySchema.parse(JSON.parse(readFileSync12(paths.vmIdentity, "utf8")));
|
|
29495
29500
|
} catch {
|
|
29496
29501
|
return null;
|
|
29497
29502
|
}
|
|
@@ -29567,7 +29572,7 @@ async function listDrivesInUse(db, findPaths) {
|
|
|
29567
29572
|
// packages/daemon/src/imps/ssh/authorized-keys.ts
|
|
29568
29573
|
var import_ssh2 = __toESM(require_lib2(), 1);
|
|
29569
29574
|
import { createHash as createHash2 } from "crypto";
|
|
29570
|
-
import { readFileSync as
|
|
29575
|
+
import { readFileSync as readFileSync13, statSync as statSync3 } from "fs";
|
|
29571
29576
|
import { dirname as dirname6 } from "path";
|
|
29572
29577
|
var KEY_TYPE = /^(?:ssh-ed25519|ssh-rsa|ecdsa-sha2-nistp(?:256|384|521))$/u;
|
|
29573
29578
|
function parseAuthorizedKeys(text) {
|
|
@@ -29642,7 +29647,7 @@ function readFileState(path, stamp) {
|
|
|
29642
29647
|
if (unsafe !== undefined) {
|
|
29643
29648
|
getImpdLogger("ssh").warning("{unsafe} is writable by group or others; no key can log in until it is not", { unsafe });
|
|
29644
29649
|
}
|
|
29645
|
-
const parsed = parseAuthorizedKeys(
|
|
29650
|
+
const parsed = parseAuthorizedKeys(readFileSync13(path, "utf8"));
|
|
29646
29651
|
for (const problem of parsed.problems) {
|
|
29647
29652
|
getImpdLogger("ssh").info("{path} {problem}; skipped", { path, problem });
|
|
29648
29653
|
}
|
|
@@ -29656,7 +29661,7 @@ import {
|
|
|
29656
29661
|
fsyncSync as fsyncSync2,
|
|
29657
29662
|
lstatSync as lstatSync2,
|
|
29658
29663
|
mkdirSync as mkdirSync6,
|
|
29659
|
-
readFileSync as
|
|
29664
|
+
readFileSync as readFileSync14,
|
|
29660
29665
|
readdirSync as readdirSync4,
|
|
29661
29666
|
renameSync as renameSync2,
|
|
29662
29667
|
rmSync as rmSync11
|
|
@@ -29680,7 +29685,7 @@ function createSecretFiles(dataDir, options = {}) {
|
|
|
29680
29685
|
},
|
|
29681
29686
|
read: (file) => {
|
|
29682
29687
|
try {
|
|
29683
|
-
return
|
|
29688
|
+
return readFileSync14(join11(directory, file), "utf8");
|
|
29684
29689
|
} catch (error) {
|
|
29685
29690
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
29686
29691
|
return null;
|
|
@@ -29847,13 +29852,13 @@ function isLoopback(address) {
|
|
|
29847
29852
|
|
|
29848
29853
|
// packages/daemon/src/network/tailnet-names/load-or-create-host-id.ts
|
|
29849
29854
|
import { randomBytes as randomBytes6 } from "crypto";
|
|
29850
|
-
import { existsSync as
|
|
29855
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync7, readFileSync as readFileSync15, writeFileSync as writeFileSync4 } from "fs";
|
|
29851
29856
|
import { join as join12 } from "path";
|
|
29852
29857
|
function loadOrCreateHostId(dataDir) {
|
|
29853
29858
|
const directory = join12(dataDir, "tailnet-names");
|
|
29854
29859
|
const path = join12(directory, "host-id");
|
|
29855
|
-
if (
|
|
29856
|
-
return
|
|
29860
|
+
if (existsSync7(path)) {
|
|
29861
|
+
return readFileSync15(path, "utf8").trim();
|
|
29857
29862
|
}
|
|
29858
29863
|
mkdirSync7(directory, { recursive: true });
|
|
29859
29864
|
const id = randomBytes6(16).toString("hex");
|
|
@@ -29863,7 +29868,7 @@ function loadOrCreateHostId(dataDir) {
|
|
|
29863
29868
|
}
|
|
29864
29869
|
|
|
29865
29870
|
// packages/daemon/src/network/tailnet-names/oauth-credential.ts
|
|
29866
|
-
import { readFileSync as
|
|
29871
|
+
import { readFileSync as readFileSync16, statSync as statSync4 } from "fs";
|
|
29867
29872
|
import * as z71 from "zod";
|
|
29868
29873
|
var CredentialSchema = z71.object({ clientId: z71.string().min(1), clientSecret: z71.string().min(1) });
|
|
29869
29874
|
function readOAuthCredential(path) {
|
|
@@ -29879,7 +29884,7 @@ function readOAuthCredential(path) {
|
|
|
29879
29884
|
}
|
|
29880
29885
|
function readJson(path) {
|
|
29881
29886
|
try {
|
|
29882
|
-
return JSON.parse(
|
|
29887
|
+
return JSON.parse(readFileSync16(path, "utf8"));
|
|
29883
29888
|
} catch {
|
|
29884
29889
|
return null;
|
|
29885
29890
|
}
|
|
@@ -30308,7 +30313,7 @@ async function startOtlpExport(env, version) {
|
|
|
30308
30313
|
|
|
30309
30314
|
// packages/daemon/src/surface/ssh/load-or-create-host-key.ts
|
|
30310
30315
|
var import_ssh22 = __toESM(require_lib2(), 1);
|
|
30311
|
-
import { existsSync as
|
|
30316
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync8, readFileSync as readFileSync17, writeFileSync as writeFileSync5 } from "fs";
|
|
30312
30317
|
import { join as join13 } from "path";
|
|
30313
30318
|
function setupSshDir(dataDir) {
|
|
30314
30319
|
const directory = join13(dataDir, "ssh");
|
|
@@ -30317,8 +30322,8 @@ function setupSshDir(dataDir) {
|
|
|
30317
30322
|
}
|
|
30318
30323
|
function loadOrCreateHostKey(sshDir) {
|
|
30319
30324
|
const path = join13(sshDir, "host_key");
|
|
30320
|
-
if (
|
|
30321
|
-
return
|
|
30325
|
+
if (existsSync8(path)) {
|
|
30326
|
+
return readFileSync17(path, "utf8");
|
|
30322
30327
|
}
|
|
30323
30328
|
const pair = generateEd25519Key();
|
|
30324
30329
|
writeFileSync5(path, pair.private, { mode: 384, flag: "wx" });
|
|
@@ -30343,12 +30348,12 @@ function readFingerprint(privateKey) {
|
|
|
30343
30348
|
}
|
|
30344
30349
|
|
|
30345
30350
|
// packages/daemon/src/vm/storage/create-storage-backend.ts
|
|
30346
|
-
import { existsSync as
|
|
30351
|
+
import { existsSync as existsSync15, readFileSync as readFileSync22, readdirSync as readdirSync9, writeFileSync as writeFileSync8 } from "fs";
|
|
30347
30352
|
import { join as join22 } from "path";
|
|
30348
30353
|
|
|
30349
30354
|
// packages/daemon/src/vm/storage/create-xfs-backend.ts
|
|
30350
30355
|
import {
|
|
30351
|
-
existsSync as
|
|
30356
|
+
existsSync as existsSync11,
|
|
30352
30357
|
mkdirSync as mkdirSync10,
|
|
30353
30358
|
readdirSync as readdirSync7,
|
|
30354
30359
|
renameSync as renameSync4,
|
|
@@ -30417,9 +30422,9 @@ async function createReflinkClone(source, target) {
|
|
|
30417
30422
|
// packages/daemon/src/vm/storage/create-xfs-backups.ts
|
|
30418
30423
|
import {
|
|
30419
30424
|
copyFileSync as copyFileSync3,
|
|
30420
|
-
existsSync as
|
|
30425
|
+
existsSync as existsSync9,
|
|
30421
30426
|
mkdirSync as mkdirSync9,
|
|
30422
|
-
readFileSync as
|
|
30427
|
+
readFileSync as readFileSync18,
|
|
30423
30428
|
readdirSync as readdirSync5,
|
|
30424
30429
|
renameSync as renameSync3,
|
|
30425
30430
|
rmSync as rmSync12,
|
|
@@ -30433,7 +30438,7 @@ function createXfsBackups(ctx) {
|
|
|
30433
30438
|
const freshCopies = new Set;
|
|
30434
30439
|
const readCopies = () => {
|
|
30435
30440
|
try {
|
|
30436
|
-
return CopiesSchema.parse(JSON.parse(
|
|
30441
|
+
return CopiesSchema.parse(JSON.parse(readFileSync18(backup.copies, "utf8")));
|
|
30437
30442
|
} catch {
|
|
30438
30443
|
return {};
|
|
30439
30444
|
}
|
|
@@ -30443,10 +30448,10 @@ function createXfsBackups(ctx) {
|
|
|
30443
30448
|
writeFileDurably(backup.copies, JSON.stringify(copies));
|
|
30444
30449
|
};
|
|
30445
30450
|
const createTreeClone = async (source, target) => {
|
|
30446
|
-
if (!
|
|
30451
|
+
if (!existsSync9(source)) {
|
|
30447
30452
|
return false;
|
|
30448
30453
|
}
|
|
30449
|
-
if (!
|
|
30454
|
+
if (!existsSync9(target)) {
|
|
30450
30455
|
mkdirSync9(dirname8(target), { recursive: true });
|
|
30451
30456
|
await ctx.cloneFile(source, `${target}.new`);
|
|
30452
30457
|
renameSync3(`${target}.new`, target);
|
|
@@ -30466,7 +30471,7 @@ function createXfsBackups(ctx) {
|
|
|
30466
30471
|
const copies = readCopies();
|
|
30467
30472
|
const last = copies[impId];
|
|
30468
30473
|
const isUnchanged = last?.ino === record.ino && last.ctimeNs === record.ctimeNs && last.size === record.size;
|
|
30469
|
-
if (options.isReusable && isUnchanged &&
|
|
30474
|
+
if (options.isReusable && isUnchanged && existsSync9(target)) {
|
|
30470
30475
|
return;
|
|
30471
30476
|
}
|
|
30472
30477
|
mkdirSync9(dirname8(target), { recursive: true });
|
|
@@ -30484,7 +30489,7 @@ function createXfsBackups(ctx) {
|
|
|
30484
30489
|
const checkpointIds = new Set;
|
|
30485
30490
|
const imageDigests = new Set;
|
|
30486
30491
|
for (const imp of request.imps) {
|
|
30487
|
-
if (!
|
|
30492
|
+
if (!existsSync9(join14(backup.tree, BACKUP_TREE.buildDisk(imp.impId)))) {
|
|
30488
30493
|
continue;
|
|
30489
30494
|
}
|
|
30490
30495
|
impIds.add(imp.impId);
|
|
@@ -30521,7 +30526,7 @@ function createXfsBackups(ctx) {
|
|
|
30521
30526
|
};
|
|
30522
30527
|
}
|
|
30523
30528
|
function removeUnlisted(directory, keep) {
|
|
30524
|
-
const names =
|
|
30529
|
+
const names = existsSync9(directory) ? readdirSync5(directory) : [];
|
|
30525
30530
|
for (const name of names.filter((entry) => !keep.has(entry))) {
|
|
30526
30531
|
rmSync12(join14(directory, name), { recursive: true, force: true });
|
|
30527
30532
|
}
|
|
@@ -30551,13 +30556,13 @@ function formatOrphan(orphan) {
|
|
|
30551
30556
|
}
|
|
30552
30557
|
|
|
30553
30558
|
// packages/daemon/src/vm/storage/probe-holding-files.ts
|
|
30554
|
-
import { existsSync as
|
|
30559
|
+
import { existsSync as existsSync10, readdirSync as readdirSync6, statSync as statSync6 } from "fs";
|
|
30555
30560
|
import { join as join15 } from "path";
|
|
30556
30561
|
function probeHoldingFiles(directory) {
|
|
30557
|
-
return
|
|
30562
|
+
return existsSync10(directory) && readdirSync6(directory, { recursive: true, withFileTypes: true }).some((entry) => !entry.isDirectory());
|
|
30558
30563
|
}
|
|
30559
30564
|
function listFilesUnder(directory) {
|
|
30560
|
-
if (!
|
|
30565
|
+
if (!existsSync10(directory)) {
|
|
30561
30566
|
return [];
|
|
30562
30567
|
}
|
|
30563
30568
|
return readdirSync6(directory, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => join15(entry.parentPath, entry.name));
|
|
@@ -30575,13 +30580,13 @@ function readDirectoryOrphan(kind, id, directory, snapshots) {
|
|
|
30575
30580
|
}
|
|
30576
30581
|
|
|
30577
30582
|
// packages/daemon/src/vm/storage/read-loop-host-free-bytes.ts
|
|
30578
|
-
import { readFileSync as
|
|
30583
|
+
import { readFileSync as readFileSync19, realpathSync, statfsSync } from "fs";
|
|
30579
30584
|
import { dirname as dirname9, join as join16 } from "path";
|
|
30580
30585
|
var HOST_DIRS = { procDir: "/proc", sysDir: "/sys" };
|
|
30581
30586
|
function readLoopBackingFile(directory, hostDirs = HOST_DIRS) {
|
|
30582
30587
|
try {
|
|
30583
30588
|
const target = realpathSync(directory);
|
|
30584
|
-
const mountInfo =
|
|
30589
|
+
const mountInfo = readFileSync19(join16(hostDirs.procDir, "self", "mountinfo"), "utf8");
|
|
30585
30590
|
for (const line of mountInfo.split(`
|
|
30586
30591
|
`)) {
|
|
30587
30592
|
const [mounts = "", fields = ""] = line.split(" - ");
|
|
@@ -30590,7 +30595,7 @@ function readLoopBackingFile(directory, hostDirs = HOST_DIRS) {
|
|
|
30590
30595
|
const loop = /^\/dev\/(?<name>loop\d+)$/u.exec(source)?.groups?.["name"];
|
|
30591
30596
|
if (mountPoint === target && loop !== undefined) {
|
|
30592
30597
|
const backing = join16(hostDirs.sysDir, "block", loop, "loop", "backing_file");
|
|
30593
|
-
return
|
|
30598
|
+
return readFileSync19(backing, "utf8").trim();
|
|
30594
30599
|
}
|
|
30595
30600
|
}
|
|
30596
30601
|
} catch {}
|
|
@@ -30635,7 +30640,7 @@ function createXfsBackend(deps) {
|
|
|
30635
30640
|
mkdirSync10(staged, { recursive: true });
|
|
30636
30641
|
try {
|
|
30637
30642
|
await write(staged);
|
|
30638
|
-
if (!
|
|
30643
|
+
if (!existsSync11(paths.rootfs)) {
|
|
30639
30644
|
rmSync13(paths.directory, { recursive: true, force: true });
|
|
30640
30645
|
}
|
|
30641
30646
|
renameSync4(staged, paths.directory);
|
|
@@ -30695,7 +30700,7 @@ function createXfsBackend(deps) {
|
|
|
30695
30700
|
const listImpFiles = (impId) => {
|
|
30696
30701
|
const paths = resolveImpPaths(impId);
|
|
30697
30702
|
const checkpoints = listEntries(paths.checkpointsDir).map((id) => buildCheckpointDisk(impId, id));
|
|
30698
|
-
return [paths.disk, ...checkpoints, paths.memFile, paths.vmstate].filter((path) =>
|
|
30703
|
+
return [paths.disk, ...checkpoints, paths.memFile, paths.vmstate].filter((path) => existsSync11(path)).map((path) => ({ owner: `imp:${impId}`, path }));
|
|
30699
30704
|
};
|
|
30700
30705
|
const listOtherFiles = () => {
|
|
30701
30706
|
const images = listEntries(buildImagesDir(deps.dataDir)).filter((name) => !name.startsWith(".")).map((name) => ({
|
|
@@ -30703,13 +30708,13 @@ function createXfsBackend(deps) {
|
|
|
30703
30708
|
path: join17(buildImagesDir(deps.dataDir), name, "rootfs.ext4")
|
|
30704
30709
|
}));
|
|
30705
30710
|
const tree = listFilesUnder(backup.tree).map((path) => ({ owner: "backup", path }));
|
|
30706
|
-
return [...images, ...tree].filter((file) =>
|
|
30711
|
+
return [...images, ...tree].filter((file) => existsSync11(file.path));
|
|
30707
30712
|
};
|
|
30708
30713
|
const usageState = { resumeImpId: null };
|
|
30709
30714
|
const setupReserveFile = async () => {
|
|
30710
30715
|
const bytes = deps.reserveFileBytes ?? 0;
|
|
30711
30716
|
const file = join17(deps.dataDir, "reserve");
|
|
30712
|
-
if (bytes === 0 ||
|
|
30717
|
+
if (bytes === 0 || existsSync11(file)) {
|
|
30713
30718
|
return;
|
|
30714
30719
|
}
|
|
30715
30720
|
const stats = statfsSync2(deps.dataDir);
|
|
@@ -30853,7 +30858,7 @@ function createXfsBackend(deps) {
|
|
|
30853
30858
|
measureImages: async (digests) => {
|
|
30854
30859
|
const deadline = Date.now() + USAGE_DEADLINE_MS;
|
|
30855
30860
|
const images = new Map;
|
|
30856
|
-
for (const digest of digests.filter((found) =>
|
|
30861
|
+
for (const digest of digests.filter((found) => existsSync11(buildImagePaths(deps.dataDir, found).directory))) {
|
|
30857
30862
|
const extents = [];
|
|
30858
30863
|
let isComplete = true;
|
|
30859
30864
|
for (const path of listFilesUnder(buildImagePaths(deps.dataDir, digest).directory)) {
|
|
@@ -30882,7 +30887,7 @@ function createXfsBackend(deps) {
|
|
|
30882
30887
|
};
|
|
30883
30888
|
}
|
|
30884
30889
|
function listEntries(directory) {
|
|
30885
|
-
return
|
|
30890
|
+
return existsSync11(directory) ? readdirSync7(directory).toSorted() : [];
|
|
30886
30891
|
}
|
|
30887
30892
|
function toStorage(entry) {
|
|
30888
30893
|
return { kind: entry.kind, id: entry.id };
|
|
@@ -30891,7 +30896,7 @@ async function readOwnedExtents(readFileExtents, path, deadline) {
|
|
|
30891
30896
|
try {
|
|
30892
30897
|
return await readFileExtents(path, deadline);
|
|
30893
30898
|
} catch (error) {
|
|
30894
|
-
if (
|
|
30899
|
+
if (existsSync11(path)) {
|
|
30895
30900
|
throw error;
|
|
30896
30901
|
}
|
|
30897
30902
|
return { extents: [], isComplete: true };
|
|
@@ -30902,7 +30907,7 @@ function isSharedExtent(extent) {
|
|
|
30902
30907
|
}
|
|
30903
30908
|
|
|
30904
30909
|
// packages/daemon/src/vm/storage/zfs/zfs-backend.ts
|
|
30905
|
-
import { existsSync as
|
|
30910
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync11, readFileSync as readFileSync21, rmdirSync, writeFileSync as writeFileSync7 } from "fs";
|
|
30906
30911
|
import { join as join21 } from "path";
|
|
30907
30912
|
|
|
30908
30913
|
// packages/daemon/src/platform/process/create-stream-runner.ts
|
|
@@ -30958,9 +30963,9 @@ async function requireExitZero(argv, exited, stderr) {
|
|
|
30958
30963
|
}
|
|
30959
30964
|
|
|
30960
30965
|
// packages/daemon/src/platform/process/read-mounts.ts
|
|
30961
|
-
import { readFileSync as
|
|
30966
|
+
import { readFileSync as readFileSync20 } from "fs";
|
|
30962
30967
|
function readMounts() {
|
|
30963
|
-
return
|
|
30968
|
+
return readFileSync20("/proc/self/mounts", "utf8");
|
|
30964
30969
|
}
|
|
30965
30970
|
function parseMounts(mounts) {
|
|
30966
30971
|
return mounts.split(`
|
|
@@ -31666,7 +31671,7 @@ function createZfsReclaim(ctx) {
|
|
|
31666
31671
|
}
|
|
31667
31672
|
|
|
31668
31673
|
// packages/daemon/src/vm/storage/zfs/create-zfs-sweep.ts
|
|
31669
|
-
import { existsSync as
|
|
31674
|
+
import { existsSync as existsSync12, readdirSync as readdirSync8, rmSync as rmSync15 } from "fs";
|
|
31670
31675
|
import { join as join20 } from "path";
|
|
31671
31676
|
var FORK_SNAPSHOT = /@fork-[^@]+$/u;
|
|
31672
31677
|
var BACKUP_SNAPSHOT = /@bk-[^@]+$/u;
|
|
@@ -31692,7 +31697,7 @@ function createZfsSweep(ctx) {
|
|
|
31692
31697
|
const orphanCheckpoints = isOrphans ? [] : unmarked.filter((entry) => !isOnOrphan(entry) && isOrphanCheckpoint(entry));
|
|
31693
31698
|
const keptDisks = isOrphans ? [] : unknownDisks;
|
|
31694
31699
|
const keptImpIds = new Set(keptDisks.map((disk) => getChildId(disk.name, ctx.datasets.disks)));
|
|
31695
|
-
const listUnknownDirs = (kind, parent) => (
|
|
31700
|
+
const listUnknownDirs = (kind, parent) => (existsSync12(parent) ? readdirSync8(parent).toSorted() : []).filter((id) => !live.impIds.has(id) && !keptImpIds.has(id)).map((id) => ({ kind, id, directory: join20(parent, id) }));
|
|
31696
31701
|
const unknownDirs = [
|
|
31697
31702
|
...listUnknownDirs("imp", buildImpsDir(ctx.dataDir)),
|
|
31698
31703
|
...listUnknownDirs("memory", join20(ctx.dataDir, "mem"))
|
|
@@ -31795,7 +31800,7 @@ function getSnapshotDataset(name) {
|
|
|
31795
31800
|
}
|
|
31796
31801
|
|
|
31797
31802
|
// packages/daemon/src/vm/storage/zfs/create-zfs-usage.ts
|
|
31798
|
-
import { existsSync as
|
|
31803
|
+
import { existsSync as existsSync13, statSync as statSync8 } from "fs";
|
|
31799
31804
|
function createZfsUsage(ctx) {
|
|
31800
31805
|
return {
|
|
31801
31806
|
measureUsage: async (imps) => {
|
|
@@ -31843,7 +31848,7 @@ function createZfsUsage(ctx) {
|
|
|
31843
31848
|
};
|
|
31844
31849
|
}
|
|
31845
31850
|
function readAllocatedBytes(path) {
|
|
31846
|
-
return
|
|
31851
|
+
return existsSync13(path) ? statSync8(path).blocks * 512 : 0;
|
|
31847
31852
|
}
|
|
31848
31853
|
|
|
31849
31854
|
// packages/daemon/src/vm/storage/zfs/zfs-backend.ts
|
|
@@ -32183,13 +32188,13 @@ function createZfsBackend(deps) {
|
|
|
32183
32188
|
}
|
|
32184
32189
|
function readZfsModuleVersion() {
|
|
32185
32190
|
try {
|
|
32186
|
-
return
|
|
32191
|
+
return readFileSync21("/sys/module/zfs/version", "utf8").trim();
|
|
32187
32192
|
} catch {
|
|
32188
32193
|
return null;
|
|
32189
32194
|
}
|
|
32190
32195
|
}
|
|
32191
32196
|
function removeMountDir(directory) {
|
|
32192
|
-
if (
|
|
32197
|
+
if (existsSync14(directory)) {
|
|
32193
32198
|
rmdirSync(directory);
|
|
32194
32199
|
}
|
|
32195
32200
|
}
|
|
@@ -32227,21 +32232,21 @@ function createBackend(config, boundaries) {
|
|
|
32227
32232
|
}
|
|
32228
32233
|
function checkStorageMarker(dataDir, kind) {
|
|
32229
32234
|
const marker = join22(dataDir, MARKER_FILE);
|
|
32230
|
-
const recorded =
|
|
32235
|
+
const recorded = existsSync15(marker) ? readFileSync22(marker, "utf8").trim() : readUnmarked(dataDir);
|
|
32231
32236
|
if (recorded !== null && recorded !== kind) {
|
|
32232
32237
|
throw new Error(`${dataDir} holds ${recorded} storage, but IMP_STORAGE_BACKEND is ${kind}; moving imps between backends is not supported`);
|
|
32233
32238
|
}
|
|
32234
32239
|
}
|
|
32235
32240
|
function writeStorageMarker(dataDir, kind) {
|
|
32236
32241
|
const marker = join22(dataDir, MARKER_FILE);
|
|
32237
|
-
if (!
|
|
32242
|
+
if (!existsSync15(marker)) {
|
|
32238
32243
|
writeFileSync8(marker, `${kind}
|
|
32239
32244
|
`);
|
|
32240
32245
|
}
|
|
32241
32246
|
}
|
|
32242
32247
|
function readUnmarked(dataDir) {
|
|
32243
32248
|
const imps = buildImpsDir(dataDir);
|
|
32244
|
-
const hasImps =
|
|
32249
|
+
const hasImps = existsSync15(imps) && readdirSync9(imps).length > 0;
|
|
32245
32250
|
return hasImps ? "xfs" : null;
|
|
32246
32251
|
}
|
|
32247
32252
|
|
|
@@ -32275,7 +32280,7 @@ async function readLiveStorage(db) {
|
|
|
32275
32280
|
}
|
|
32276
32281
|
|
|
32277
32282
|
// packages/daemon/src/vm/storage/setup-system-files.ts
|
|
32278
|
-
import { existsSync as
|
|
32283
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync12, readFileSync as readFileSync23 } from "fs";
|
|
32279
32284
|
import { dirname as dirname12 } from "path";
|
|
32280
32285
|
|
|
32281
32286
|
// packages/daemon/src/vm/storage/system-file-info.ts
|
|
@@ -32307,21 +32312,21 @@ function deriveSha256(data) {
|
|
|
32307
32312
|
// packages/daemon/src/vm/storage/setup-system-files.ts
|
|
32308
32313
|
async function setupSystemFiles(config) {
|
|
32309
32314
|
const kernelSource = config.kernelSource ?? config.kernelPath;
|
|
32310
|
-
if (!
|
|
32315
|
+
if (!existsSync16(kernelSource)) {
|
|
32311
32316
|
const missing = config.kernelSource === null ? " and no source is configured" : "";
|
|
32312
32317
|
throw new Error(`${kernelSource} does not exist${missing}`);
|
|
32313
32318
|
}
|
|
32314
|
-
const kernel =
|
|
32319
|
+
const kernel = readFileSync23(kernelSource);
|
|
32315
32320
|
const guestKernel = readKernelInfo(kernel);
|
|
32316
32321
|
if (config.kernelSource !== null && !probeContent(config.kernelPath, kernel)) {
|
|
32317
32322
|
writeCopy(config.kernelSource, config.kernelPath);
|
|
32318
32323
|
}
|
|
32319
|
-
if (!
|
|
32324
|
+
if (!existsSync16(config.systemDriveSource)) {
|
|
32320
32325
|
throw new Error(`${config.systemDriveSource} does not exist`);
|
|
32321
32326
|
}
|
|
32322
32327
|
const sha256 = await deriveFileSha256(config.systemDriveSource);
|
|
32323
32328
|
const systemDrivePath = buildSystemDrivePath(config.dataDir, sha256);
|
|
32324
|
-
if (!
|
|
32329
|
+
if (!existsSync16(systemDrivePath)) {
|
|
32325
32330
|
writeCopy(config.systemDriveSource, systemDrivePath);
|
|
32326
32331
|
}
|
|
32327
32332
|
return {
|
|
@@ -32331,7 +32336,7 @@ async function setupSystemFiles(config) {
|
|
|
32331
32336
|
};
|
|
32332
32337
|
}
|
|
32333
32338
|
function probeContent(path, content) {
|
|
32334
|
-
return
|
|
32339
|
+
return existsSync16(path) && Buffer.from(content).equals(readFileSync23(path));
|
|
32335
32340
|
}
|
|
32336
32341
|
function writeCopy(source, target) {
|
|
32337
32342
|
mkdirSync12(dirname12(target), { recursive: true });
|
|
@@ -32350,13 +32355,13 @@ async function writeImageFiles(files, directory) {
|
|
|
32350
32355
|
}
|
|
32351
32356
|
|
|
32352
32357
|
// packages/daemon/src/vm/vmm/read-huge-page-pool.ts
|
|
32353
|
-
import { readFileSync as
|
|
32358
|
+
import { readFileSync as readFileSync24 } from "fs";
|
|
32354
32359
|
import { join as join24 } from "path";
|
|
32355
32360
|
var HUGE_PAGE_MIB = 2;
|
|
32356
32361
|
function readHugePagePool(sysRoot = "/sys") {
|
|
32357
32362
|
const directory = join24(sysRoot, "kernel", "mm", "hugepages", "hugepages-2048kB");
|
|
32358
32363
|
try {
|
|
32359
|
-
const readCount = (name) => Number(
|
|
32364
|
+
const readCount = (name) => Number(readFileSync24(join24(directory, name), "utf8").trim());
|
|
32360
32365
|
const total = readCount("nr_hugepages");
|
|
32361
32366
|
const free = readCount("free_hugepages") - readCount("resv_hugepages");
|
|
32362
32367
|
if (!Number.isSafeInteger(total) || !Number.isSafeInteger(free)) {
|
|
@@ -32369,7 +32374,7 @@ function readHugePagePool(sysRoot = "/sys") {
|
|
|
32369
32374
|
}
|
|
32370
32375
|
|
|
32371
32376
|
// packages/daemon/src/vm/vmm/read-ksm-host-stats.ts
|
|
32372
|
-
import { readFileSync as
|
|
32377
|
+
import { readFileSync as readFileSync25 } from "fs";
|
|
32373
32378
|
import { readFile as readFile3 } from "fs/promises";
|
|
32374
32379
|
var KSM_DIR = "/sys/kernel/mm/ksm";
|
|
32375
32380
|
var PAGE_BYTES = 4096;
|
|
@@ -32397,12 +32402,12 @@ function readKsmHostStats(directory = KSM_DIR) {
|
|
|
32397
32402
|
try {
|
|
32398
32403
|
const readCount = (name) => {
|
|
32399
32404
|
try {
|
|
32400
|
-
return Number(
|
|
32405
|
+
return Number(readFileSync25(`${directory}/${name}`, "utf8").trim());
|
|
32401
32406
|
} catch {
|
|
32402
32407
|
return 0;
|
|
32403
32408
|
}
|
|
32404
32409
|
};
|
|
32405
|
-
const run =
|
|
32410
|
+
const run = readFileSync25(`${directory}/run`, "utf8").trim();
|
|
32406
32411
|
return {
|
|
32407
32412
|
running: run === "1",
|
|
32408
32413
|
sharedMib: Math.round(readCount("pages_sharing") * PAGE_BYTES / MIB2),
|
|
@@ -35309,7 +35314,7 @@ import { ORPCError as ORPCError3 } from "@orpc/server";
|
|
|
35309
35314
|
import invariant9 from "tiny-invariant";
|
|
35310
35315
|
|
|
35311
35316
|
// packages/daemon/src/surface/to-api-image.ts
|
|
35312
|
-
function toApiImage(image) {
|
|
35317
|
+
function toApiImage(image, aliases) {
|
|
35313
35318
|
return {
|
|
35314
35319
|
id: image.id,
|
|
35315
35320
|
name: image.name,
|
|
@@ -35318,16 +35323,22 @@ function toApiImage(image) {
|
|
|
35318
35323
|
source: image.source,
|
|
35319
35324
|
createdAt: image.createdAt,
|
|
35320
35325
|
sizeBytes: image.sizeBytes,
|
|
35321
|
-
pinned: image.isPinned
|
|
35326
|
+
pinned: image.isPinned,
|
|
35327
|
+
aliases: [...aliases]
|
|
35322
35328
|
};
|
|
35323
35329
|
}
|
|
35324
35330
|
|
|
35325
35331
|
// packages/daemon/src/surface/create-image-routes.ts
|
|
35326
35332
|
function createImageRoutes(os, deps) {
|
|
35333
|
+
const readApiImage = async (image) => {
|
|
35334
|
+
const aliases = await deps.images.listImageAliases([image.id]);
|
|
35335
|
+
return toApiImage(image, aliases.get(image.id) ?? []);
|
|
35336
|
+
};
|
|
35327
35337
|
return {
|
|
35328
35338
|
list: os.images.list.handler(async () => {
|
|
35329
35339
|
const images = await deps.images.listImages();
|
|
35330
|
-
|
|
35340
|
+
const aliases = await deps.images.listImageAliases(images.map((image) => image.id));
|
|
35341
|
+
return images.map((image) => toApiImage(image, aliases.get(image.id) ?? []));
|
|
35331
35342
|
}),
|
|
35332
35343
|
add: os.images.add.handler(async (context) => {
|
|
35333
35344
|
const input = context.input;
|
|
@@ -35336,7 +35347,7 @@ function createImageRoutes(os, deps) {
|
|
|
35336
35347
|
context.context.auditDetail.value = reference;
|
|
35337
35348
|
};
|
|
35338
35349
|
const image = "imp" in input ? await deps.templates.createTemplate(input.imp, input.name) : await deps.images.addImage(input.ref, input.name, { signal, onResolved });
|
|
35339
|
-
return
|
|
35350
|
+
return readApiImage(image);
|
|
35340
35351
|
}),
|
|
35341
35352
|
addStream: os.images.addStream.handler((context) => {
|
|
35342
35353
|
const input = context.input;
|
|
@@ -35350,7 +35361,7 @@ function createImageRoutes(os, deps) {
|
|
|
35350
35361
|
setPhase: report.setPhase,
|
|
35351
35362
|
onResolved
|
|
35352
35363
|
});
|
|
35353
|
-
return
|
|
35364
|
+
return readApiImage(image);
|
|
35354
35365
|
}, buildImageOpOptions(deps, context, "images.addStream", firstPhase));
|
|
35355
35366
|
}),
|
|
35356
35367
|
buildStream: os.images.buildStream.handler((context) => {
|
|
@@ -35378,7 +35389,7 @@ function createImageRoutes(os, deps) {
|
|
|
35378
35389
|
},
|
|
35379
35390
|
setBuilder: run.setBuilder
|
|
35380
35391
|
});
|
|
35381
|
-
return
|
|
35392
|
+
return await readApiImage(image);
|
|
35382
35393
|
} finally {
|
|
35383
35394
|
upload.release();
|
|
35384
35395
|
}
|
|
@@ -35390,13 +35401,13 @@ function createImageRoutes(os, deps) {
|
|
|
35390
35401
|
setPhase: report.setPhase,
|
|
35391
35402
|
output: report.output
|
|
35392
35403
|
});
|
|
35393
|
-
return
|
|
35404
|
+
return readApiImage(image);
|
|
35394
35405
|
}), { ...buildImageOpOptions(deps, context, "images.buildStream", "pack"), logs });
|
|
35395
35406
|
}),
|
|
35396
35407
|
builds: os.images.builds.handler(() => deps.images.listBuildRuns()),
|
|
35397
35408
|
build: os.images.build.handler(async (context) => {
|
|
35398
35409
|
const image = await deps.images.runImageBuild(context.input.contextDir, context.input.name, context.input.dockerfile, { ...context.signal !== undefined && { signal: context.signal } });
|
|
35399
|
-
return
|
|
35410
|
+
return readApiImage(image);
|
|
35400
35411
|
}),
|
|
35401
35412
|
delete: os.images.delete.handler(async (context) => {
|
|
35402
35413
|
await deps.images.removeImage(context.input.name);
|
|
@@ -35404,11 +35415,19 @@ function createImageRoutes(os, deps) {
|
|
|
35404
35415
|
}),
|
|
35405
35416
|
pin: os.images.pin.handler(async (context) => {
|
|
35406
35417
|
const image = await deps.images.updateImagePin(context.input.name, true, findPinRefPrefix(context.context.caller));
|
|
35407
|
-
return
|
|
35418
|
+
return readApiImage(image);
|
|
35408
35419
|
}),
|
|
35409
35420
|
unpin: os.images.unpin.handler(async (context) => {
|
|
35410
35421
|
const image = await deps.images.updateImagePin(context.input.name, false, findPinRefPrefix(context.context.caller));
|
|
35411
|
-
return
|
|
35422
|
+
return readApiImage(image);
|
|
35423
|
+
}),
|
|
35424
|
+
alias: os.images.alias.handler(async (context) => {
|
|
35425
|
+
const image = await deps.images.updateImageAlias(context.input.alias, context.input.image);
|
|
35426
|
+
return readApiImage(image);
|
|
35427
|
+
}),
|
|
35428
|
+
unalias: os.images.unalias.handler(async (context) => {
|
|
35429
|
+
await deps.images.removeImageAlias(context.input.alias);
|
|
35430
|
+
return {};
|
|
35412
35431
|
})
|
|
35413
35432
|
};
|
|
35414
35433
|
}
|
|
@@ -35464,14 +35483,12 @@ function createImpRoutes(os, deps, views) {
|
|
|
35464
35483
|
if (networks !== undefined && caller.imps !== null) {
|
|
35465
35484
|
throw buildForbiddenError(`${formatCaller(caller)} is limited to some imps, so it cannot put an imp on a network`);
|
|
35466
35485
|
}
|
|
35467
|
-
|
|
35468
|
-
|
|
35469
|
-
|
|
35470
|
-
throw buildForbiddenError(`${formatCaller(caller)} may not copy imp ${image.sourceImp}, the source of template ${image.name}`);
|
|
35471
|
-
}
|
|
35486
|
+
const image = await deps.images.resolveImage(input.image);
|
|
35487
|
+
if (caller.imps !== null && image.sourceImp !== null && !isCallerAllowed(caller, "manage", image.sourceImp)) {
|
|
35488
|
+
throw buildForbiddenError(`${formatCaller(caller)} may not copy imp ${image.sourceImp}, the source of template ${image.name}`);
|
|
35472
35489
|
}
|
|
35473
35490
|
const networkIds = await deps.networks.resolveNetworkIds(networks ?? []);
|
|
35474
|
-
return views.readCallerImp(caller, deps.imps.createImp({ ...input, networkIds, isBackedUp: backup }));
|
|
35491
|
+
return views.readCallerImp(caller, deps.imps.createImp({ ...input, image, networkIds, isBackedUp: backup }));
|
|
35475
35492
|
}),
|
|
35476
35493
|
list: os.imps.list.handler(async (context) => {
|
|
35477
35494
|
const caller = context.context.caller;
|
|
@@ -38685,7 +38702,7 @@ function buildHostReach(ranges, uplinks, hasIPv6) {
|
|
|
38685
38702
|
}
|
|
38686
38703
|
|
|
38687
38704
|
// packages/daemon/src/host-net/net/read-uplinks.ts
|
|
38688
|
-
import { existsSync as
|
|
38705
|
+
import { existsSync as existsSync17 } from "fs";
|
|
38689
38706
|
var NON_UNICAST = new Set([
|
|
38690
38707
|
"local",
|
|
38691
38708
|
"broadcast",
|
|
@@ -38738,7 +38755,7 @@ function parseConnectedPrefixes(family, routes, addresses) {
|
|
|
38738
38755
|
}
|
|
38739
38756
|
async function readUplinks(procNet = "/proc/sys/net/ipv6", run = runChecked) {
|
|
38740
38757
|
const ipv4 = await run(["ip", "-4", "route", "show", "default"]);
|
|
38741
|
-
const ipv6 =
|
|
38758
|
+
const ipv6 = existsSync17(procNet) ? await run(["ip", "-6", "route", "show", "default"]) : "";
|
|
38742
38759
|
return { ipv4: parseUplinks(ipv4), ipv6: parseUplinks(ipv6) };
|
|
38743
38760
|
}
|
|
38744
38761
|
async function readIpv6DefaultRoute(run = runCommand) {
|
|
@@ -39267,9 +39284,9 @@ async function runBundleInstall(vsockPath, input, options = {}) {
|
|
|
39267
39284
|
import { createPrivateKey, generateKeyPairSync } from "crypto";
|
|
39268
39285
|
import {
|
|
39269
39286
|
chmodSync as chmodSync4,
|
|
39270
|
-
existsSync as
|
|
39287
|
+
existsSync as existsSync18,
|
|
39271
39288
|
mkdirSync as mkdirSync14,
|
|
39272
|
-
readFileSync as
|
|
39289
|
+
readFileSync as readFileSync26,
|
|
39273
39290
|
renameSync as renameSync5,
|
|
39274
39291
|
rmSync as rmSync17,
|
|
39275
39292
|
writeFileSync as writeFileSync10
|
|
@@ -39397,8 +39414,8 @@ function loadOrCreateIdentity(deps) {
|
|
|
39397
39414
|
};
|
|
39398
39415
|
}
|
|
39399
39416
|
function readOrCreateKey(path) {
|
|
39400
|
-
if (
|
|
39401
|
-
return buildIdentityKey(createPrivateKey(
|
|
39417
|
+
if (existsSync18(path)) {
|
|
39418
|
+
return buildIdentityKey(createPrivateKey(readFileSync26(path, "utf8")));
|
|
39402
39419
|
}
|
|
39403
39420
|
const key = buildIdentityKey(generateKeyPairSync("ec", { namedCurve: "P-256" }).privateKey);
|
|
39404
39421
|
writeKeyFile(path, key);
|
|
@@ -39410,14 +39427,14 @@ function writeKeyFile(path, key) {
|
|
|
39410
39427
|
}
|
|
39411
39428
|
var NextSchema = z82.object({ switchAtSeconds: z82.int().nonnegative() });
|
|
39412
39429
|
function readStagedKey(paths) {
|
|
39413
|
-
if (!
|
|
39430
|
+
if (!existsSync18(paths.next) || !existsSync18(paths.nextTime)) {
|
|
39414
39431
|
rmSync17(paths.next, { force: true });
|
|
39415
39432
|
rmSync17(paths.nextTime, { force: true });
|
|
39416
39433
|
return null;
|
|
39417
39434
|
}
|
|
39418
|
-
const time = NextSchema.parse(JSON.parse(
|
|
39435
|
+
const time = NextSchema.parse(JSON.parse(readFileSync26(paths.nextTime, "utf8")));
|
|
39419
39436
|
return {
|
|
39420
|
-
key: buildIdentityKey(createPrivateKey(
|
|
39437
|
+
key: buildIdentityKey(createPrivateKey(readFileSync26(paths.next, "utf8"))),
|
|
39421
39438
|
switchAtSeconds: time.switchAtSeconds
|
|
39422
39439
|
};
|
|
39423
39440
|
}
|
|
@@ -41361,7 +41378,7 @@ async function removeRecordedFiles(db, files, valueFiles) {
|
|
|
41361
41378
|
// packages/daemon/src/network/broker/tls/broker-ca.ts
|
|
41362
41379
|
import"reflect-metadata";
|
|
41363
41380
|
import { createPrivateKey as createPrivateKey2, randomBytes as randomBytes10 } from "crypto";
|
|
41364
|
-
import { chmodSync as chmodSync5, existsSync as
|
|
41381
|
+
import { chmodSync as chmodSync5, existsSync as existsSync19, mkdirSync as mkdirSync16, readFileSync as readFileSync27, writeFileSync as writeFileSync11 } from "fs";
|
|
41365
41382
|
import { join as join30 } from "path";
|
|
41366
41383
|
import * as x509 from "@peculiar/x509";
|
|
41367
41384
|
var ALGORITHM = { name: "ECDSA", namedCurve: "P-256", hash: "SHA-256" };
|
|
@@ -41373,14 +41390,14 @@ async function loadOrCreateBrokerCa(directory, now = Date.now) {
|
|
|
41373
41390
|
chmodSync5(directory, 448);
|
|
41374
41391
|
const certPath = join30(directory, "ca.pem");
|
|
41375
41392
|
const keyPath = join30(directory, "ca.key");
|
|
41376
|
-
if (!
|
|
41393
|
+
if (!existsSync19(certPath) || !existsSync19(keyPath)) {
|
|
41377
41394
|
const created = await createCa(now());
|
|
41378
41395
|
writeFileSync11(keyPath, created.keyPem, { mode: 384 });
|
|
41379
41396
|
writeFileSync11(certPath, created.certPem, { mode: 420 });
|
|
41380
41397
|
}
|
|
41381
|
-
const certPem =
|
|
41398
|
+
const certPem = readFileSync27(certPath, "utf8");
|
|
41382
41399
|
const ca = new x509.X509Certificate(certPem);
|
|
41383
|
-
const signingKey = await parsePrivateKey(
|
|
41400
|
+
const signingKey = await parsePrivateKey(readFileSync27(keyPath, "utf8"));
|
|
41384
41401
|
const authorityKeyId = await x509.AuthorityKeyIdentifierExtension.create(ca);
|
|
41385
41402
|
return {
|
|
41386
41403
|
certPem,
|
|
@@ -41675,7 +41692,7 @@ function resolvePublicUpstream(host) {
|
|
|
41675
41692
|
}
|
|
41676
41693
|
|
|
41677
41694
|
// packages/daemon/src/network/create-upstream-resolver.ts
|
|
41678
|
-
import { readFileSync as
|
|
41695
|
+
import { readFileSync as readFileSync28, statSync as statSync11 } from "fs";
|
|
41679
41696
|
import { rootCertificates as rootCertificates2 } from "tls";
|
|
41680
41697
|
import * as z85 from "zod";
|
|
41681
41698
|
var FileSchema = z85.object({
|
|
@@ -41699,7 +41716,7 @@ function createUpstreamResolver(path) {
|
|
|
41699
41716
|
if (mtimeMs !== cache.mtimeMs) {
|
|
41700
41717
|
cache.mtimeMs = mtimeMs;
|
|
41701
41718
|
try {
|
|
41702
|
-
cache.file = FileSchema.parse(JSON.parse(
|
|
41719
|
+
cache.file = FileSchema.parse(JSON.parse(readFileSync28(path, "utf8")));
|
|
41703
41720
|
const hosts = Object.keys(cache.file.upstreams).join(", ");
|
|
41704
41721
|
getImpdLogger("broker").warning("test upstreams from {path} stand in for {hosts}", {
|
|
41705
41722
|
path,
|
|
@@ -43111,17 +43128,17 @@ async function createImpdFirewall(config, deps, secretFiles, plan) {
|
|
|
43111
43128
|
}
|
|
43112
43129
|
|
|
43113
43130
|
// packages/daemon/src/impd/create-impd-imps.ts
|
|
43114
|
-
import { readFileSync as
|
|
43131
|
+
import { readFileSync as readFileSync35 } from "fs";
|
|
43115
43132
|
import { availableParallelism } from "os";
|
|
43116
43133
|
|
|
43117
43134
|
// packages/daemon/src/host-net/net/read-guest-net-bytes.ts
|
|
43118
|
-
import { readFileSync as
|
|
43135
|
+
import { readFileSync as readFileSync29 } from "fs";
|
|
43119
43136
|
import { join as join33 } from "path";
|
|
43120
43137
|
function readGuestNetBytes(tap, sysRoot = "/sys") {
|
|
43121
43138
|
const statistics = join33(sysRoot, "class", "net", tap, "statistics");
|
|
43122
43139
|
try {
|
|
43123
|
-
const hostRx = Number(
|
|
43124
|
-
const hostTx = Number(
|
|
43140
|
+
const hostRx = Number(readFileSync29(join33(statistics, "rx_bytes"), "utf8"));
|
|
43141
|
+
const hostTx = Number(readFileSync29(join33(statistics, "tx_bytes"), "utf8"));
|
|
43125
43142
|
return { rxBytes: hostTx, txBytes: hostRx };
|
|
43126
43143
|
} catch {
|
|
43127
43144
|
return null;
|
|
@@ -43129,10 +43146,10 @@ function readGuestNetBytes(tap, sysRoot = "/sys") {
|
|
|
43129
43146
|
}
|
|
43130
43147
|
|
|
43131
43148
|
// packages/daemon/src/host-net/net/tap-devices.ts
|
|
43132
|
-
import { readFileSync as
|
|
43149
|
+
import { readFileSync as readFileSync30 } from "fs";
|
|
43133
43150
|
function readTapMac(tap) {
|
|
43134
43151
|
try {
|
|
43135
|
-
return
|
|
43152
|
+
return readFileSync30(`/sys/class/net/${tap}/address`, "utf8").trim();
|
|
43136
43153
|
} catch {
|
|
43137
43154
|
return null;
|
|
43138
43155
|
}
|
|
@@ -43199,8 +43216,8 @@ function readTapOwner(tap) {
|
|
|
43199
43216
|
try {
|
|
43200
43217
|
const directory = `/sys/class/net/${tap}`;
|
|
43201
43218
|
return {
|
|
43202
|
-
uid: Number(
|
|
43203
|
-
gid: Number(
|
|
43219
|
+
uid: Number(readFileSync30(`${directory}/owner`, "utf8").trim()),
|
|
43220
|
+
gid: Number(readFileSync30(`${directory}/group`, "utf8").trim())
|
|
43204
43221
|
};
|
|
43205
43222
|
} catch {
|
|
43206
43223
|
return null;
|
|
@@ -44107,7 +44124,7 @@ function createImpCommands(parts) {
|
|
|
44107
44124
|
return {
|
|
44108
44125
|
createImp: async (input) => {
|
|
44109
44126
|
const received = performance.now();
|
|
44110
|
-
const image =
|
|
44127
|
+
const image = input.image;
|
|
44111
44128
|
if (input.policy !== undefined) {
|
|
44112
44129
|
context.egress.requirePolicy(input.policy);
|
|
44113
44130
|
}
|
|
@@ -44445,7 +44462,8 @@ function createDiskBudget(deps) {
|
|
|
44445
44462
|
}
|
|
44446
44463
|
|
|
44447
44464
|
// packages/daemon/src/vm/storage/storage-gate.ts
|
|
44448
|
-
|
|
44465
|
+
import { systemClock as systemClock3 } from "@zgeoff/std";
|
|
44466
|
+
function createStorageGate(clock = systemClock3) {
|
|
44449
44467
|
const state = {
|
|
44450
44468
|
inFlight: 0,
|
|
44451
44469
|
waiting: 0,
|
|
@@ -44483,7 +44501,7 @@ function createStorageGate(clock = REAL_CLOCK) {
|
|
|
44483
44501
|
return { ran: false };
|
|
44484
44502
|
}
|
|
44485
44503
|
const expired = Promise.withResolvers();
|
|
44486
|
-
const cancel = clock.
|
|
44504
|
+
const cancel = clock.schedule(() => {
|
|
44487
44505
|
expired.resolve();
|
|
44488
44506
|
}, left);
|
|
44489
44507
|
try {
|
|
@@ -44512,9 +44530,9 @@ function createStorageGate(clock = REAL_CLOCK) {
|
|
|
44512
44530
|
|
|
44513
44531
|
// packages/daemon/src/vm/templates/boot-templates.ts
|
|
44514
44532
|
import {
|
|
44515
|
-
existsSync as
|
|
44533
|
+
existsSync as existsSync20,
|
|
44516
44534
|
mkdirSync as mkdirSync19,
|
|
44517
|
-
readFileSync as
|
|
44535
|
+
readFileSync as readFileSync31,
|
|
44518
44536
|
readdirSync as readdirSync10,
|
|
44519
44537
|
renameSync as renameSync6,
|
|
44520
44538
|
rmSync as rmSync21,
|
|
@@ -44754,7 +44772,7 @@ function createBootTemplates(deps) {
|
|
|
44754
44772
|
};
|
|
44755
44773
|
const readMeta = (key) => {
|
|
44756
44774
|
try {
|
|
44757
|
-
const text =
|
|
44775
|
+
const text = readFileSync31(join34(root, key, "meta.json"), "utf8");
|
|
44758
44776
|
return TemplateMetaSchema.parse(JSON.parse(text));
|
|
44759
44777
|
} catch {
|
|
44760
44778
|
return null;
|
|
@@ -44768,7 +44786,7 @@ function createBootTemplates(deps) {
|
|
|
44768
44786
|
const directory = join34(root, key);
|
|
44769
44787
|
const meta = readMeta(key);
|
|
44770
44788
|
const files = { vmstate: join34(directory, "vmstate"), memFile: join34(directory, "mem") };
|
|
44771
|
-
if (meta === null || !
|
|
44789
|
+
if (meta === null || !existsSync20(files.vmstate) || !existsSync20(files.memFile)) {
|
|
44772
44790
|
return null;
|
|
44773
44791
|
}
|
|
44774
44792
|
return {
|
|
@@ -44780,7 +44798,7 @@ function createBootTemplates(deps) {
|
|
|
44780
44798
|
placeholderPath: placeholder
|
|
44781
44799
|
};
|
|
44782
44800
|
};
|
|
44783
|
-
const listTemplateKeys = () =>
|
|
44801
|
+
const listTemplateKeys = () => existsSync20(root) ? readdirSync10(root).filter((name) => name !== PLACEHOLDER_NAME && !name.startsWith(".")) : [];
|
|
44784
44802
|
const removeDir = (name) => {
|
|
44785
44803
|
templateLocks.release(name);
|
|
44786
44804
|
const gone = join34(root, `.gone-${Bun.randomUUIDv7()}`);
|
|
@@ -44826,7 +44844,7 @@ function createBootTemplates(deps) {
|
|
|
44826
44844
|
const writeTemplate = async (shape, key, work, buildId) => {
|
|
44827
44845
|
const runDir = join34(work, "run");
|
|
44828
44846
|
mkdirSync19(runDir, { recursive: true });
|
|
44829
|
-
if (!
|
|
44847
|
+
if (!existsSync20(placeholder)) {
|
|
44830
44848
|
writeFileSync12(placeholder, "");
|
|
44831
44849
|
truncateSync2(placeholder, PLACEHOLDER_BYTES);
|
|
44832
44850
|
}
|
|
@@ -45031,7 +45049,7 @@ function createBootTemplates(deps) {
|
|
|
45031
45049
|
},
|
|
45032
45050
|
countRestored: (files) => restoredByBuild.get(files.buildId) ?? 0,
|
|
45033
45051
|
removeStale: () => {
|
|
45034
|
-
if (!
|
|
45052
|
+
if (!existsSync20(root)) {
|
|
45035
45053
|
return [];
|
|
45036
45054
|
}
|
|
45037
45055
|
const live = new Set(building.listKeys());
|
|
@@ -45456,12 +45474,12 @@ function buildLogKey(impId, generation) {
|
|
|
45456
45474
|
import { createActor as createActor3 } from "xstate";
|
|
45457
45475
|
|
|
45458
45476
|
// packages/daemon/src/imps/imps/session-logs/read-session-log-range.ts
|
|
45459
|
-
import { existsSync as
|
|
45477
|
+
import { existsSync as existsSync22, mkdirSync as mkdirSync20, readdirSync as readdirSync12, rmSync as rmSync23, rmdirSync as rmdirSync2 } from "fs";
|
|
45460
45478
|
import { open as open5 } from "fs/promises";
|
|
45461
45479
|
import { basename as basename5, dirname as dirname13, join as join36, resolve as resolve2 } from "path";
|
|
45462
45480
|
|
|
45463
45481
|
// packages/daemon/src/imps/imps/session-logs/generation-log.ts
|
|
45464
|
-
import { existsSync as
|
|
45482
|
+
import { existsSync as existsSync21, readFileSync as readFileSync32, readdirSync as readdirSync11, rmSync as rmSync22 } from "fs";
|
|
45465
45483
|
import { mkdir, open as open4, stat, truncate, unlink } from "fs/promises";
|
|
45466
45484
|
import { join as join35 } from "path";
|
|
45467
45485
|
import * as z88 from "zod";
|
|
@@ -45529,11 +45547,11 @@ function getSegmentPath(directory, start) {
|
|
|
45529
45547
|
}
|
|
45530
45548
|
function readGenerationMeta(directory) {
|
|
45531
45549
|
const path = join35(directory, META_FILE);
|
|
45532
|
-
if (!
|
|
45550
|
+
if (!existsSync21(path)) {
|
|
45533
45551
|
return null;
|
|
45534
45552
|
}
|
|
45535
45553
|
try {
|
|
45536
|
-
return GenerationMetaSchema.parse(JSON.parse(
|
|
45554
|
+
return GenerationMetaSchema.parse(JSON.parse(readFileSync32(path, "utf8")));
|
|
45537
45555
|
} catch {
|
|
45538
45556
|
return null;
|
|
45539
45557
|
}
|
|
@@ -45770,7 +45788,7 @@ function getGenerationDir(sessionLogsDir, generation) {
|
|
|
45770
45788
|
return directory;
|
|
45771
45789
|
}
|
|
45772
45790
|
function readImpMetas(sessionLogsDir, readLive) {
|
|
45773
|
-
if (!
|
|
45791
|
+
if (!existsSync22(sessionLogsDir)) {
|
|
45774
45792
|
return [];
|
|
45775
45793
|
}
|
|
45776
45794
|
return readdirSync12(sessionLogsDir).filter((entry) => isGenerationName(entry)).flatMap((generation) => {
|
|
@@ -45784,11 +45802,11 @@ function writeTombstone(sessionLogsDir, generation) {
|
|
|
45784
45802
|
writeFileDurably(path, "");
|
|
45785
45803
|
}
|
|
45786
45804
|
function probeTombstone(sessionLogsDir, generation) {
|
|
45787
|
-
return isGenerationName(generation) &&
|
|
45805
|
+
return isGenerationName(generation) && existsSync22(getTombstonePath(sessionLogsDir, generation));
|
|
45788
45806
|
}
|
|
45789
45807
|
function listTombstones(sessionLogsDir) {
|
|
45790
45808
|
const directory = join36(sessionLogsDir, TOMBSTONES);
|
|
45791
|
-
return
|
|
45809
|
+
return existsSync22(directory) ? readdirSync12(directory).filter((entry) => isGenerationName(entry)) : [];
|
|
45792
45810
|
}
|
|
45793
45811
|
function removeTombstone(sessionLogsDir, generation) {
|
|
45794
45812
|
rmSync23(getTombstonePath(sessionLogsDir, generation), { force: true });
|
|
@@ -46665,7 +46683,6 @@ function createImpContext(deps) {
|
|
|
46665
46683
|
execStartTimer: deps.execStartTimer ?? startRealTimer
|
|
46666
46684
|
};
|
|
46667
46685
|
const vms = {
|
|
46668
|
-
images: deps.images,
|
|
46669
46686
|
taps: deps.taps,
|
|
46670
46687
|
vms: deps.vms,
|
|
46671
46688
|
storage: deps.storage,
|
|
@@ -48330,8 +48347,9 @@ import { resolve as resolve3 } from "path";
|
|
|
48330
48347
|
import { mkdirSync as mkdirSync22, rmSync as rmSync27 } from "fs";
|
|
48331
48348
|
|
|
48332
48349
|
// packages/daemon/src/vm/agent-client/wait-for-agent.ts
|
|
48350
|
+
import { systemClock as systemClock4 } from "@zgeoff/std";
|
|
48333
48351
|
async function waitForAgent(vsockPath, options) {
|
|
48334
|
-
const clock = options.clock ??
|
|
48352
|
+
const clock = options.clock ?? systemClock4;
|
|
48335
48353
|
const deadline = clock.now() + options.deadlineMs;
|
|
48336
48354
|
const maxDelay = options.maxDelayMs ?? 100;
|
|
48337
48355
|
let delay = options.firstDelayMs ?? 5;
|
|
@@ -48360,7 +48378,7 @@ async function waitForAgent(vsockPath, options) {
|
|
|
48360
48378
|
import {
|
|
48361
48379
|
chmodSync as chmodSync7,
|
|
48362
48380
|
closeSync as closeSync9,
|
|
48363
|
-
existsSync as
|
|
48381
|
+
existsSync as existsSync23,
|
|
48364
48382
|
lchownSync as lchownSync2,
|
|
48365
48383
|
lstatSync as lstatSync3,
|
|
48366
48384
|
mkdirSync as mkdirSync21,
|
|
@@ -48509,7 +48527,7 @@ function createJails(deps) {
|
|
|
48509
48527
|
remove,
|
|
48510
48528
|
removeOrphans: async (impIds) => {
|
|
48511
48529
|
const base = join37(deps.chrootBase, execName);
|
|
48512
|
-
const ids =
|
|
48530
|
+
const ids = existsSync23(base) ? readdirSync13(base) : [];
|
|
48513
48531
|
const orphans = ids.filter((impId) => !impIds.has(impId));
|
|
48514
48532
|
const removed = [];
|
|
48515
48533
|
for (const impId of orphans) {
|
|
@@ -48591,7 +48609,7 @@ function setupOwnership(paths, user, isDiskLate) {
|
|
|
48591
48609
|
lchownSync2(paths.runDir, user.uid, user.gid);
|
|
48592
48610
|
setupImpdDir(paths.snapshotDir);
|
|
48593
48611
|
for (const file of [paths.vmstate, paths.memFile]) {
|
|
48594
|
-
if (
|
|
48612
|
+
if (existsSync23(file)) {
|
|
48595
48613
|
requireRegularFile(file);
|
|
48596
48614
|
}
|
|
48597
48615
|
}
|
|
@@ -48600,7 +48618,7 @@ function setupOwnership(paths, user, isDiskLate) {
|
|
|
48600
48618
|
lchownSync2(paths.disk, user.uid, user.gid);
|
|
48601
48619
|
}
|
|
48602
48620
|
for (const file of [paths.vmstate, paths.memFile]) {
|
|
48603
|
-
if (
|
|
48621
|
+
if (existsSync23(file)) {
|
|
48604
48622
|
setupSnapshotFile(file, user.gid);
|
|
48605
48623
|
}
|
|
48606
48624
|
}
|
|
@@ -48818,7 +48836,7 @@ function toMib(bytes) {
|
|
|
48818
48836
|
}
|
|
48819
48837
|
|
|
48820
48838
|
// packages/daemon/src/vm/vmm/start-uffd-handler.ts
|
|
48821
|
-
import { closeSync as closeSync10, existsSync as
|
|
48839
|
+
import { closeSync as closeSync10, existsSync as existsSync24, openSync as openSync8, rmSync as rmSync26 } from "fs";
|
|
48822
48840
|
|
|
48823
48841
|
// packages/daemon/src/vm/vmm/uffd-stats-layout.ts
|
|
48824
48842
|
var UFFD_STATS_LAYOUT = {
|
|
@@ -48853,7 +48871,7 @@ async function startUffdHandler(plan) {
|
|
|
48853
48871
|
writeRegularFile(paths.uffdPidFile, `${String(child.pid)}
|
|
48854
48872
|
`);
|
|
48855
48873
|
const deadline = Date.now() + SOCKET_WAIT_MS2;
|
|
48856
|
-
while (!
|
|
48874
|
+
while (!existsSync24(paths.uffdSocket)) {
|
|
48857
48875
|
if (child.exitCode !== null || Date.now() > deadline) {
|
|
48858
48876
|
stopPid(child.pid);
|
|
48859
48877
|
throw new Error(`the page handler did not open its socket (exit ${String(child.exitCode)}): ${readLogTail(paths.logFile, 5)}`);
|
|
@@ -48877,7 +48895,7 @@ function readUffdStats(paths, readFile) {
|
|
|
48877
48895
|
};
|
|
48878
48896
|
}
|
|
48879
48897
|
function readHandlerState(paths, procRoot = "/proc") {
|
|
48880
|
-
if (!
|
|
48898
|
+
if (!existsSync24(paths.uffdPidFile)) {
|
|
48881
48899
|
return { state: "none" };
|
|
48882
48900
|
}
|
|
48883
48901
|
const pid = readPidFile(paths.uffdPidFile);
|
|
@@ -50042,9 +50060,9 @@ function parseStealUs(stat) {
|
|
|
50042
50060
|
}
|
|
50043
50061
|
|
|
50044
50062
|
// packages/daemon/src/platform/process/read-text.ts
|
|
50045
|
-
import { readFileSync as
|
|
50063
|
+
import { readFileSync as readFileSync33 } from "fs";
|
|
50046
50064
|
function readText(path) {
|
|
50047
|
-
return
|
|
50065
|
+
return readFileSync33(path, "utf8");
|
|
50048
50066
|
}
|
|
50049
50067
|
|
|
50050
50068
|
// packages/daemon/src/platform/telemetry/start-imp-telemetry.ts
|
|
@@ -50421,9 +50439,9 @@ function createMemoryController(deps) {
|
|
|
50421
50439
|
|
|
50422
50440
|
// packages/daemon/src/vm/vmm/cpu-cgroups.ts
|
|
50423
50441
|
import {
|
|
50424
|
-
existsSync as
|
|
50442
|
+
existsSync as existsSync25,
|
|
50425
50443
|
mkdirSync as mkdirSync23,
|
|
50426
|
-
readFileSync as
|
|
50444
|
+
readFileSync as readFileSync34,
|
|
50427
50445
|
readdirSync as readdirSync14,
|
|
50428
50446
|
rmdirSync as rmdirSync3,
|
|
50429
50447
|
writeFileSync as writeFileSync13
|
|
@@ -50467,7 +50485,7 @@ function createCpuCgroups(options) {
|
|
|
50467
50485
|
const oomBaselines = new Map;
|
|
50468
50486
|
const readOomKills = (impId) => {
|
|
50469
50487
|
try {
|
|
50470
|
-
const events =
|
|
50488
|
+
const events = readFileSync34(join39(getDir(impId), "memory.events"), "utf8");
|
|
50471
50489
|
return parseOomKills(events);
|
|
50472
50490
|
} catch {
|
|
50473
50491
|
return null;
|
|
@@ -50529,7 +50547,7 @@ function createCpuCgroups(options) {
|
|
|
50529
50547
|
isMemoryEnforced,
|
|
50530
50548
|
setup,
|
|
50531
50549
|
apply: (impId, cpu) => {
|
|
50532
|
-
if (isEnforced &&
|
|
50550
|
+
if (isEnforced && existsSync25(getDir(impId))) {
|
|
50533
50551
|
tryWrite(impId, "apply the limit", () => {
|
|
50534
50552
|
writeSettings(impId, cpu, cpu.limit);
|
|
50535
50553
|
});
|
|
@@ -50552,7 +50570,7 @@ function createCpuCgroups(options) {
|
|
|
50552
50570
|
},
|
|
50553
50571
|
setGuestMib: (impId, guestMib) => {
|
|
50554
50572
|
guestMibs.set(impId, guestMib);
|
|
50555
|
-
if (isMemoryEnforced &&
|
|
50573
|
+
if (isMemoryEnforced && existsSync25(getDir(impId))) {
|
|
50556
50574
|
tryWrite(impId, "set the memory limit", () => {
|
|
50557
50575
|
writeMemory(impId);
|
|
50558
50576
|
});
|
|
@@ -50564,7 +50582,7 @@ function createCpuCgroups(options) {
|
|
|
50564
50582
|
if (!isEnforced) {
|
|
50565
50583
|
return;
|
|
50566
50584
|
}
|
|
50567
|
-
for (let attempt = 1;
|
|
50585
|
+
for (let attempt = 1;existsSync25(getDir(impId)); attempt += 1) {
|
|
50568
50586
|
try {
|
|
50569
50587
|
rmdir(getDir(impId));
|
|
50570
50588
|
return;
|
|
@@ -50593,7 +50611,7 @@ function createCpuCgroups(options) {
|
|
|
50593
50611
|
return orphans;
|
|
50594
50612
|
},
|
|
50595
50613
|
kill: (impId) => {
|
|
50596
|
-
if (isEnforced &&
|
|
50614
|
+
if (isEnforced && existsSync25(getDir(impId))) {
|
|
50597
50615
|
tryWrite(impId, "kill", () => {
|
|
50598
50616
|
writeFileSync13(join39(getDir(impId), "cgroup.kill"), "1");
|
|
50599
50617
|
});
|
|
@@ -50606,7 +50624,7 @@ function createCpuCgroups(options) {
|
|
|
50606
50624
|
},
|
|
50607
50625
|
readCpuStat: (impId) => {
|
|
50608
50626
|
try {
|
|
50609
|
-
const stat =
|
|
50627
|
+
const stat = readFileSync34(join39(getDir(impId), "cpu.stat"), "utf8");
|
|
50610
50628
|
return parseCpuStat(stat);
|
|
50611
50629
|
} catch {
|
|
50612
50630
|
return null;
|
|
@@ -50616,7 +50634,7 @@ function createCpuCgroups(options) {
|
|
|
50616
50634
|
}
|
|
50617
50635
|
function probeControllerDelegated(imps, controller) {
|
|
50618
50636
|
try {
|
|
50619
|
-
const delegated =
|
|
50637
|
+
const delegated = readFileSync34(join39(imps, "cgroup.subtree_control"), "utf8");
|
|
50620
50638
|
return delegated.split(/\s+/u).includes(controller);
|
|
50621
50639
|
} catch {
|
|
50622
50640
|
return false;
|
|
@@ -50650,6 +50668,7 @@ function probeUffdDevice(path = "/dev/userfaultfd") {
|
|
|
50650
50668
|
|
|
50651
50669
|
// packages/daemon/src/vm/vmm/vm-runner.ts
|
|
50652
50670
|
import { lstatSync as lstatSync4, mkdirSync as mkdirSync24, renameSync as renameSync7, rmSync as rmSync28 } from "fs";
|
|
50671
|
+
import { systemClock as systemClock5 } from "@zgeoff/std";
|
|
50653
50672
|
|
|
50654
50673
|
// packages/daemon/src/vm/vmm/build-boot-args.ts
|
|
50655
50674
|
function buildBootArgs(plan) {
|
|
@@ -50729,7 +50748,7 @@ function createVmRunner(jails, options) {
|
|
|
50729
50748
|
const createClient = options.createClient ?? createFirecrackerClient;
|
|
50730
50749
|
const readFile = options.readFile;
|
|
50731
50750
|
const uffdHandlerBin = options.uffdHandlerBin ?? null;
|
|
50732
|
-
const clock = options.clock ??
|
|
50751
|
+
const clock = options.clock ?? systemClock5;
|
|
50733
50752
|
const uffdWatch = createUffdWatch({
|
|
50734
50753
|
probeVmAlive: (pid, paths) => probeProcessAlive(pid, paths.apiSocket, procRoot),
|
|
50735
50754
|
readHandlerState: (paths) => readHandlerState(paths, procRoot),
|
|
@@ -51062,7 +51081,7 @@ function createImpdImps(config, deps, parts) {
|
|
|
51062
51081
|
}), {
|
|
51063
51082
|
mergeWrapper: config.ksm?.execBin ?? null,
|
|
51064
51083
|
uffdHandlerBin: config.hugePages?.handlerBin ?? null,
|
|
51065
|
-
readFile:
|
|
51084
|
+
readFile: readFileSync35
|
|
51066
51085
|
});
|
|
51067
51086
|
const {
|
|
51068
51087
|
readVmRam,
|
|
@@ -51078,7 +51097,6 @@ function createImpdImps(config, deps, parts) {
|
|
|
51078
51097
|
const serviceDeps = {
|
|
51079
51098
|
config,
|
|
51080
51099
|
db: deps.db,
|
|
51081
|
-
images: parts.storage.images,
|
|
51082
51100
|
taps: deps.taps ?? createTapDevices(),
|
|
51083
51101
|
vms,
|
|
51084
51102
|
storage: deps.storage,
|
|
@@ -51240,7 +51258,7 @@ function makeStandInVmRam(readRam) {
|
|
|
51240
51258
|
}
|
|
51241
51259
|
|
|
51242
51260
|
// packages/daemon/src/imp-ops/moves/move-receiver.ts
|
|
51243
|
-
import { existsSync as
|
|
51261
|
+
import { existsSync as existsSync27, rmSync as rmSync30 } from "fs";
|
|
51244
51262
|
import { join as join41 } from "path";
|
|
51245
51263
|
|
|
51246
51264
|
// packages/daemon/src/platform/db/probe-slot-free.ts
|
|
@@ -51330,9 +51348,10 @@ function readReceipt(receipt, secret) {
|
|
|
51330
51348
|
var COMMIT_WINDOW_MS = 24 * 60 * 60 * 1000;
|
|
51331
51349
|
|
|
51332
51350
|
// packages/daemon/src/imp-ops/moves/create-part-pipe.ts
|
|
51351
|
+
import { systemClock as systemClock6 } from "@zgeoff/std";
|
|
51333
51352
|
var MOVE_PART_BYTES = 256 * 1024 * 1024;
|
|
51334
51353
|
var PART_WAIT_MS = 60000;
|
|
51335
|
-
function createPartPipe(waitMs = PART_WAIT_MS, timer =
|
|
51354
|
+
function createPartPipe(waitMs = PART_WAIT_MS, timer = systemClock6) {
|
|
51336
51355
|
const parts = [];
|
|
51337
51356
|
const state = {
|
|
51338
51357
|
isEnded: false,
|
|
@@ -51357,7 +51376,7 @@ function createPartPipe(waitMs = PART_WAIT_MS, timer = REAL_CLOCK) {
|
|
|
51357
51376
|
}
|
|
51358
51377
|
const waiter = Promise.withResolvers();
|
|
51359
51378
|
state.waiter = waiter;
|
|
51360
|
-
const cancel = timer.
|
|
51379
|
+
const cancel = timer.schedule(() => {
|
|
51361
51380
|
waiter.resolve();
|
|
51362
51381
|
}, Math.max(0, deadline - timer.now()));
|
|
51363
51382
|
await waiter.promise;
|
|
@@ -51580,7 +51599,7 @@ config ${configContentSha256}
|
|
|
51580
51599
|
|
|
51581
51600
|
// packages/daemon/src/imp-ops/moves/check-warm-move.ts
|
|
51582
51601
|
import { createHash as createHash7 } from "crypto";
|
|
51583
|
-
import { existsSync as
|
|
51602
|
+
import { existsSync as existsSync26, mkdirSync as mkdirSync25, renameSync as renameSync8 } from "fs";
|
|
51584
51603
|
import { dirname as dirname15 } from "path";
|
|
51585
51604
|
|
|
51586
51605
|
// packages/daemon/src/imp-ops/moves/read-warm-host.ts
|
|
@@ -51747,7 +51766,7 @@ async function writeSystemDrive(deps, temp, meta) {
|
|
|
51747
51766
|
if (!isSameHash(sha256, meta.systemDrive)) {
|
|
51748
51767
|
throw new MoveRequestError("BAD_REQUEST", "the system drive does not match its sha256");
|
|
51749
51768
|
}
|
|
51750
|
-
if (!
|
|
51769
|
+
if (!existsSync26(path)) {
|
|
51751
51770
|
mkdirSync25(dirname15(path), { recursive: true });
|
|
51752
51771
|
renameSync8(temp, path);
|
|
51753
51772
|
}
|
|
@@ -52227,7 +52246,7 @@ async function readMoveStream(deps, options) {
|
|
|
52227
52246
|
await deps.imps.createImp({
|
|
52228
52247
|
id: header.imp.id,
|
|
52229
52248
|
name: header.imp.name,
|
|
52230
|
-
image: image.name,
|
|
52249
|
+
image: await deps.images.resolveImage(image.name),
|
|
52231
52250
|
...header.imp.clonedDigest !== undefined && { imageDigest: header.imp.clonedDigest },
|
|
52232
52251
|
vcpus: header.imp.vcpus,
|
|
52233
52252
|
memoryMib: header.imp.memoryMib,
|
|
@@ -52434,7 +52453,7 @@ function createMoveReceiver(deps) {
|
|
|
52434
52453
|
const offer = async (offered) => {
|
|
52435
52454
|
const digests = buildOfferedDigests(offered.imageDigest, offered.receivedImageDigest);
|
|
52436
52455
|
const existing = await readImageInUse(deps.db, digests, deps.now());
|
|
52437
|
-
const needsSystemDrive = offered.systemDrive !== undefined && !
|
|
52456
|
+
const needsSystemDrive = offered.systemDrive !== undefined && !existsSync27(buildSystemDrivePath(deps.dataDir, offered.systemDrive));
|
|
52438
52457
|
return {
|
|
52439
52458
|
needsImage: existing === undefined,
|
|
52440
52459
|
needsSystemDrive,
|
|
@@ -53610,8 +53629,9 @@ function createImpdMoves(config, deps, parts, hooks) {
|
|
|
53610
53629
|
}
|
|
53611
53630
|
|
|
53612
53631
|
// packages/daemon/src/imps/images/template-service.ts
|
|
53613
|
-
import { copyFileSync as copyFileSync4, existsSync as
|
|
53632
|
+
import { copyFileSync as copyFileSync4, existsSync as existsSync28, statSync as statSync16, writeFileSync as writeFileSync14 } from "fs";
|
|
53614
53633
|
import { join as join42 } from "path";
|
|
53634
|
+
import { systemClock as systemClock7 } from "@zgeoff/std";
|
|
53615
53635
|
|
|
53616
53636
|
// packages/daemon/src/imps/images/read-held-image.ts
|
|
53617
53637
|
async function readHeldImage(db, name, at) {
|
|
@@ -53630,6 +53650,14 @@ function requireClientImageName(name) {
|
|
|
53630
53650
|
return imageName;
|
|
53631
53651
|
}
|
|
53632
53652
|
|
|
53653
|
+
// packages/daemon/src/imps/images/require-unaliased-name.ts
|
|
53654
|
+
async function requireUnaliasedName(db, name) {
|
|
53655
|
+
const isAliased = await probeImageAlias(db, name);
|
|
53656
|
+
if (isAliased) {
|
|
53657
|
+
throw buildConflictError("image", name, `image name ${name} is held by an alias; remove the alias first`);
|
|
53658
|
+
}
|
|
53659
|
+
}
|
|
53660
|
+
|
|
53633
53661
|
// packages/daemon/src/imps/images/rootfs/remove-unused-rootfs.ts
|
|
53634
53662
|
async function removeUnusedRootfs(db, storage, digest) {
|
|
53635
53663
|
if (await countImageDigestUses(db, digest) === 0) {
|
|
@@ -53648,7 +53676,7 @@ function writeImageRow(db, existing, image, at) {
|
|
|
53648
53676
|
// packages/daemon/src/imps/images/template-service.ts
|
|
53649
53677
|
var TEMPLATE_DIGEST_PREFIX = "imp-";
|
|
53650
53678
|
function createTemplateService(deps) {
|
|
53651
|
-
const clock = deps.clock ??
|
|
53679
|
+
const clock = deps.clock ?? systemClock7;
|
|
53652
53680
|
const storage = deps.storage;
|
|
53653
53681
|
const withConsistentDisk = createConsistentDisk({
|
|
53654
53682
|
storage,
|
|
@@ -53659,7 +53687,7 @@ function createTemplateService(deps) {
|
|
|
53659
53687
|
const image = await readImageById(deps.db, imageId);
|
|
53660
53688
|
const target = join42(directory, "config.json");
|
|
53661
53689
|
const config = image === undefined ? undefined : buildImagePaths(deps.config.dataDir, image.digest).config;
|
|
53662
|
-
if (config !== undefined &&
|
|
53690
|
+
if (config !== undefined && existsSync28(config)) {
|
|
53663
53691
|
copyFileSync4(config, target);
|
|
53664
53692
|
} else {
|
|
53665
53693
|
writeFileSync14(target, "{}");
|
|
@@ -53667,6 +53695,7 @@ function createTemplateService(deps) {
|
|
|
53667
53695
|
};
|
|
53668
53696
|
const writeTemplate = async (impName, name) => {
|
|
53669
53697
|
requireClientImageName(name);
|
|
53698
|
+
await requireUnaliasedName(deps.db, name);
|
|
53670
53699
|
await deps.diskBudget.requireRoom(0);
|
|
53671
53700
|
return deps.storageGate.join(() => deps.imps.lockImp(impName, async (imp) => {
|
|
53672
53701
|
if (imp.state === "creating") {
|
|
@@ -53977,6 +54006,7 @@ function createImpdServices(config, deps, parts) {
|
|
|
53977
54006
|
config,
|
|
53978
54007
|
db,
|
|
53979
54008
|
imps: parts.imps,
|
|
54009
|
+
images: parts.storage.images,
|
|
53980
54010
|
storage,
|
|
53981
54011
|
diskBudget: parts.storage.diskBudget,
|
|
53982
54012
|
...freezer
|
|
@@ -54003,15 +54033,70 @@ function createImpdServices(config, deps, parts) {
|
|
|
54003
54033
|
return { checkpoints, templates, networks, gc, audit };
|
|
54004
54034
|
}
|
|
54005
54035
|
|
|
54036
|
+
// packages/daemon/src/imps/images/image-service.ts
|
|
54037
|
+
import { systemClock as systemClock8 } from "@zgeoff/std";
|
|
54038
|
+
|
|
54039
|
+
// packages/daemon/src/platform/db/is-foreign-key-error.ts
|
|
54040
|
+
function isForeignKeyError(error) {
|
|
54041
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "SQLITE_CONSTRAINT_FOREIGNKEY";
|
|
54042
|
+
}
|
|
54043
|
+
|
|
54044
|
+
// packages/daemon/src/platform/db/list-image-aliases.ts
|
|
54045
|
+
async function listImageAliases(db, imageIds) {
|
|
54046
|
+
const aliases = new Map;
|
|
54047
|
+
if (imageIds.length === 0) {
|
|
54048
|
+
return aliases;
|
|
54049
|
+
}
|
|
54050
|
+
const rows = await db.selectFrom("image_aliases").select(["name", "image_id"]).where("image_id", "in", imageIds).orderBy("name").execute();
|
|
54051
|
+
for (const row of rows) {
|
|
54052
|
+
aliases.set(row.image_id, [...aliases.get(row.image_id) ?? [], row.name]);
|
|
54053
|
+
}
|
|
54054
|
+
return aliases;
|
|
54055
|
+
}
|
|
54056
|
+
|
|
54057
|
+
// packages/daemon/src/platform/db/read-image-by-alias.ts
|
|
54058
|
+
async function readImageByAlias(db, alias) {
|
|
54059
|
+
const row = await db.selectFrom("images").selectAll("images").innerJoin("image_aliases", "image_aliases.image_id", "images.id").where("image_aliases.name", "=", alias).executeTakeFirst();
|
|
54060
|
+
return row === undefined ? undefined : toImageRecord(row);
|
|
54061
|
+
}
|
|
54062
|
+
|
|
54063
|
+
// packages/daemon/src/platform/db/remove-image-alias.ts
|
|
54064
|
+
async function removeImageAlias(db, alias) {
|
|
54065
|
+
const row = await db.deleteFrom("image_aliases").where("name", "=", alias).returning("name").executeTakeFirst();
|
|
54066
|
+
return row !== undefined;
|
|
54067
|
+
}
|
|
54068
|
+
|
|
54069
|
+
// packages/daemon/src/platform/db/update-aliased-image-use.ts
|
|
54070
|
+
async function updateAliasedImageUse(db, alias, atMs) {
|
|
54071
|
+
const row = await db.updateTable("images").set((eb) => ({ last_used_at: eb.fn("max", ["last_used_at", eb.val(atMs)]) })).where("id", "=", (eb) => eb.selectFrom("image_aliases").select("image_aliases.image_id").where("name", "=", alias)).returningAll().executeTakeFirst();
|
|
54072
|
+
return row === undefined ? undefined : toImageRecord(row);
|
|
54073
|
+
}
|
|
54074
|
+
|
|
54075
|
+
// packages/daemon/src/platform/db/update-image-alias.ts
|
|
54076
|
+
function updateImageAlias(db, alias, imageName, atMs) {
|
|
54077
|
+
return db.transaction().execute(async (trx) => {
|
|
54078
|
+
const written = await trx.insertInto("image_aliases").columns(["name", "image_id", "updated_at"]).expression((eb) => eb.selectFrom("images").select([
|
|
54079
|
+
eb.val(alias).as("name"),
|
|
54080
|
+
"images.id as image_id",
|
|
54081
|
+
eb.val(atMs).as("updated_at")
|
|
54082
|
+
]).where("images.name", "=", imageName).where((inner) => inner.not(inner.exists(inner.selectFrom("images as taken").select("taken.id").where("taken.name", "=", alias))))).onConflict((conflict) => conflict.column("name").doUpdateSet((eb) => ({
|
|
54083
|
+
image_id: eb.ref("excluded.image_id"),
|
|
54084
|
+
updated_at: eb.ref("excluded.updated_at")
|
|
54085
|
+
}))).returning("image_id").executeTakeFirst();
|
|
54086
|
+
const row = written === undefined ? undefined : await trx.selectFrom("images").selectAll().where("id", "=", written.image_id).executeTakeFirst();
|
|
54087
|
+
return row === undefined ? undefined : toImageRecord(row);
|
|
54088
|
+
});
|
|
54089
|
+
}
|
|
54090
|
+
|
|
54006
54091
|
// packages/daemon/src/imps/images/build/create-image-builds.ts
|
|
54007
|
-
import { existsSync as
|
|
54092
|
+
import { existsSync as existsSync30, mkdirSync as mkdirSync27, rmSync as rmSync31, statSync as statSync17 } from "fs";
|
|
54008
54093
|
import { join as join44, posix as posix3 } from "path";
|
|
54009
54094
|
|
|
54010
54095
|
// packages/local-tar/src/create-local-extractor.ts
|
|
54011
54096
|
import tar from "tar-stream";
|
|
54012
54097
|
import * as z95 from "zod";
|
|
54013
54098
|
// packages/local-tar/src/list-context-entries.ts
|
|
54014
|
-
import { existsSync as
|
|
54099
|
+
import { existsSync as existsSync29 } from "fs";
|
|
54015
54100
|
import { lstat, readFile as readFile5, readdir } from "fs/promises";
|
|
54016
54101
|
import { join as join43, posix as posix2 } from "path";
|
|
54017
54102
|
import ignore from "@balena/dockerignore";
|
|
@@ -54297,7 +54382,7 @@ class MissingDockerfileError extends Error {
|
|
|
54297
54382
|
name = "MissingDockerfileError";
|
|
54298
54383
|
}
|
|
54299
54384
|
function listContextEntries(root, dockerfile) {
|
|
54300
|
-
const found = listDockerfileCandidates(posix2.normalize(dockerfile)).find((candidate) =>
|
|
54385
|
+
const found = listDockerfileCandidates(posix2.normalize(dockerfile)).find((candidate) => existsSync29(join43(root, candidate)));
|
|
54301
54386
|
if (found === undefined) {
|
|
54302
54387
|
return Promise.reject(new MissingDockerfileError(`there is no ${dockerfile} in ${root}`));
|
|
54303
54388
|
}
|
|
@@ -54309,8 +54394,8 @@ var ENTRY_KINDS = [
|
|
|
54309
54394
|
["file", "isFile"]
|
|
54310
54395
|
];
|
|
54311
54396
|
async function listEntries2(root, dockerfile) {
|
|
54312
|
-
const ignoreName =
|
|
54313
|
-
const patterns =
|
|
54397
|
+
const ignoreName = existsSync29(join43(root, `${dockerfile}.dockerignore`)) ? `${dockerfile}.dockerignore` : ".dockerignore";
|
|
54398
|
+
const patterns = existsSync29(join43(root, ignoreName)) ? await readFile5(join43(root, ignoreName), "utf8") : "";
|
|
54314
54399
|
const matcher = ignore().add(patterns);
|
|
54315
54400
|
const hasExceptions = patterns.split(`
|
|
54316
54401
|
`).some((line) => line.trim().startsWith("!"));
|
|
@@ -55687,6 +55772,7 @@ function createImageBuilds(deps, writer) {
|
|
|
55687
55772
|
const createFromContext = async (tarPath, name, givenDockerfile, options) => {
|
|
55688
55773
|
const signal = options.signal;
|
|
55689
55774
|
const imageName = requireClientImageName(name);
|
|
55775
|
+
await requireUnaliasedName(deps.db, imageName);
|
|
55690
55776
|
const tag = `imp/${imageName}:latest`;
|
|
55691
55777
|
const tarBytes = statSync17(tarPath).size;
|
|
55692
55778
|
const dockerfilePath = normalizeDockerfilePath(givenDockerfile);
|
|
@@ -55769,12 +55855,13 @@ function createImageBuilds(deps, writer) {
|
|
|
55769
55855
|
}
|
|
55770
55856
|
};
|
|
55771
55857
|
const createOnHost = async (contextDir, name, dockerfile, options) => {
|
|
55858
|
+
await requireUnaliasedName(deps.db, requireClientImageName(name));
|
|
55772
55859
|
if (!contextDir.startsWith("/")) {
|
|
55773
55860
|
throw new ImpdError("BAD_REQUEST", {
|
|
55774
55861
|
message: `build context ${JSON.stringify(contextDir)} is not an absolute path`
|
|
55775
55862
|
});
|
|
55776
55863
|
}
|
|
55777
|
-
if (!
|
|
55864
|
+
if (!existsSync30(contextDir)) {
|
|
55778
55865
|
throw new ImpdError("BAD_REQUEST", {
|
|
55779
55866
|
message: `build context ${contextDir} does not exist on the impd host; build the image there and use \`impz image add\``
|
|
55780
55867
|
});
|
|
@@ -55946,7 +56033,7 @@ function buildImageRuntimeConfig(ociConfig) {
|
|
|
55946
56033
|
}
|
|
55947
56034
|
|
|
55948
56035
|
// packages/daemon/src/imps/images/rootfs/create-image-writer.ts
|
|
55949
|
-
import { existsSync as
|
|
56036
|
+
import { existsSync as existsSync31, mkdirSync as mkdirSync29, rmSync as rmSync33, statSync as statSync18, writeFileSync as writeFileSync15 } from "fs";
|
|
55950
56037
|
import { join as join46 } from "path";
|
|
55951
56038
|
|
|
55952
56039
|
// packages/daemon/src/imps/images/rootfs/read-oci-config.ts
|
|
@@ -56109,7 +56196,7 @@ function createImageWriter(deps) {
|
|
|
56109
56196
|
try {
|
|
56110
56197
|
guest.signal.throwIfAborted();
|
|
56111
56198
|
const sizeBytes = await createRootfsOnce(digest, () => {
|
|
56112
|
-
if (
|
|
56199
|
+
if (existsSync31(rootfs)) {
|
|
56113
56200
|
return Promise.resolve(readDiskUsage(rootfs));
|
|
56114
56201
|
}
|
|
56115
56202
|
freshRootfs.add(digest);
|
|
@@ -56259,6 +56346,7 @@ function createImageAdds(deps, writer) {
|
|
|
56259
56346
|
}
|
|
56260
56347
|
const givenName = name ?? deriveImageName(ref);
|
|
56261
56348
|
const imageName = isImpds ? NameSchema.parse(givenName) : requireClientImageName(givenName);
|
|
56349
|
+
await requireUnaliasedName(deps.db, imageName);
|
|
56262
56350
|
const taken = await readImageByName(deps.db, imageName);
|
|
56263
56351
|
requireDockerImage(taken);
|
|
56264
56352
|
return createImageInBuilder(ref, imageName, options);
|
|
@@ -56288,6 +56376,7 @@ function createImageAdds(deps, writer) {
|
|
|
56288
56376
|
if (image?.ref === ref) {
|
|
56289
56377
|
return;
|
|
56290
56378
|
}
|
|
56379
|
+
await requireUnaliasedName(deps.db, BUILDER_IMAGE);
|
|
56291
56380
|
await waitForPull(builderImage.run(BUILDER_IMAGE, () => createBuilderImage(ref)), signal);
|
|
56292
56381
|
};
|
|
56293
56382
|
return {
|
|
@@ -56377,7 +56466,7 @@ function pickEvictedImages(state, marks) {
|
|
|
56377
56466
|
}
|
|
56378
56467
|
var RECENT_USE_MS = 3600000;
|
|
56379
56468
|
function isEvictable(state, use) {
|
|
56380
|
-
return use.impCount === 0 && !use.isPinned && !state.keptNames.has(use.name) && state.now - use.lastUsedAt >= RECENT_USE_MS;
|
|
56469
|
+
return use.impCount === 0 && !use.isPinned && !use.isAliased && !state.keptNames.has(use.name) && state.now - use.lastUsedAt >= RECENT_USE_MS;
|
|
56381
56470
|
}
|
|
56382
56471
|
|
|
56383
56472
|
// packages/daemon/src/imps/images/eviction/create-image-eviction.ts
|
|
@@ -56469,7 +56558,7 @@ function createImageEviction(deps) {
|
|
|
56469
56558
|
|
|
56470
56559
|
// packages/daemon/src/imps/images/image-service.ts
|
|
56471
56560
|
function createImageService(deps) {
|
|
56472
|
-
const clock = deps.clock ??
|
|
56561
|
+
const clock = deps.clock ?? systemClock8;
|
|
56473
56562
|
const writer = createImageWriter({
|
|
56474
56563
|
...deps,
|
|
56475
56564
|
clock
|
|
@@ -56505,17 +56594,42 @@ function createImageService(deps) {
|
|
|
56505
56594
|
if (image !== undefined) {
|
|
56506
56595
|
return image;
|
|
56507
56596
|
}
|
|
56597
|
+
const aliased = await readImageByAlias(deps.db, name);
|
|
56598
|
+
if (aliased !== undefined) {
|
|
56599
|
+
return aliased;
|
|
56600
|
+
}
|
|
56508
56601
|
}
|
|
56509
56602
|
return;
|
|
56510
56603
|
};
|
|
56604
|
+
const resolveImageName = async (name) => {
|
|
56605
|
+
await updateImageUse(deps.db, "name", [name], clock.now());
|
|
56606
|
+
const image = await readImageByName(deps.db, name);
|
|
56607
|
+
return image ?? updateAliasedImageUse(deps.db, name, clock.now());
|
|
56608
|
+
};
|
|
56511
56609
|
const resolveImage = async (name) => {
|
|
56512
56610
|
const names = name === undefined ? [deps.config.defaultImage, FALLBACK_DEFAULT_IMAGE] : [name];
|
|
56513
|
-
|
|
56514
|
-
|
|
56515
|
-
|
|
56516
|
-
|
|
56611
|
+
for (const candidate of names) {
|
|
56612
|
+
const image = await resolveImageName(candidate);
|
|
56613
|
+
if (image !== undefined) {
|
|
56614
|
+
return image;
|
|
56615
|
+
}
|
|
56616
|
+
}
|
|
56617
|
+
throw buildNotFoundError("image", name ?? deps.config.defaultImage);
|
|
56618
|
+
};
|
|
56619
|
+
const requireUnusedImage = async (image) => {
|
|
56620
|
+
const users = await countImpsUsingImage(deps.db, image.id);
|
|
56621
|
+
const found = await listImageAliases(deps.db, [image.id]);
|
|
56622
|
+
const aliases = found.get(image.id) ?? [];
|
|
56623
|
+
const reasons = [];
|
|
56624
|
+
if (users > 0) {
|
|
56625
|
+
reasons.push(`used by ${String(users)} imp(s)`);
|
|
56626
|
+
}
|
|
56627
|
+
if (aliases.length > 0) {
|
|
56628
|
+
reasons.push(`pointed at by alias ${aliases.join(", ")}; remove ${aliases.length === 1 ? "it" : "them"} with image unalias first`);
|
|
56629
|
+
}
|
|
56630
|
+
if (reasons.length > 0) {
|
|
56631
|
+
throw buildConflictError("image", image.name, `image ${image.name} is ${reasons.join(" and ")}`);
|
|
56517
56632
|
}
|
|
56518
|
-
return image;
|
|
56519
56633
|
};
|
|
56520
56634
|
return {
|
|
56521
56635
|
...adds,
|
|
@@ -56530,12 +56644,15 @@ function createImageService(deps) {
|
|
|
56530
56644
|
if (image === undefined) {
|
|
56531
56645
|
throw buildNotFoundError("image", name);
|
|
56532
56646
|
}
|
|
56533
|
-
|
|
56534
|
-
if (users > 0) {
|
|
56535
|
-
throw buildConflictError("image", name, `image ${name} is used by ${String(users)} imp(s)`);
|
|
56536
|
-
}
|
|
56647
|
+
await requireUnusedImage(image);
|
|
56537
56648
|
await deps.storageGate.join(async () => {
|
|
56538
|
-
await removeImage(deps.db, image.id)
|
|
56649
|
+
await removeImage(deps.db, image.id).catch(async (error) => {
|
|
56650
|
+
if (!isForeignKeyError(error)) {
|
|
56651
|
+
throw error;
|
|
56652
|
+
}
|
|
56653
|
+
await requireUnusedImage(image);
|
|
56654
|
+
throw buildConflictError("image", name, `image ${name} is in use again; check its imps and aliases, then retry`);
|
|
56655
|
+
});
|
|
56539
56656
|
const isRemoved = await writer.removeIdleRootfs(image.digest);
|
|
56540
56657
|
if (isRemoved) {
|
|
56541
56658
|
await removeImageRemoval(deps.db, image.digest);
|
|
@@ -56554,9 +56671,27 @@ function createImageService(deps) {
|
|
|
56554
56671
|
throw buildNotFoundError("image", name);
|
|
56555
56672
|
},
|
|
56556
56673
|
resolveImage,
|
|
56674
|
+
updateImageAlias: async (alias, imageName) => {
|
|
56675
|
+
const image = await updateImageAlias(deps.db, alias, imageName, clock.now());
|
|
56676
|
+
if (image !== undefined) {
|
|
56677
|
+
return image;
|
|
56678
|
+
}
|
|
56679
|
+
const target = await readImageByName(deps.db, imageName);
|
|
56680
|
+
if (target === undefined) {
|
|
56681
|
+
throw buildNotFoundError("image", imageName);
|
|
56682
|
+
}
|
|
56683
|
+
throw buildConflictError("image", alias, `alias ${alias} is the name of an image; pick another alias`);
|
|
56684
|
+
},
|
|
56685
|
+
removeImageAlias: async (alias) => {
|
|
56686
|
+
if (!await removeImageAlias(deps.db, alias)) {
|
|
56687
|
+
throw buildNotFoundError("image alias", alias);
|
|
56688
|
+
}
|
|
56689
|
+
},
|
|
56690
|
+
listImageAliases: (imageIds) => listImageAliases(deps.db, imageIds),
|
|
56557
56691
|
findDefaultImage: readDefaultImage,
|
|
56558
56692
|
runImageEviction: runEviction,
|
|
56559
|
-
withImagePublisher: writer.withPublisher
|
|
56693
|
+
withImagePublisher: writer.withPublisher,
|
|
56694
|
+
removeIdleRootfs: writer.removeIdleRootfs
|
|
56560
56695
|
};
|
|
56561
56696
|
}
|
|
56562
56697
|
|
|
@@ -57166,7 +57301,7 @@ function registerReconcilers(deps) {
|
|
|
57166
57301
|
}
|
|
57167
57302
|
|
|
57168
57303
|
// packages/daemon/src/network/https/wire-https-service.ts
|
|
57169
|
-
import { readFileSync as
|
|
57304
|
+
import { readFileSync as readFileSync37 } from "fs";
|
|
57170
57305
|
|
|
57171
57306
|
// packages/daemon/src/platform/db/read-public-imp.ts
|
|
57172
57307
|
async function readPublicImp(db, name) {
|
|
@@ -57190,7 +57325,7 @@ async function listPublicImpNames(db) {
|
|
|
57190
57325
|
}
|
|
57191
57326
|
|
|
57192
57327
|
// packages/daemon/src/network/https/acme/cert-store.ts
|
|
57193
|
-
import { existsSync as
|
|
57328
|
+
import { existsSync as existsSync32, mkdirSync as mkdirSync30, readFileSync as readFileSync36, rmSync as rmSync34 } from "fs";
|
|
57194
57329
|
import { join as join48 } from "path";
|
|
57195
57330
|
import * as z103 from "zod";
|
|
57196
57331
|
var AttemptStateSchema = z103.object({
|
|
@@ -57272,7 +57407,7 @@ ${certificate.chainPem.trimEnd()}
|
|
|
57272
57407
|
};
|
|
57273
57408
|
}
|
|
57274
57409
|
function readIfExists(path) {
|
|
57275
|
-
return
|
|
57410
|
+
return existsSync32(path) ? readFileSync36(path, "utf8") : null;
|
|
57276
57411
|
}
|
|
57277
57412
|
function parseJson2(text) {
|
|
57278
57413
|
try {
|
|
@@ -58263,7 +58398,7 @@ function wireHttpsService(options) {
|
|
|
58263
58398
|
const issue = createAcmeIssuer({
|
|
58264
58399
|
directoryUrl: config.acmeDirectory,
|
|
58265
58400
|
email: config.acmeEmail,
|
|
58266
|
-
caPem: config.acmeCaFile === null ? null :
|
|
58401
|
+
caPem: config.acmeCaFile === null ? null : readFileSync37(config.acmeCaFile, "utf8"),
|
|
58267
58402
|
store,
|
|
58268
58403
|
dns
|
|
58269
58404
|
});
|
|
@@ -60210,6 +60345,7 @@ async function startImpdParts(config, boundaries, plan) {
|
|
|
60210
60345
|
config,
|
|
60211
60346
|
db,
|
|
60212
60347
|
imps: { ...imps, ...deps.agent },
|
|
60348
|
+
images: stored.images,
|
|
60213
60349
|
ensureImage: stored.images.ensureBuilderImage,
|
|
60214
60350
|
testRegistry: firewall.testRegistry
|
|
60215
60351
|
});
|
|
@@ -60308,7 +60444,7 @@ async function startImpdParts(config, boundaries, plan) {
|
|
|
60308
60444
|
readTailnetNames: tailnetNames === null ? null : tailnetNames.readStatus,
|
|
60309
60445
|
hostReaders: {
|
|
60310
60446
|
readKernel: () => deps.hostKernelRelease ?? release2(),
|
|
60311
|
-
readCpuInfo: deps.readCpuInfo ?? (() =>
|
|
60447
|
+
readCpuInfo: deps.readCpuInfo ?? (() => readFileSync38("/proc/cpuinfo", "utf8")),
|
|
60312
60448
|
readHugePagePool: deps.imps?.readHugePagePool ?? (() => readHugePagePool())
|
|
60313
60449
|
},
|
|
60314
60450
|
isReady: () => state.ready,
|
|
@@ -60395,8 +60531,7 @@ async function startImpdParts(config, boundaries, plan) {
|
|
|
60395
60531
|
async function setupDefaultImage(config, images) {
|
|
60396
60532
|
try {
|
|
60397
60533
|
await images.addDefaultImage();
|
|
60398
|
-
|
|
60399
|
-
if (!existing.some((image) => image.name === config.defaultImage)) {
|
|
60534
|
+
if (!await probeDefaultImageName(config, images)) {
|
|
60400
60535
|
getImpdLogger("image").warning("no image named {defaultImage} (IMP_DEFAULT_IMAGE); impz new uses ubuntu until `impz image add <ref> --name {defaultImage}` adds it", { defaultImage: config.defaultImage });
|
|
60401
60536
|
}
|
|
60402
60537
|
} catch (error) {
|
|
@@ -60405,66 +60540,45 @@ async function setupDefaultImage(config, images) {
|
|
|
60405
60540
|
});
|
|
60406
60541
|
}
|
|
60407
60542
|
}
|
|
60408
|
-
|
|
60409
|
-
|
|
60410
|
-
|
|
60411
|
-
|
|
60543
|
+
async function probeDefaultImageName(config, images) {
|
|
60544
|
+
const found = await images.findDefaultImage();
|
|
60545
|
+
if (found === undefined) {
|
|
60546
|
+
return false;
|
|
60547
|
+
}
|
|
60548
|
+
if (found.name === config.defaultImage) {
|
|
60549
|
+
return true;
|
|
60550
|
+
}
|
|
60551
|
+
const aliases = await images.listImageAliases([found.id]);
|
|
60552
|
+
return aliases.get(found.id)?.includes(config.defaultImage) ?? false;
|
|
60412
60553
|
}
|
|
60413
60554
|
|
|
60414
|
-
// packages/
|
|
60415
|
-
|
|
60416
|
-
|
|
60417
|
-
|
|
60418
|
-
|
|
60419
|
-
|
|
60420
|
-
|
|
60421
|
-
|
|
60422
|
-
|
|
60423
|
-
|
|
60424
|
-
|
|
60425
|
-
|
|
60426
|
-
}
|
|
60427
|
-
const [id, timer] = due;
|
|
60428
|
-
pending.delete(id);
|
|
60429
|
-
state.nowMs = Math.max(state.nowMs, timer.at);
|
|
60430
|
-
timer.fire();
|
|
60431
|
-
}
|
|
60432
|
-
state.nowMs = until;
|
|
60433
|
-
};
|
|
60434
|
-
const startTimer = (fire, durationMs) => {
|
|
60435
|
-
state.nextId += 1;
|
|
60436
|
-
const id = state.nextId;
|
|
60437
|
-
delays.push(durationMs);
|
|
60438
|
-
pending.set(id, { at: state.nowMs + durationMs, durationMs, fire });
|
|
60439
|
-
return () => {
|
|
60440
|
-
pending.delete(id);
|
|
60441
|
-
};
|
|
60442
|
-
};
|
|
60443
|
-
const sleep = (durationMs) => {
|
|
60444
|
-
sleeps.push(durationMs);
|
|
60445
|
-
runFor(durationMs);
|
|
60446
|
-
return Promise.resolve();
|
|
60447
|
-
};
|
|
60448
|
-
const clock = { now: () => state.nowMs, startTimer, sleep };
|
|
60555
|
+
// packages/testing/src/stand-in/start-test-impd.ts
|
|
60556
|
+
import { createORPCClient as createORPCClient2 } from "@orpc/client";
|
|
60557
|
+
import { RPCLink } from "@orpc/client/fetch";
|
|
60558
|
+
import { createFakeClock } from "@zgeoff/testing/clock";
|
|
60559
|
+
import { claimFreePorts } from "@zgeoff/testing/process";
|
|
60560
|
+
import invariant16 from "tiny-invariant";
|
|
60561
|
+
|
|
60562
|
+
// packages/testing/src/test-token.ts
|
|
60563
|
+
var TEST_TOKEN = "test-token";
|
|
60564
|
+
|
|
60565
|
+
// packages/testing/src/stand-in/build-imps-with-resolved-images.ts
|
|
60566
|
+
function buildImpsWithResolvedImages(imps, images) {
|
|
60449
60567
|
return {
|
|
60450
|
-
...
|
|
60451
|
-
|
|
60452
|
-
|
|
60453
|
-
|
|
60454
|
-
|
|
60455
|
-
const pendingNow = [...pending];
|
|
60456
|
-
for (const [id, timer] of pendingNow) {
|
|
60457
|
-
if (pending.delete(id)) {
|
|
60458
|
-
timer.fire();
|
|
60459
|
-
}
|
|
60460
|
-
}
|
|
60461
|
-
},
|
|
60462
|
-
readPendingMs: () => [...pending.values()].map((timer) => timer.durationMs),
|
|
60463
|
-
countPending: () => pending.size
|
|
60568
|
+
...imps,
|
|
60569
|
+
createImp: async (input) => {
|
|
60570
|
+
const image = typeof input.image === "object" ? input.image : await images.resolveImage(input.image);
|
|
60571
|
+
return imps.createImp({ ...input, image });
|
|
60572
|
+
}
|
|
60464
60573
|
};
|
|
60465
60574
|
}
|
|
60466
60575
|
|
|
60467
|
-
// packages/
|
|
60576
|
+
// packages/testing/src/stand-in/network/read-no-tailscale.ts
|
|
60577
|
+
function readNoTailscale() {
|
|
60578
|
+
return Promise.resolve({ state: null, hostname: null, dnsName: null, ip: null, ips: [] });
|
|
60579
|
+
}
|
|
60580
|
+
|
|
60581
|
+
// packages/testing/src/stand-in/platform/build-stub-ticker-timer.ts
|
|
60468
60582
|
function buildStubTickerTimer() {
|
|
60469
60583
|
const pending = new Map;
|
|
60470
60584
|
const holdRun = (label, run, durationMs) => {
|
|
@@ -60490,12 +60604,12 @@ function buildStubTickerTimer() {
|
|
|
60490
60604
|
};
|
|
60491
60605
|
}
|
|
60492
60606
|
|
|
60493
|
-
// packages/
|
|
60607
|
+
// packages/testing/src/stand-in/platform/format-run-prefix.ts
|
|
60494
60608
|
function formatRunPrefix(owner) {
|
|
60495
60609
|
return `pid${String(owner.pid)}-ns${owner.namespace}-`;
|
|
60496
60610
|
}
|
|
60497
60611
|
|
|
60498
|
-
// packages/
|
|
60612
|
+
// packages/testing/src/stand-in/platform/open-migrated-copy.ts
|
|
60499
60613
|
import { Database as Database4 } from "bun:sqlite";
|
|
60500
60614
|
var TEMPLATE = {};
|
|
60501
60615
|
function openMigratedCopy(now) {
|
|
@@ -60510,14 +60624,7 @@ async function serializeMigratedDatabase() {
|
|
|
60510
60624
|
return bytes;
|
|
60511
60625
|
}
|
|
60512
60626
|
|
|
60513
|
-
// packages/
|
|
60514
|
-
var FIRST_PORT = 10100;
|
|
60515
|
-
var PORT_SPAN = 9900;
|
|
60516
|
-
function pickImpdPort(draw) {
|
|
60517
|
-
return FIRST_PORT + Math.floor(draw * PORT_SPAN);
|
|
60518
|
-
}
|
|
60519
|
-
|
|
60520
|
-
// packages/daemon/src/test-utils/platform/read-run-owner.ts
|
|
60627
|
+
// packages/testing/src/stand-in/platform/read-run-owner.ts
|
|
60521
60628
|
import { readlinkSync as readlinkSync2 } from "fs";
|
|
60522
60629
|
function readRunOwner() {
|
|
60523
60630
|
return {
|
|
@@ -60526,9 +60633,6 @@ function readRunOwner() {
|
|
|
60526
60633
|
};
|
|
60527
60634
|
}
|
|
60528
60635
|
|
|
60529
|
-
// packages/daemon/src/test-utils/platform/start-impd-log-capture.ts
|
|
60530
|
-
import { resetSync } from "@logtape/logtape";
|
|
60531
|
-
|
|
60532
60636
|
// packages/daemon/src/platform/process/setup-logging.ts
|
|
60533
60637
|
import { AsyncLocalStorage } from "async_hooks";
|
|
60534
60638
|
import { configureSync } from "@logtape/logtape";
|
|
@@ -60559,7 +60663,8 @@ function renderLogLine(record) {
|
|
|
60559
60663
|
`;
|
|
60560
60664
|
}
|
|
60561
60665
|
|
|
60562
|
-
// packages/
|
|
60666
|
+
// packages/testing/src/stand-in/platform/start-impd-log-capture.ts
|
|
60667
|
+
import { resetSync } from "@logtape/logtape";
|
|
60563
60668
|
var listeners = new Set;
|
|
60564
60669
|
function startImpdLogCapture(onLine) {
|
|
60565
60670
|
if (listeners.size === 0) {
|
|
@@ -60577,11 +60682,8 @@ function startImpdLogCapture(onLine) {
|
|
|
60577
60682
|
};
|
|
60578
60683
|
}
|
|
60579
60684
|
|
|
60580
|
-
// packages/
|
|
60581
|
-
|
|
60582
|
-
|
|
60583
|
-
// packages/daemon/src/test-utils/vm/build-stub-vmm.ts
|
|
60584
|
-
import { existsSync as existsSync34, mkdirSync as mkdirSync31, renameSync as renameSync9, writeFileSync as writeFileSync16 } from "fs";
|
|
60685
|
+
// packages/testing/src/stand-in/vm/build-stub-vmm.ts
|
|
60686
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync31, renameSync as renameSync9, writeFileSync as writeFileSync16 } from "fs";
|
|
60585
60687
|
var STUB_AGENT_VERSION = "0.1.0";
|
|
60586
60688
|
var IMPD_OWNER = { uid: process.getuid?.() ?? 0, cgroup: null };
|
|
60587
60689
|
|
|
@@ -60731,7 +60833,7 @@ log tail`);
|
|
|
60731
60833
|
}),
|
|
60732
60834
|
wakeVm: (plan) => runInGeneration(async () => {
|
|
60733
60835
|
const files = [plan.paths.disk, plan.paths.vmstate, plan.paths.memFile];
|
|
60734
|
-
wakeJails.push({ jail: plan.jail, files: files.filter((file) =>
|
|
60836
|
+
wakeJails.push({ jail: plan.jail, files: files.filter((file) => existsSync33(file)) });
|
|
60735
60837
|
wakePlans.push(plan);
|
|
60736
60838
|
const drive = readLoadingMeta(plan.paths)?.systemDrivePath;
|
|
60737
60839
|
if (plan.jail !== null && drive !== undefined && !plan.readOnlyFiles.includes(drive)) {
|
|
@@ -60984,8 +61086,8 @@ log tail`);
|
|
|
60984
61086
|
};
|
|
60985
61087
|
}
|
|
60986
61088
|
|
|
60987
|
-
// packages/
|
|
60988
|
-
import { existsSync as
|
|
61089
|
+
// packages/testing/src/stand-in/vm/create-stub-uffd-handler.ts
|
|
61090
|
+
import { existsSync as existsSync34, readFileSync as readFileSync39, writeFileSync as writeFileSync17 } from "fs";
|
|
60989
61091
|
import { join as join50 } from "path";
|
|
60990
61092
|
import * as z105 from "zod";
|
|
60991
61093
|
var StartSchema = z105.object({
|
|
@@ -61019,11 +61121,11 @@ exec '${process.execPath}' '${script}' '${mode}' '${recorded}' '${warmAnswer}' "
|
|
|
61019
61121
|
};
|
|
61020
61122
|
}
|
|
61021
61123
|
function readRecords(path, schema) {
|
|
61022
|
-
return
|
|
61124
|
+
return existsSync34(path) ? readFileSync39(path, "utf8").trimEnd().split(`
|
|
61023
61125
|
`).map((line) => schema.parse(JSON.parse(line))) : [];
|
|
61024
61126
|
}
|
|
61025
61127
|
|
|
61026
|
-
// packages/
|
|
61128
|
+
// packages/testing/src/stand-in/start-test-impd.ts
|
|
61027
61129
|
var FAKE_VM_RAM_MIB = 300;
|
|
61028
61130
|
var FAKE_VM_RSS_MIB = 340;
|
|
61029
61131
|
var TEST_DRIVE = "d1".repeat(32);
|
|
@@ -61052,10 +61154,8 @@ async function startTestImpd(stack, options = {}) {
|
|
|
61052
61154
|
await db.destroy();
|
|
61053
61155
|
options.onLog?.("test harness: database closed");
|
|
61054
61156
|
});
|
|
61055
|
-
const ports = claimFreePorts(3, {
|
|
61056
|
-
|
|
61057
|
-
onRelease: stack.defer.bind(stack)
|
|
61058
|
-
});
|
|
61157
|
+
const ports = claimFreePorts(3, { cleanup: "manual" });
|
|
61158
|
+
stack.defer(ports.release);
|
|
61059
61159
|
const config = {
|
|
61060
61160
|
...loadConfig({
|
|
61061
61161
|
IMP_DATA_DIR: dataDir,
|
|
@@ -61065,6 +61165,7 @@ async function startTestImpd(stack, options = {}) {
|
|
|
61065
61165
|
IMP_BROKER_PORT: String(ports.take()),
|
|
61066
61166
|
IMP_EGRESS_DNS_PORT: String(ports.take()),
|
|
61067
61167
|
IMP_SSH_PORT: "0",
|
|
61168
|
+
IMP_PORT_BASE: "40000",
|
|
61068
61169
|
IMP_UFFD_HANDLER: uffdHandler.path,
|
|
61069
61170
|
...options.env
|
|
61070
61171
|
}),
|
|
@@ -61072,7 +61173,7 @@ async function startTestImpd(stack, options = {}) {
|
|
|
61072
61173
|
};
|
|
61073
61174
|
const fake = buildStubVmm();
|
|
61074
61175
|
const tickers = buildStubTickerTimer();
|
|
61075
|
-
const reconcilerTimers =
|
|
61176
|
+
const reconcilerTimers = createFakeClock();
|
|
61076
61177
|
const taps = [];
|
|
61077
61178
|
const removedTaps = [];
|
|
61078
61179
|
const logs = [];
|
|
@@ -61127,7 +61228,7 @@ async function startTestImpd(stack, options = {}) {
|
|
|
61127
61228
|
logRpcFailure: printRpcFailure,
|
|
61128
61229
|
now: readClock,
|
|
61129
61230
|
readTailscale: extra.readTailscale ?? readNoTailscale,
|
|
61130
|
-
readDiskSpace: () => Promise.resolve({ ...diskUsage }),
|
|
61231
|
+
readDiskSpace: extra.readDiskSpace ?? (() => Promise.resolve({ ...diskUsage })),
|
|
61131
61232
|
resolveIpv6: () => Promise.resolve(options.ipv6 ?? null),
|
|
61132
61233
|
readIdentity: () => identity,
|
|
61133
61234
|
cgroups,
|
|
@@ -61140,7 +61241,7 @@ async function startTestImpd(stack, options = {}) {
|
|
|
61140
61241
|
hostKernelRelease: extra.hostKernelRelease ?? KSM_KERNEL,
|
|
61141
61242
|
readKsmHostStats: options.readKsmHostStats ?? (() => IDLE_KSM),
|
|
61142
61243
|
tickerTimer: tickers.timer,
|
|
61143
|
-
reconcilerTimer: reconcilerTimers.
|
|
61244
|
+
reconcilerTimer: reconcilerTimers.schedule,
|
|
61144
61245
|
proxyPorts: extra.proxyPorts ?? { proxy: 0, slot: () => 0 },
|
|
61145
61246
|
apiHostname: "127.0.0.1",
|
|
61146
61247
|
images: { seedRef: null, ...extra.images },
|
|
@@ -61255,6 +61356,15 @@ async function startTestImpd(stack, options = {}) {
|
|
|
61255
61356
|
return impd;
|
|
61256
61357
|
};
|
|
61257
61358
|
const current = { impd: await startImpd(host.identity, fake.startGeneration()) };
|
|
61359
|
+
const seededImpds = new WeakMap;
|
|
61360
|
+
const buildImpdWithResolvedImages = (impd) => {
|
|
61361
|
+
const seeded = seededImpds.get(impd) ?? {
|
|
61362
|
+
...impd,
|
|
61363
|
+
imps: buildImpsWithResolvedImages(impd.imps, impd.images)
|
|
61364
|
+
};
|
|
61365
|
+
seededImpds.set(impd, seeded);
|
|
61366
|
+
return seeded;
|
|
61367
|
+
};
|
|
61258
61368
|
const sendRequest = (request) => current.impd.api.app.handle(request);
|
|
61259
61369
|
const buildClient = (token) => createORPCClient2(new RPCLink({
|
|
61260
61370
|
url: "http://impd.test/rpc",
|
|
@@ -61293,7 +61403,7 @@ async function startTestImpd(stack, options = {}) {
|
|
|
61293
61403
|
now: readClock,
|
|
61294
61404
|
advance: (durationMs) => {
|
|
61295
61405
|
clock.offsetMs += durationMs;
|
|
61296
|
-
reconcilerTimers.
|
|
61406
|
+
reconcilerTimers.advance(durationMs);
|
|
61297
61407
|
},
|
|
61298
61408
|
setClock: (nowMs) => {
|
|
61299
61409
|
invariant16(options.frozenClockMs !== undefined, "setClock needs a frozen clock");
|
|
@@ -61310,10 +61420,10 @@ async function startTestImpd(stack, options = {}) {
|
|
|
61310
61420
|
return `http://127.0.0.1:${String(current.impd.app.server?.port)}`;
|
|
61311
61421
|
},
|
|
61312
61422
|
get impd() {
|
|
61313
|
-
return current.impd;
|
|
61423
|
+
return buildImpdWithResolvedImages(current.impd);
|
|
61314
61424
|
},
|
|
61315
61425
|
get imps() {
|
|
61316
|
-
return current.impd.imps;
|
|
61426
|
+
return buildImpdWithResolvedImages(current.impd).imps;
|
|
61317
61427
|
},
|
|
61318
61428
|
get governor() {
|
|
61319
61429
|
return current.impd.governor;
|
|
@@ -61359,7 +61469,7 @@ async function startTestImpd(stack, options = {}) {
|
|
|
61359
61469
|
await stopImpd(current.impd);
|
|
61360
61470
|
host.identity = identity;
|
|
61361
61471
|
current.impd = await startImpd(identity, runner);
|
|
61362
|
-
return current.impd;
|
|
61472
|
+
return buildImpdWithResolvedImages(current.impd);
|
|
61363
61473
|
}
|
|
61364
61474
|
};
|
|
61365
61475
|
}
|
|
@@ -61860,8 +61970,8 @@ function resumeFrontLink(link) {
|
|
|
61860
61970
|
import { randomBytes as randomBytes12 } from "crypto";
|
|
61861
61971
|
import { Duplex } from "stream";
|
|
61862
61972
|
|
|
61863
|
-
// packages/
|
|
61864
|
-
import { onTestFinished
|
|
61973
|
+
// packages/testing/src/stand-in/vm/start-stub-agent.ts
|
|
61974
|
+
import { onTestFinished } from "bun:test";
|
|
61865
61975
|
import { mkdirSync as mkdirSync33 } from "fs";
|
|
61866
61976
|
import { createServer as createServer4 } from "net";
|
|
61867
61977
|
import { dirname as dirname16 } from "path";
|
|
@@ -61902,7 +62012,7 @@ async function startStubAgent(path, agent, options = {}) {
|
|
|
61902
62012
|
server.close();
|
|
61903
62013
|
};
|
|
61904
62014
|
if (options.stack === undefined) {
|
|
61905
|
-
|
|
62015
|
+
onTestFinished(stopServer);
|
|
61906
62016
|
} else {
|
|
61907
62017
|
options.stack.defer(stopServer);
|
|
61908
62018
|
}
|
|
@@ -62055,9 +62165,6 @@ function relayFrame(stream, frame) {
|
|
|
62055
62165
|
}
|
|
62056
62166
|
}
|
|
62057
62167
|
|
|
62058
|
-
// packages/testing/src/test-token.ts
|
|
62059
|
-
var TEST_TOKEN2 = TEST_TOKEN;
|
|
62060
|
-
|
|
62061
62168
|
// packages/testing/src/start-test-impd.ts
|
|
62062
62169
|
var GUEST_AGENT_VERSION = "0.18.0";
|
|
62063
62170
|
async function startTestImpd2(options = {}) {
|
|
@@ -62073,8 +62180,8 @@ async function startTestImpd2(options = {}) {
|
|
|
62073
62180
|
...options.version !== undefined && { version: options.version },
|
|
62074
62181
|
...options.features !== undefined && { features: options.features }
|
|
62075
62182
|
});
|
|
62076
|
-
const client = createImpClient2({ url: proxy.url, token:
|
|
62077
|
-
const guestClient = createImpClient2({ url: harness.url, token:
|
|
62183
|
+
const client = createImpClient2({ url: proxy.url, token: TEST_TOKEN });
|
|
62184
|
+
const guestClient = createImpClient2({ url: harness.url, token: TEST_TOKEN });
|
|
62078
62185
|
return {
|
|
62079
62186
|
url: proxy.url,
|
|
62080
62187
|
impdUrl: harness.url,
|
|
@@ -62128,6 +62235,6 @@ function isGuestDown(event) {
|
|
|
62128
62235
|
return event.ev === "ImpRemoved" || event.ev === "ImpChanged" && event.imp.state !== "running";
|
|
62129
62236
|
}
|
|
62130
62237
|
export {
|
|
62131
|
-
|
|
62238
|
+
TEST_TOKEN,
|
|
62132
62239
|
startTestImpd2 as startTestImpd
|
|
62133
62240
|
};
|