@nosana/node 1.1.84 → 1.1.85-rc
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/.env +2 -1
- package/dist/package.json +1 -1
- package/dist/packages/job-runtime/src/host/HostClient.d.ts +20 -4
- package/dist/packages/job-runtime/src/host/HostClient.js +35 -2
- package/dist/packages/job-runtime/src/host/contract.d.ts +27 -7
- package/dist/packages/job-runtime/src/host/contract.js +43 -7
- package/dist/packages/job-runtime/src/runtime/runJob.d.ts +8 -5
- package/dist/packages/job-runtime/src/runtime/runJob.js +44 -17
- package/dist/packages/vm-orchestrator/src/CidRegistry.d.ts +67 -0
- package/dist/packages/vm-orchestrator/src/CidRegistry.js +168 -0
- package/dist/packages/vm-orchestrator/src/GpuPool.d.ts +27 -0
- package/dist/packages/vm-orchestrator/src/GpuPool.js +41 -0
- package/dist/packages/vm-orchestrator/src/Hypervisor.d.ts +66 -0
- package/dist/packages/vm-orchestrator/src/Hypervisor.js +7 -0
- package/dist/packages/vm-orchestrator/src/QemuHypervisor.d.ts +62 -0
- package/dist/packages/vm-orchestrator/src/QemuHypervisor.js +185 -0
- package/dist/packages/vm-orchestrator/src/QemuHypervisorConfig.d.ts +61 -0
- package/dist/packages/vm-orchestrator/src/QemuHypervisorConfig.js +37 -0
- package/dist/packages/vm-orchestrator/src/QemuVmInstance.d.ts +37 -0
- package/dist/packages/vm-orchestrator/src/QemuVmInstance.js +44 -0
- package/dist/packages/vm-orchestrator/src/QmpClient.d.ts +43 -0
- package/dist/packages/vm-orchestrator/src/QmpClient.js +103 -0
- package/dist/packages/vm-orchestrator/src/VmSpec.d.ts +21 -0
- package/dist/packages/vm-orchestrator/src/VmSpec.js +30 -0
- package/dist/packages/vm-orchestrator/src/VmStateManager.d.ts +16 -0
- package/dist/packages/vm-orchestrator/src/VmStateManager.js +30 -0
- package/dist/packages/vm-orchestrator/src/bootAttempt.d.ts +31 -0
- package/dist/packages/vm-orchestrator/src/bootAttempt.js +193 -0
- package/dist/packages/vm-orchestrator/src/bootErrors.d.ts +33 -0
- package/dist/packages/vm-orchestrator/src/bootErrors.js +67 -0
- package/dist/packages/vm-orchestrator/src/buildCloudInit.d.ts +33 -0
- package/dist/packages/vm-orchestrator/src/buildCloudInit.js +55 -0
- package/dist/packages/vm-orchestrator/src/buildQemuArgs.d.ts +33 -0
- package/dist/packages/vm-orchestrator/src/buildQemuArgs.js +127 -0
- package/dist/packages/vm-orchestrator/src/diskSizing.d.ts +18 -0
- package/dist/packages/vm-orchestrator/src/diskSizing.js +41 -0
- package/dist/packages/vm-orchestrator/src/firmware.d.ts +5 -0
- package/dist/packages/vm-orchestrator/src/firmware.js +18 -0
- package/dist/packages/vm-orchestrator/src/hostAccess/VmHostAccess.d.ts +22 -0
- package/dist/packages/vm-orchestrator/src/hostAccess/VmHostAccess.js +33 -0
- package/dist/packages/vm-orchestrator/src/hostAccess/deviceProblems.d.ts +3 -0
- package/dist/packages/vm-orchestrator/src/hostAccess/deviceProblems.js +17 -0
- package/dist/packages/vm-orchestrator/src/hostAccess/findVmHostAccessProblems.d.ts +9 -0
- package/dist/packages/vm-orchestrator/src/hostAccess/findVmHostAccessProblems.js +17 -0
- package/dist/packages/vm-orchestrator/src/hostAccess/gpuProblems.d.ts +6 -0
- package/dist/packages/vm-orchestrator/src/hostAccess/gpuProblems.js +42 -0
- package/dist/packages/vm-orchestrator/src/hostAccess/index.d.ts +1 -0
- package/dist/packages/vm-orchestrator/src/hostAccess/index.js +1 -0
- package/dist/packages/vm-orchestrator/src/hostAccess/memlockProblems.d.ts +6 -0
- package/dist/packages/vm-orchestrator/src/hostAccess/memlockProblems.js +18 -0
- package/dist/packages/vm-orchestrator/src/hostAccess/workRootProblems.d.ts +7 -0
- package/dist/packages/vm-orchestrator/src/hostAccess/workRootProblems.js +30 -0
- package/dist/packages/vm-orchestrator/src/hostDevices.d.ts +12 -0
- package/dist/packages/vm-orchestrator/src/hostDevices.js +12 -0
- package/dist/packages/vm-orchestrator/src/hostTools.d.ts +25 -0
- package/dist/packages/vm-orchestrator/src/hostTools.js +39 -0
- package/dist/packages/vm-orchestrator/src/imageCache.d.ts +25 -0
- package/dist/packages/vm-orchestrator/src/imageCache.js +73 -0
- package/dist/packages/vm-orchestrator/src/imageDownload.d.ts +31 -0
- package/dist/packages/vm-orchestrator/src/imageDownload.js +85 -0
- package/dist/packages/vm-orchestrator/src/index.d.ts +19 -0
- package/dist/packages/vm-orchestrator/src/index.js +15 -0
- package/dist/packages/vm-orchestrator/src/memlockLimit.d.ts +5 -0
- package/dist/packages/vm-orchestrator/src/memlockLimit.js +23 -0
- package/dist/packages/vm-orchestrator/src/nvidiaHolders.d.ts +11 -0
- package/dist/packages/vm-orchestrator/src/nvidiaHolders.js +74 -0
- package/dist/packages/vm-orchestrator/src/pciNuma.d.ts +7 -0
- package/dist/packages/vm-orchestrator/src/pciNuma.js +18 -0
- package/dist/packages/vm-orchestrator/src/pciSysfs.d.ts +21 -0
- package/dist/packages/vm-orchestrator/src/pciSysfs.js +47 -0
- package/dist/packages/vm-orchestrator/src/processes.d.ts +37 -0
- package/dist/packages/vm-orchestrator/src/processes.js +102 -0
- package/dist/packages/vm-orchestrator/src/sockets.d.ts +21 -0
- package/dist/packages/vm-orchestrator/src/sockets.js +58 -0
- package/dist/packages/vm-orchestrator/src/sweepVmImageCache.d.ts +19 -0
- package/dist/packages/vm-orchestrator/src/sweepVmImageCache.js +132 -0
- package/dist/packages/vm-orchestrator/src/util.d.ts +14 -0
- package/dist/packages/vm-orchestrator/src/util.js +33 -0
- package/dist/packages/vm-orchestrator/src/vfioBinding.d.ts +27 -0
- package/dist/packages/vm-orchestrator/src/vfioBinding.js +163 -0
- package/dist/packages/vm-orchestrator/src/vmImageResolver.d.ts +20 -0
- package/dist/packages/vm-orchestrator/src/vmImageResolver.js +62 -0
- package/dist/packages/vm-orchestrator/src/vsockBridge.d.ts +20 -0
- package/dist/packages/vm-orchestrator/src/vsockBridge.js +27 -0
- package/dist/packages/vm-orchestrator/src/workDirs.d.ts +49 -0
- package/dist/packages/vm-orchestrator/src/workDirs.js +79 -0
- package/dist/src/NodeManager/configs/configs.d.ts +4 -0
- package/dist/src/NodeManager/configs/configs.js +3 -0
- package/dist/src/NodeManager/db/index.d.ts +10 -0
- package/dist/src/NodeManager/db/index.js +4 -0
- package/dist/src/NodeManager/monitoring/log/NodeLog.d.ts +2 -0
- package/dist/src/NodeManager/monitoring/log/NodeLog.js +21 -0
- package/dist/src/NodeManager/monitoring/log/console/ConsoleLogger.d.ts +8 -0
- package/dist/src/NodeManager/monitoring/log/console/ConsoleLogger.js +29 -5
- package/dist/src/NodeManager/monitoring/log/vmSetupLog.d.ts +11 -0
- package/dist/src/NodeManager/monitoring/log/vmSetupLog.js +33 -0
- package/dist/src/NodeManager/node/Node.d.ts +2 -0
- package/dist/src/NodeManager/node/Node.js +12 -5
- package/dist/src/NodeManager/node/job/ContainerJobRuntime.d.ts +141 -0
- package/dist/src/NodeManager/node/job/ContainerJobRuntime.js +419 -0
- package/dist/src/NodeManager/node/job/JobRuntimeEnvironment.d.ts +74 -0
- package/dist/src/NodeManager/node/job/JobRuntimeEnvironment.js +1 -0
- package/dist/src/NodeManager/node/job/JobRuntimeHost.d.ts +6 -2
- package/dist/src/NodeManager/node/job/JobRuntimeHost.js +13 -2
- package/dist/src/NodeManager/node/job/JobRuntimeSession.d.ts +12 -9
- package/dist/src/NodeManager/node/job/JobRuntimeSession.js +42 -71
- package/dist/src/NodeManager/node/job/VmJobRuntime.d.ts +109 -0
- package/dist/src/NodeManager/node/job/VmJobRuntime.js +258 -0
- package/dist/src/NodeManager/node/job/VmJobRuntimeConfig.d.ts +33 -0
- package/dist/src/NodeManager/node/job/VmJobRuntimeConfig.js +1 -0
- package/dist/src/NodeManager/node/job/buildJobRuntimeEnv.d.ts +41 -0
- package/dist/src/NodeManager/node/job/buildJobRuntimeEnv.js +25 -0
- package/dist/src/NodeManager/node/job/followFile.d.ts +14 -0
- package/dist/src/NodeManager/node/job/followFile.js +57 -0
- package/dist/src/NodeManager/node/job/jobHandler.d.ts +3 -3
- package/dist/src/NodeManager/node/job/jobHandler.js +7 -7
- package/dist/src/NodeManager/node/job/keepFailedConsole.d.ts +7 -0
- package/dist/src/NodeManager/node/job/keepFailedConsole.js +52 -0
- package/dist/src/NodeManager/node/job/selectJobRuntimeEnvironment.d.ts +50 -0
- package/dist/src/NodeManager/node/job/selectJobRuntimeEnvironment.js +117 -0
- package/dist/src/NodeManager/node/market/benchmark.d.ts +3 -3
- package/dist/src/NodeManager/node/market/benchmark.js +3 -3
- package/dist/src/NodeManager/node/market/marketHandler.d.ts +3 -3
- package/dist/src/NodeManager/node/market/marketHandler.js +3 -3
- package/dist/src/NodeManager/node/resource/resourceManager.d.ts +1 -1
- package/dist/src/NodeManager/node/resource/resourceManager.js +1 -1
- package/dist/src/NodeManager/provider/Provider.d.ts +3 -121
- package/dist/src/NodeManager/provider/Provider.js +3 -369
- package/dist/src/NodeManager/provider/vmHost/VmNodeOptions.d.ts +14 -0
- package/dist/src/NodeManager/provider/vmHost/VmNodeOptions.js +1 -0
- package/dist/src/NodeManager/provider/vmHost/capacity.d.ts +16 -0
- package/dist/src/NodeManager/provider/vmHost/capacity.js +47 -0
- package/dist/src/NodeManager/provider/vmHost/gpus.d.ts +19 -0
- package/dist/src/NodeManager/provider/vmHost/gpus.js +83 -0
- package/dist/src/NodeManager/provider/vmHost/index.d.ts +5 -0
- package/dist/src/NodeManager/provider/vmHost/index.js +4 -0
- package/dist/src/NodeManager/provider/vmHost/readVmSpec.d.ts +11 -0
- package/dist/src/NodeManager/provider/vmHost/readVmSpec.js +22 -0
- package/dist/src/NodeManager/provider/vmHost/setup/PrepareVmHostSystem.d.ts +27 -0
- package/dist/src/NodeManager/provider/vmHost/setup/PrepareVmHostSystem.js +25 -0
- package/dist/src/NodeManager/provider/vmHost/setup/fileOwnership.d.ts +6 -0
- package/dist/src/NodeManager/provider/vmHost/setup/fileOwnership.js +22 -0
- package/dist/src/NodeManager/provider/vmHost/setup/hostUser.d.ts +15 -0
- package/dist/src/NodeManager/provider/vmHost/setup/hostUser.js +25 -0
- package/dist/src/NodeManager/provider/vmHost/setup/index.d.ts +2 -0
- package/dist/src/NodeManager/provider/vmHost/setup/index.js +2 -0
- package/dist/src/NodeManager/provider/vmHost/setup/memlockLimits.d.ts +6 -0
- package/dist/src/NodeManager/provider/vmHost/setup/memlockLimits.js +12 -0
- package/dist/src/NodeManager/provider/vmHost/setup/prepareVmHost.d.ts +17 -0
- package/dist/src/NodeManager/provider/vmHost/setup/prepareVmHost.js +90 -0
- package/dist/src/NodeManager/provider/vmHost/setup/sudoCaller.d.ts +5 -0
- package/dist/src/NodeManager/provider/vmHost/setup/sudoCaller.js +35 -0
- package/dist/src/NodeManager/provider/vmHost/vmHostEnv.d.ts +20 -0
- package/dist/src/NodeManager/provider/vmHost/vmHostEnv.js +24 -0
- package/dist/src/NodeManager/provider/vmHost/workRoot.d.ts +14 -0
- package/dist/src/NodeManager/provider/vmHost/workRoot.js +84 -0
- package/dist/src/NodeManager/repository/NodeRepository.d.ts +12 -2
- package/dist/src/NodeManager/repository/NodeRepository.js +21 -1
- package/dist/src/cli/commands/prune/command.js +2 -1
- package/dist/src/cli/commands/run/action.d.ts +2 -2
- package/dist/src/cli/commands/run/action.js +15 -34
- package/dist/src/cli/commands/run/command.js +7 -2
- package/dist/src/cli/commands/sharedOptions/--config.d.ts +2 -0
- package/dist/src/cli/commands/sharedOptions/--config.js +2 -0
- package/dist/src/cli/commands/sharedOptions/--environment.d.ts +6 -0
- package/dist/src/cli/commands/sharedOptions/--environment.js +6 -0
- package/dist/src/cli/commands/sharedOptions/--gpu.js +5 -2
- package/dist/src/cli/commands/sharedOptions/--node-limits.d.ts +9 -0
- package/dist/src/cli/commands/sharedOptions/--node-limits.js +24 -0
- package/dist/src/cli/commands/sharedOptions/index.d.ts +3 -0
- package/dist/src/cli/commands/sharedOptions/index.js +3 -0
- package/dist/src/cli/commands/start/command.js +7 -2
- package/dist/src/cli/commands/vm-setup/action.d.ts +10 -0
- package/dist/src/cli/commands/vm-setup/action.js +14 -0
- package/dist/src/cli/commands/vm-setup/command.d.ts +3 -0
- package/dist/src/cli/commands/vm-setup/command.js +11 -0
- package/dist/src/cli/createNosanaCli.d.ts +1 -0
- package/dist/src/cli/createNosanaCli.js +4 -1
- package/npm-shrinkwrap.json +10 -2
- package/package.json +1 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { describeError, pathExists } from './util.js';
|
|
4
|
+
/** Work dirs are `<workRoot>/nosana-vm-<random>`. */
|
|
5
|
+
export const WORK_DIR_PREFIX = 'nosana-vm-';
|
|
6
|
+
/** The qcow2 overlay in a VM's work dir, over the (immutable) base image. */
|
|
7
|
+
export const OVERLAY_FILE = 'overlay.qcow2';
|
|
8
|
+
/** The VM's serial console, as VmStateManager keeps it in the work dir. */
|
|
9
|
+
export const VM_CONSOLE_LOG = 'console.log';
|
|
10
|
+
/**
|
|
11
|
+
* A VM work dir with no record is left alone this long after it last changed:
|
|
12
|
+
* a co-tenant node sharing the work root may be booting it, its QEMU not
|
|
13
|
+
* spawned yet.
|
|
14
|
+
*/
|
|
15
|
+
const ORPHAN_WORKDIR_MIN_AGE_MS = 10 * 60 * 1000;
|
|
16
|
+
/** The paths of the files in a VM work dir. */
|
|
17
|
+
export function workDirPaths(workdir) {
|
|
18
|
+
return {
|
|
19
|
+
workdir,
|
|
20
|
+
overlay: path.join(workdir, OVERLAY_FILE),
|
|
21
|
+
seedIso: path.join(workdir, 'seed.iso'),
|
|
22
|
+
userData: path.join(workdir, 'user-data'),
|
|
23
|
+
metaData: path.join(workdir, 'meta-data'),
|
|
24
|
+
qmpSocket: path.join(workdir, 'qmp.sock'),
|
|
25
|
+
serialSocket: path.join(workdir, 'serial.sock'),
|
|
26
|
+
qemuLog: path.join(workdir, 'qemu.log'),
|
|
27
|
+
bridgeLog: path.join(workdir, 'bridge.log'),
|
|
28
|
+
consoleLog: path.join(workdir, VM_CONSOLE_LOG),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Make a fresh VM work dir under `workRoot`. */
|
|
32
|
+
export async function makeWorkDir(workRoot) {
|
|
33
|
+
return workDirPaths(await fs.mkdtemp(path.join(workRoot, WORK_DIR_PREFIX)));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Remove a VM work dir. Refuses anything not named like one, so a bad record
|
|
37
|
+
* can never point it elsewhere.
|
|
38
|
+
*/
|
|
39
|
+
export async function removeWorkDir(workdir) {
|
|
40
|
+
if (!path.basename(workdir).startsWith(WORK_DIR_PREFIX)) {
|
|
41
|
+
throw new Error(`not a VM work dir: ${workdir}`);
|
|
42
|
+
}
|
|
43
|
+
await fs.rm(workdir, { recursive: true, force: true });
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Remove every VM work dir under `workRoot` that a node booted but never
|
|
47
|
+
* recorded: not in `keep`, with an overlay (the image cache has none), last
|
|
48
|
+
* changed at least {@link ORPHAN_WORKDIR_MIN_AGE_MS} ago, and named by no
|
|
49
|
+
* running process (`<dir>/` in its command line). The processes are listed
|
|
50
|
+
* once, and only when there is something to remove; when they cannot be
|
|
51
|
+
* listed, nothing is removed. A dir that will not go is logged and left.
|
|
52
|
+
*/
|
|
53
|
+
export async function sweepWorkDirs(workRoot, keep, listCommandLines) {
|
|
54
|
+
const kept = new Set(keep.map((dir) => path.resolve(dir)));
|
|
55
|
+
const names = await fs.readdir(workRoot).catch(() => []);
|
|
56
|
+
let commandLines;
|
|
57
|
+
for (const name of names) {
|
|
58
|
+
const dir = path.join(workRoot, name);
|
|
59
|
+
if (!(await isUnrecordedWorkDir(dir, kept)))
|
|
60
|
+
continue;
|
|
61
|
+
commandLines ??= await listCommandLines();
|
|
62
|
+
if (!commandLines)
|
|
63
|
+
return;
|
|
64
|
+
if (commandLines.some((line) => line.includes(`${dir}/`)))
|
|
65
|
+
continue;
|
|
66
|
+
await removeWorkDir(dir).catch((error) => console.error(`Failed to remove VM work dir ${dir}: ${describeError(error).message}`));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** Is `dir` a VM work dir, not in `kept`, that has not changed for a while? */
|
|
70
|
+
async function isUnrecordedWorkDir(dir, kept) {
|
|
71
|
+
if (!path.basename(dir).startsWith(WORK_DIR_PREFIX))
|
|
72
|
+
return false;
|
|
73
|
+
if (kept.has(path.resolve(dir)))
|
|
74
|
+
return false;
|
|
75
|
+
if (!(await pathExists(path.join(dir, OVERLAY_FILE))))
|
|
76
|
+
return false;
|
|
77
|
+
const changedMs = (await fs.stat(dir).catch(() => undefined))?.mtimeMs;
|
|
78
|
+
return changedMs !== undefined && Date.now() - changedMs >= ORPHAN_WORKDIR_MIN_AGE_MS;
|
|
79
|
+
}
|
|
@@ -17,6 +17,10 @@ export type configType = {
|
|
|
17
17
|
resourceManager: {
|
|
18
18
|
containerImage: string;
|
|
19
19
|
};
|
|
20
|
+
vm: {
|
|
21
|
+
/** The golden VM image a `--vm` node boots each job's runtime in; '' when unset. */
|
|
22
|
+
image: string;
|
|
23
|
+
};
|
|
20
24
|
minDiskSpace: number;
|
|
21
25
|
network: 'devnet' | 'mainnet';
|
|
22
26
|
};
|
|
@@ -21,6 +21,9 @@ export const configs = (options) => {
|
|
|
21
21
|
resourceManager: {
|
|
22
22
|
containerImage: loadConfigurationValue('RESOURCE_MANAGER_IMAGE'),
|
|
23
23
|
},
|
|
24
|
+
vm: {
|
|
25
|
+
image: loadConfigurationValue('GOLDEN_VM_IMAGE', ''),
|
|
26
|
+
},
|
|
24
27
|
minDiskSpace: parseInt(loadConfigurationValue('MIN_DISK_SPACE')),
|
|
25
28
|
network: options?.network ?? nodeConfigs.getNetwork(),
|
|
26
29
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LowSync } from 'lowdb/lib';
|
|
2
2
|
import type { ResourceHistory, VolumeResource } from '../../../packages/job-runtime/src/resources/index.js';
|
|
3
|
+
import type { VmRecord } from '../../../packages/vm-orchestrator/src/index.js';
|
|
3
4
|
import { CudaCheckSuccessResponse } from '../types/index.js';
|
|
4
5
|
export type NodeDb = {
|
|
5
6
|
resources: Resources;
|
|
@@ -40,6 +41,14 @@ export type Resources = {
|
|
|
40
41
|
containers: {
|
|
41
42
|
[id: string]: ContainerResource;
|
|
42
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* The VM each job's runtime runs in, by job address (VmJobRuntime): QEMU
|
|
46
|
+
* outlives the node process, and the next one attaches to it from here or
|
|
47
|
+
* reaps it.
|
|
48
|
+
*/
|
|
49
|
+
vms: {
|
|
50
|
+
[jobAddress: string]: VmRecord;
|
|
51
|
+
};
|
|
43
52
|
};
|
|
44
53
|
/**
|
|
45
54
|
* A container this node started, recorded so a later resync can tear down
|
|
@@ -60,6 +69,7 @@ export type ContainerResource = {
|
|
|
60
69
|
};
|
|
61
70
|
/** The cache records, shared with a job's sidecar (see @nosana/job-runtime/resources). */
|
|
62
71
|
export type { ResourceHistory, VolumeResource };
|
|
72
|
+
export type { VmRecord };
|
|
63
73
|
export declare class DB {
|
|
64
74
|
db: LowSync<NodeDb>;
|
|
65
75
|
/** The node's data directory, the database's and the jobs' runtime sockets'. */
|
|
@@ -7,6 +7,7 @@ const initial_state = {
|
|
|
7
7
|
images: {},
|
|
8
8
|
volumes: {},
|
|
9
9
|
containers: {},
|
|
10
|
+
vms: {},
|
|
10
11
|
},
|
|
11
12
|
info: {
|
|
12
13
|
version: pkg.version,
|
|
@@ -50,6 +51,9 @@ export class DB {
|
|
|
50
51
|
if (!this.db.data.resources.containers) {
|
|
51
52
|
this.db.data.resources.containers = {};
|
|
52
53
|
}
|
|
54
|
+
if (!this.db.data.resources.vms) {
|
|
55
|
+
this.db.data.resources.vms = {};
|
|
56
|
+
}
|
|
53
57
|
// A job's records are its runtime's now. Node versions that ran jobs
|
|
54
58
|
// themselves kept them here.
|
|
55
59
|
for (const legacy of ['flows', 'sshKeyGrants', 'sshHostKeys']) {
|
|
@@ -33,6 +33,8 @@ declare class NodeLog {
|
|
|
33
33
|
private notifyObservers;
|
|
34
34
|
private addLog;
|
|
35
35
|
private process;
|
|
36
|
+
/** A job VM's setup is one spinner; its boot steps are not shown (see vmSetupLog). */
|
|
37
|
+
private handleVmSetup;
|
|
36
38
|
private handleRecommend;
|
|
37
39
|
private handleRegister;
|
|
38
40
|
private handleExpiryHandler;
|
|
@@ -2,6 +2,7 @@ import chalk from 'chalk';
|
|
|
2
2
|
import { logEmitter, translateJobPhaseLog } from '../../../../packages/common/src/index.js';
|
|
3
3
|
import { SECONDS_PER_DAY } from '../../utils/utils.js';
|
|
4
4
|
import { LogMonitoringRegistry } from '../LogMonitoringRegistry.js';
|
|
5
|
+
import { VM_SETUP_LOG_CLASS, VM_SETUP_LOG_METHOD, VM_SETUP_NODE_LOG_METHOD, } from './vmSetupLog.js';
|
|
5
6
|
export const log = (() => {
|
|
6
7
|
let instance = null;
|
|
7
8
|
return () => {
|
|
@@ -41,6 +42,9 @@ class NodeLog {
|
|
|
41
42
|
this.addLog({ ...entry, job: this.job });
|
|
42
43
|
}
|
|
43
44
|
}
|
|
45
|
+
if (data.class === VM_SETUP_LOG_CLASS && data.method === VM_SETUP_LOG_METHOD) {
|
|
46
|
+
this.handleVmSetup(data);
|
|
47
|
+
}
|
|
44
48
|
if (data.class === 'BenchmarkTaskManager' && data.method === 'progress') {
|
|
45
49
|
this.addLog({
|
|
46
50
|
method: `${data.class}.${data.method}`,
|
|
@@ -158,6 +162,23 @@ class NodeLog {
|
|
|
158
162
|
this.handleExpiryHandler(data);
|
|
159
163
|
}
|
|
160
164
|
}
|
|
165
|
+
/** A job VM's setup is one spinner; its boot steps are not shown (see vmSetupLog). */
|
|
166
|
+
handleVmSetup(data) {
|
|
167
|
+
const outcome = {
|
|
168
|
+
call: { type: 'process', log: chalk.cyan('Setting up VM') },
|
|
169
|
+
return: { type: 'success', log: chalk.green('VM is ready') },
|
|
170
|
+
error: { type: 'error', log: chalk.red('Failed to set up the VM') },
|
|
171
|
+
}[data.type];
|
|
172
|
+
this.addLog({
|
|
173
|
+
method: VM_SETUP_NODE_LOG_METHOD,
|
|
174
|
+
job: this.job,
|
|
175
|
+
timestamp: Date.now(),
|
|
176
|
+
...outcome,
|
|
177
|
+
...(data.type === 'call' && {
|
|
178
|
+
pending: { isPending: true, expecting: VM_SETUP_NODE_LOG_METHOD },
|
|
179
|
+
}),
|
|
180
|
+
});
|
|
181
|
+
}
|
|
161
182
|
handleRecommend(data) {
|
|
162
183
|
if (data.type === 'call') {
|
|
163
184
|
this.addLog({
|
|
@@ -15,6 +15,8 @@ export declare class ConsoleLogger implements LogObserver {
|
|
|
15
15
|
private taskManagerStartMethod;
|
|
16
16
|
private benchmarkProgress;
|
|
17
17
|
private shutdownAfterJob;
|
|
18
|
+
/** A job VM is being set up inside the task window: its bar says so until the ops run. */
|
|
19
|
+
private settingUpVm;
|
|
18
20
|
private renderTaskManagerBar;
|
|
19
21
|
private expiry;
|
|
20
22
|
private taskManagerRunInterval;
|
|
@@ -22,5 +24,11 @@ export declare class ConsoleLogger implements LogObserver {
|
|
|
22
24
|
constructor(isNode?: boolean);
|
|
23
25
|
addObserver(): void;
|
|
24
26
|
isNodeObserver(): boolean;
|
|
27
|
+
private isBenchmarkWindow;
|
|
28
|
+
/**
|
|
29
|
+
* A job VM set up inside the task window: its bar says so while the VM boots and, in a
|
|
30
|
+
* benchmark, until the first op reports (its progress clears it); not once the setup fails.
|
|
31
|
+
*/
|
|
32
|
+
private showVmSetupInWindow;
|
|
25
33
|
update(log: NodeLogEntry, isNode?: boolean): void;
|
|
26
34
|
}
|
|
@@ -2,6 +2,7 @@ import chalk from 'chalk';
|
|
|
2
2
|
import ora from 'ora';
|
|
3
3
|
import { MultiBar, Presets, SingleBar } from 'cli-progress';
|
|
4
4
|
import { log } from '../NodeLog.js';
|
|
5
|
+
import { VM_SETUP_NODE_LOG_METHOD } from '../vmSetupLog.js';
|
|
5
6
|
import { convertFromBytes } from '../../../utils/convertFromBytes.js';
|
|
6
7
|
import { formatTime } from '../../../../../packages/common/src/index.js';
|
|
7
8
|
export const consoleLogging = (() => {
|
|
@@ -25,6 +26,8 @@ export class ConsoleLogger {
|
|
|
25
26
|
this.taskManagerStartMethod = 'TaskManager.start';
|
|
26
27
|
this.benchmarkProgress = { completed: 0, total: 0 };
|
|
27
28
|
this.shutdownAfterJob = false;
|
|
29
|
+
/** A job VM is being set up inside the task window: its bar says so until the ops run. */
|
|
30
|
+
this.settingUpVm = false;
|
|
28
31
|
}
|
|
29
32
|
addObserver() {
|
|
30
33
|
log().addObserver(this);
|
|
@@ -32,6 +35,18 @@ export class ConsoleLogger {
|
|
|
32
35
|
isNodeObserver() {
|
|
33
36
|
return this.isNode;
|
|
34
37
|
}
|
|
38
|
+
isBenchmarkWindow() {
|
|
39
|
+
return this.taskManagerStartMethod === 'BenchmarkTaskManager.start';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A job VM set up inside the task window: its bar says so while the VM boots and, in a
|
|
43
|
+
* benchmark, until the first op reports (its progress clears it); not once the setup fails.
|
|
44
|
+
*/
|
|
45
|
+
showVmSetupInWindow(type) {
|
|
46
|
+
this.settingUpVm = type === 'process' || (type === 'success' && this.isBenchmarkWindow());
|
|
47
|
+
if (this.renderTaskManagerBar)
|
|
48
|
+
this.spinner.text = this.renderTaskManagerBar();
|
|
49
|
+
}
|
|
35
50
|
update(log, isNode = true) {
|
|
36
51
|
const renderBase = `${chalk.bgGreenBright.black.bold(this.taskManagerLabel)} ${chalk.reset('')}`;
|
|
37
52
|
// Handled first so a toggle is never swallowed by the job's quiet window.
|
|
@@ -99,6 +114,7 @@ export class ConsoleLogger {
|
|
|
99
114
|
: ' RUNNING JOB ';
|
|
100
115
|
const activeRenderBase = `${chalk.bgGreenBright.black.bold(this.taskManagerLabel)} ${chalk.reset('')}`;
|
|
101
116
|
this.taskManagerActive = true;
|
|
117
|
+
this.settingUpVm = false;
|
|
102
118
|
this.pending = true;
|
|
103
119
|
this.expiry = log.payload?.expiry;
|
|
104
120
|
// From the run's start onchain when known, so a job taken over after
|
|
@@ -111,9 +127,12 @@ export class ConsoleLogger {
|
|
|
111
127
|
const modePlate = () => this.shutdownAfterJob
|
|
112
128
|
? `${chalk.red('[s]')} ${chalk.red.bold('cancel')} ${chalk.red('shutdown after job')}`
|
|
113
129
|
: chalk.dim('[s] shutdown after job');
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
130
|
+
const setupPlate = `${chalk.bgYellow.black.bold(' Setting up VM ')} ${chalk.reset('')}`;
|
|
131
|
+
const renderBar = (duration = 0) => this.settingUpVm
|
|
132
|
+
? `${activeRenderBase} ${setupPlate}`
|
|
133
|
+
: isBenchmark
|
|
134
|
+
? `${activeRenderBase} ${chalk.bgYellow.black.bold(` Ops: ${this.benchmarkProgress.completed}/${this.benchmarkProgress.total} `)} ${chalk.reset('')}`
|
|
135
|
+
: `${activeRenderBase} ${chalk.bgYellow.black.bold(` ⏱ Duration: ${formatTime(duration)} `)} ${chalk.reset('')} ${chalk.bgBlue.black.bold(` ⚡ Max Duration: ${formatTime(this.expiry ?? 0)} `)} ${modePlate()}`;
|
|
117
136
|
this.renderTaskManagerBar = () => renderBar((Date.now() - startTime) / 1000);
|
|
118
137
|
this.spinner = ora({ text: this.renderTaskManagerBar(), discardStdin: false }).start();
|
|
119
138
|
this.taskManagerRunInterval = setInterval(() => {
|
|
@@ -130,7 +149,7 @@ export class ConsoleLogger {
|
|
|
130
149
|
// While TaskManager is active, swallow all logs except the stop signal
|
|
131
150
|
if (this.taskManagerActive) {
|
|
132
151
|
if (log.method === this.taskManagerStartMethod) {
|
|
133
|
-
const endingSuffix = this.
|
|
152
|
+
const endingSuffix = this.isBenchmarkWindow()
|
|
134
153
|
? ' Completed'
|
|
135
154
|
: ` Ending ${log.job}...`;
|
|
136
155
|
this.spinner.succeed(renderBase + endingSuffix);
|
|
@@ -138,8 +157,13 @@ export class ConsoleLogger {
|
|
|
138
157
|
this.pending = false;
|
|
139
158
|
return;
|
|
140
159
|
}
|
|
160
|
+
if (log.method === VM_SETUP_NODE_LOG_METHOD) {
|
|
161
|
+
this.showVmSetupInWindow(log.type);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
141
164
|
if (log.method === 'BenchmarkTaskManager.progress' &&
|
|
142
|
-
this.
|
|
165
|
+
this.isBenchmarkWindow()) {
|
|
166
|
+
this.settingUpVm = false;
|
|
143
167
|
const { completed, total } = log.payload ?? {};
|
|
144
168
|
if (typeof completed === 'number' && typeof total === 'number') {
|
|
145
169
|
this.benchmarkProgress = { completed, total };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The log stream's class for a job VM's setup. */
|
|
2
|
+
export declare const VM_SETUP_LOG_CLASS = "VmJobRuntime";
|
|
3
|
+
/** The setup itself: `call` as it starts, `return` once the VM is up, `error` if it fails. */
|
|
4
|
+
export declare const VM_SETUP_LOG_METHOD = "setup";
|
|
5
|
+
/** How NodeLog names the setup to its observers (see ConsoleLogger). */
|
|
6
|
+
export declare const VM_SETUP_NODE_LOG_METHOD = "VmJobRuntime.setup";
|
|
7
|
+
/**
|
|
8
|
+
* Runs a job VM's setup bracketed on the node's log stream, which the console shows as one
|
|
9
|
+
* spinner. Answers or throws as `setup` does.
|
|
10
|
+
*/
|
|
11
|
+
export declare function trackVmSetup<T>(jobAddress: string, setup: () => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { logEmitter } from '../../../../packages/common/src/index.js';
|
|
2
|
+
/** The log stream's class for a job VM's setup. */
|
|
3
|
+
export const VM_SETUP_LOG_CLASS = 'VmJobRuntime';
|
|
4
|
+
/** The setup itself: `call` as it starts, `return` once the VM is up, `error` if it fails. */
|
|
5
|
+
export const VM_SETUP_LOG_METHOD = 'setup';
|
|
6
|
+
/** How NodeLog names the setup to its observers (see ConsoleLogger). */
|
|
7
|
+
export const VM_SETUP_NODE_LOG_METHOD = `${VM_SETUP_LOG_CLASS}.${VM_SETUP_LOG_METHOD}`;
|
|
8
|
+
/**
|
|
9
|
+
* Runs a job VM's setup bracketed on the node's log stream, which the console shows as one
|
|
10
|
+
* spinner. Answers or throws as `setup` does.
|
|
11
|
+
*/
|
|
12
|
+
export async function trackVmSetup(jobAddress, setup) {
|
|
13
|
+
emit('call', jobAddress);
|
|
14
|
+
let result;
|
|
15
|
+
try {
|
|
16
|
+
result = await setup();
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
emit('error', jobAddress);
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
emit('return', jobAddress);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
function emit(type, jobAddress) {
|
|
26
|
+
logEmitter.emit('log', {
|
|
27
|
+
class: VM_SETUP_LOG_CLASS,
|
|
28
|
+
method: VM_SETUP_LOG_METHOD,
|
|
29
|
+
arguments: [jobAddress],
|
|
30
|
+
timestamp: new Date().toISOString(),
|
|
31
|
+
type,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -3,6 +3,7 @@ import { MarketHandler } from './market/marketHandler.js';
|
|
|
3
3
|
import { NodeNotRegisteredError } from '../errors/NodeNotRegisteredError.js';
|
|
4
4
|
import { RunHandler } from './run/runHandler.js';
|
|
5
5
|
import { JobHandler } from './job/jobHandler.js';
|
|
6
|
+
import { selectJobRuntimeEnvironment } from './job/selectJobRuntimeEnvironment.js';
|
|
6
7
|
import { DB } from '../db/index.js';
|
|
7
8
|
import { Provider } from '../provider/Provider.js';
|
|
8
9
|
import { applyLoggingProxyToClass } from '../../../packages/common/src/index.js';
|
|
@@ -37,13 +38,19 @@ export class BasicNode {
|
|
|
37
38
|
this.repository = new NodeRepository(db);
|
|
38
39
|
this.containerOrchestration = selectContainerOrchestrationProvider(options.provider, options.podman, options.gpu, options.trustedExecutionRuntime, nodeOrchestrationHooks(this.repository));
|
|
39
40
|
this.resourceManager = new ResourceManager(this.containerOrchestration, this.repository);
|
|
40
|
-
this.provider = new Provider(this.containerOrchestration, this.
|
|
41
|
+
this.provider = new Provider(this.containerOrchestration, this.resourceManager);
|
|
42
|
+
this.environment = selectJobRuntimeEnvironment(options, {
|
|
43
|
+
containerOrchestration: this.containerOrchestration,
|
|
44
|
+
repository: this.repository,
|
|
45
|
+
resourceManager: this.resourceManager,
|
|
46
|
+
dataDir: store.dir,
|
|
47
|
+
});
|
|
41
48
|
this.apiHandler = new ApiHandler(nodeAddress(), this.repository, this.provider, options.port,
|
|
42
49
|
// Read when a request comes in: the job handler is made below.
|
|
43
50
|
(jobId) => this.jobHandler.jobRuntimeUrl(jobId));
|
|
44
51
|
this.balanceHandler = new BalanceHandler(this.kit);
|
|
45
|
-
this.jobHandler = new JobHandler(this.kit, this.
|
|
46
|
-
this.marketHandler = new MarketHandler(this.kit, this.
|
|
52
|
+
this.jobHandler = new JobHandler(this.kit, this.environment, this.repository, store.dir);
|
|
53
|
+
this.marketHandler = new MarketHandler(this.kit, this.environment, store.dir);
|
|
47
54
|
this.runHandler = new RunHandler(this.kit, this.repository);
|
|
48
55
|
this.keyHandler = new KeyHandler(this.kit);
|
|
49
56
|
this.healthHandler = new HealthHandler(this.kit, this.containerOrchestration, this.marketHandler, this.keyHandler);
|
|
@@ -146,7 +153,7 @@ export class BasicNode {
|
|
|
146
153
|
*/
|
|
147
154
|
async setup(liveJob) {
|
|
148
155
|
await this.resourceManager.resyncResourcesDB(liveJob);
|
|
149
|
-
await this.
|
|
156
|
+
await this.environment.sweep(liveJob).catch((error) => console.error(`Failed to remove what earlier jobs left: ${error.message}`));
|
|
150
157
|
await this.jobHandler.removeLeftoverJobs(liveJob);
|
|
151
158
|
}
|
|
152
159
|
async fetchMarketResources(market) {
|
|
@@ -160,7 +167,7 @@ export class BasicNode {
|
|
|
160
167
|
*/
|
|
161
168
|
async pullJobRuntimeImage() {
|
|
162
169
|
try {
|
|
163
|
-
await this.
|
|
170
|
+
await this.environment.prepare();
|
|
164
171
|
}
|
|
165
172
|
catch (error) {
|
|
166
173
|
const failure = error instanceof Error ? error : new Error(String(error));
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { NodeRepository } from '../../repository/NodeRepository.js';
|
|
2
|
+
import { ResourceManager } from '../resource/resourceManager.js';
|
|
3
|
+
import { ContainerOrchestrationInterface } from '../../../../packages/container-orchestrator/src/index.js';
|
|
4
|
+
import { type JobRuntimeConsole, type JobRuntimeKind } from '../../../../packages/job-runtime/src/host/index.js';
|
|
5
|
+
import type { ResourceCacheSnapshot } from '../../../../packages/job-runtime/src/resources/index.js';
|
|
6
|
+
import type { JobRuntimeEnvironment } from './JobRuntimeEnvironment.js';
|
|
7
|
+
/**
|
|
8
|
+
* Each job's runtime as a sidecar container beside the node, which runs the
|
|
9
|
+
* job's own containers.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ContainerJobRuntime implements JobRuntimeEnvironment {
|
|
12
|
+
private containerOrchestration;
|
|
13
|
+
private repository;
|
|
14
|
+
/** The node's image and resource cache, which a job's sidecar starts from. */
|
|
15
|
+
private resourceManager;
|
|
16
|
+
private jobRuntimeVolumesSwept;
|
|
17
|
+
private readonly jobRuntimeUrls;
|
|
18
|
+
constructor(containerOrchestration: ContainerOrchestrationInterface, repository: NodeRepository,
|
|
19
|
+
/** The node's image and resource cache, which a job's sidecar starts from. */
|
|
20
|
+
resourceManager: ResourceManager);
|
|
21
|
+
/** The sidecar shares the node's cache: it starts from the node's records. */
|
|
22
|
+
cacheSnapshot(): ResourceCacheSnapshot;
|
|
23
|
+
/**
|
|
24
|
+
* Writes what the job's sidecar changed in the cache records back to the
|
|
25
|
+
* node's. Whole or not at all: changes of a version the node does not know
|
|
26
|
+
* are left out of the records rather than half applied.
|
|
27
|
+
*/
|
|
28
|
+
writeBackCache(hostDir: string, jobAddress: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Starts the job's runtime sidecar (packages/job-runtime) with the job's
|
|
31
|
+
* address and the host it runs on, nothing about the job itself: an
|
|
32
|
+
* onchain job it resolves onchain, runs, publishes its job API for at
|
|
33
|
+
* https://<jobId>.<frp server> and pins the result of; an inline run's
|
|
34
|
+
* definition is in the seed in `hostDir`, the job's directory, where the
|
|
35
|
+
* node also serves it its socket (JobRuntimeHost).
|
|
36
|
+
*
|
|
37
|
+
* A sidecar a previous node left behind is replaced; the new one resumes
|
|
38
|
+
* the job from the data volume they share. The sidecar has no restart
|
|
39
|
+
* policy: the node starts it again if it exits before its result (see
|
|
40
|
+
* JobRuntimeSession).
|
|
41
|
+
*/
|
|
42
|
+
start(jobAddress: string, hostDir: string, kind: JobRuntimeKind,
|
|
43
|
+
/** What its console carries; `entries` for `nosana node run` to render. */
|
|
44
|
+
consoleOutput?: JobRuntimeConsole): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* The group a sidecar needs to use the runtime socket: the socket's own,
|
|
47
|
+
* which is opened to its group where it is root's alone (podman serves its
|
|
48
|
+
* socket that way; docker's is its `docker` group's already). The socket
|
|
49
|
+
* is the one the node itself uses, bound into its container read-write,
|
|
50
|
+
* so the change reaches the socket the sidecar gets bound. Undefined when
|
|
51
|
+
* the socket cannot be read or changed (a TCP endpoint, a dev socket the
|
|
52
|
+
* user does not own), in which case the sidecar runs as root, as it did
|
|
53
|
+
* before, rather than not at all.
|
|
54
|
+
*/
|
|
55
|
+
private jobRuntimeSocketGroup;
|
|
56
|
+
/**
|
|
57
|
+
* Makes the job's data volume the sidecar user's. A volume created as the
|
|
58
|
+
* sidecar starts takes the ownership of the image's mount point, which is
|
|
59
|
+
* the user's; one that is already there (a sidecar a previous node left,
|
|
60
|
+
* one that may have run as root) is chowned first, by a one-shot container
|
|
61
|
+
* on the same image, so that the sidecar can write its records.
|
|
62
|
+
*/
|
|
63
|
+
private ownJobRuntimeVolume;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the job has a sidecar, running or exited: one that outlived the
|
|
66
|
+
* node's last process, to take over. Only the runtime saying there is no
|
|
67
|
+
* such container answers false; a runtime that fails to answer (its daemon
|
|
68
|
+
* still starting after a host restart, say) is asked again, for about two
|
|
69
|
+
* minutes, before its last error is thrown.
|
|
70
|
+
*/
|
|
71
|
+
has(jobAddress: string): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Whether the job's sidecar runs on an image other than the configured one
|
|
74
|
+
* as the node has it locally (pulled by prepare before the job
|
|
75
|
+
* loop): a node updated mid-job meets the sidecar of the version before it.
|
|
76
|
+
* An exited sidecar is not outdated, nor is one whose image or the
|
|
77
|
+
* configured one cannot be read: an image the node does not have is no
|
|
78
|
+
* reason to replace a sidecar that runs.
|
|
79
|
+
*/
|
|
80
|
+
isOutdated(jobAddress: string): Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* Waits for the job's sidecar to exit, and answers its exit code;
|
|
83
|
+
* undefined once it is gone. A wait the runtime drops (its daemon
|
|
84
|
+
* restarting) is waited again. Only the runtime saying there is no such
|
|
85
|
+
* container means gone: one that fails to answer is asked again for as
|
|
86
|
+
* long as it takes, since answering gone would have the node remove a
|
|
87
|
+
* sidecar that may still run. The job's expiry is enforced apart from
|
|
88
|
+
* this, and removing the sidecar ends the wait.
|
|
89
|
+
*/
|
|
90
|
+
wait(jobAddress: string): Promise<{
|
|
91
|
+
exitCode: number;
|
|
92
|
+
} | undefined>;
|
|
93
|
+
/** Starts the job's exited sidecar again, as it was. */
|
|
94
|
+
restart(jobAddress: string): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Removes what job sidecars of this node left behind, the sidecars
|
|
97
|
+
* themselves included, for every job but `liveJob`, which this node still
|
|
98
|
+
* runs. A sidecar stamps its job and this node on everything it starts, so
|
|
99
|
+
* this finds what a sidecar that died never removed, and no other node's.
|
|
100
|
+
*/
|
|
101
|
+
sweep(liveJob?: string): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Where the job's sidecar serves its job API: its address on the gateway
|
|
104
|
+
* network, which a node on the network and one on the host both reach.
|
|
105
|
+
* Undefined while it is not running. An address is looked up again after
|
|
106
|
+
* a few seconds, since a restarted sidecar may come back with another; a
|
|
107
|
+
* miss is not kept, so a sidecar that is starting is found once it is up.
|
|
108
|
+
*/
|
|
109
|
+
url(jobAddress: string): Promise<string | undefined>;
|
|
110
|
+
/**
|
|
111
|
+
* Follows the sidecar's console as it runs (its phases, then the summary of
|
|
112
|
+
* the operations): its log from the start, followed. Undefined when the
|
|
113
|
+
* runtime cannot give it.
|
|
114
|
+
*/
|
|
115
|
+
output(jobAddress: string, read: (stream: 'stdout' | 'stderr', text: string) => void): Promise<(() => void) | undefined>;
|
|
116
|
+
/**
|
|
117
|
+
* Pulls the sidecar image `.env` names and records it in the image cache,
|
|
118
|
+
* where the resync between jobs ages out what goes unused, so a bump's
|
|
119
|
+
* predecessor goes the way of any other image.
|
|
120
|
+
*/
|
|
121
|
+
prepare(): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* Removes the job's sidecar, then whatever else of the job is left: its
|
|
124
|
+
* frpc, and any operation container a sidecar that died never removed.
|
|
125
|
+
* Then the sidecar's data volume. Throws on failure; what will not go is
|
|
126
|
+
* swept again by the next resync (sweep).
|
|
127
|
+
*/
|
|
128
|
+
remove(jobAddress: string): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Removes job-runtime-<jobId> volumes left by a job whose stop never ran (the
|
|
131
|
+
* node died mid-job). The volume resync does not know them, and a reaped
|
|
132
|
+
* sidecar container leaves its named volume behind. Runs once, on the first
|
|
133
|
+
* sidecar start after boot. The job starting keeps its volume, to resume
|
|
134
|
+
* from, and a volume still in use fails to delete and is kept for the next
|
|
135
|
+
* boot.
|
|
136
|
+
*/
|
|
137
|
+
private removeOrphanedJobRuntimeVolumes;
|
|
138
|
+
private hostSocketPath?;
|
|
139
|
+
/** The runtime socket as a host path, which is what a bind source must be. */
|
|
140
|
+
private resolveHostSocketPath;
|
|
141
|
+
}
|