@nosana/node 1.0.7 → 1.0.8-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/package.json +1 -1
- package/dist/src/NodeManager/node/task/TaskManager.d.ts +2 -0
- package/dist/src/NodeManager/node/task/TaskManager.js +2 -1
- package/dist/src/NodeManager/node/task/globalStore/index.d.ts +1 -0
- package/dist/src/NodeManager/node/task/globalStore/index.js +1 -0
- package/dist/src/NodeManager/node/task/globalStore/setContainerIp.d.ts +2 -0
- package/dist/src/NodeManager/node/task/globalStore/setContainerIp.js +9 -0
- package/dist/src/NodeManager/node/task/operations/runTaskManagerOperation.js +3 -0
- package/dist/src/NodeManager/provider/Provider.js +22 -6
- package/dist/src/NodeManager/provider/containerOrchestration/docker/createDockerRunOptions.d.ts +1 -1
- package/dist/src/NodeManager/provider/containerOrchestration/docker/createDockerRunOptions.js +9 -7
- package/dist/src/NodeManager/provider/containerOrchestration/interface.d.ts +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -50,6 +50,7 @@ export interface TaskLog {
|
|
|
50
50
|
}
|
|
51
51
|
export type OperationData = {
|
|
52
52
|
host?: string;
|
|
53
|
+
container_ip?: string;
|
|
53
54
|
endpoint?: {
|
|
54
55
|
[key: string]: string;
|
|
55
56
|
};
|
|
@@ -197,6 +198,7 @@ export default class TaskManager {
|
|
|
197
198
|
setResult: (opId: string, key: string, value: any) => void;
|
|
198
199
|
setResults: (opId: string, values: Record<string, any>) => void;
|
|
199
200
|
setHost: (opId: string, host: string) => void;
|
|
201
|
+
setContainerIp: (opId: string, ip: string) => void;
|
|
200
202
|
setDefaults: (flowId: string, project: string, jobDefinition: JobDefinition) => void;
|
|
201
203
|
rehydrateEndpointsForOperation: (flowId: string, project: string, jobDefinition: JobDefinition, opId: string) => void;
|
|
202
204
|
getByPath: (opId: string, path: string) => any;
|
|
@@ -13,7 +13,7 @@ import { createDependencyMap } from './executions/createDependencyMap.js';
|
|
|
13
13
|
import { getCurrentGroup, getCurrentGroupStatus, getGroupStatus, getOperationsStatus, getOperationStatus, } from './operations/getOperationsInfos.js';
|
|
14
14
|
import { addLog, getAllLogs, getLogsByGroup, getLogsByOp, subscribe, unsubscribe, } from './loggers/logManager.js';
|
|
15
15
|
import { moveTaskManagerGroupOperations } from './operations/moveTaskManagerGroupOperation.js';
|
|
16
|
-
import { setResult, setResults, setHost, setDefaults, rehydrateEndpointsForOperation, getByPath, resolveLiteralsInString, interpolate, interpolateOperation, transformCollections, } from './globalStore/index.js';
|
|
16
|
+
import { setResult, setResults, setHost, setDefaults, setContainerIp, rehydrateEndpointsForOperation, getByPath, resolveLiteralsInString, interpolate, interpolateOperation, transformCollections, } from './globalStore/index.js';
|
|
17
17
|
import { configs } from '../../configs/configs.js';
|
|
18
18
|
import { getSDK } from '../../sdk/index.js';
|
|
19
19
|
export const StopReasons = {
|
|
@@ -155,6 +155,7 @@ export default class TaskManager {
|
|
|
155
155
|
this.setResult = setResult.bind(this);
|
|
156
156
|
this.setResults = setResults.bind(this);
|
|
157
157
|
this.setHost = setHost.bind(this);
|
|
158
|
+
this.setContainerIp = setContainerIp.bind(this);
|
|
158
159
|
this.setDefaults = setDefaults.bind(this);
|
|
159
160
|
this.rehydrateEndpointsForOperation =
|
|
160
161
|
rehydrateEndpointsForOperation.bind(this);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { setResult } from './setResult.js';
|
|
2
2
|
export { setResults } from './setResults.js';
|
|
3
3
|
export { setHost } from './setHost.js';
|
|
4
|
+
export { setContainerIp } from './setContainerIp.js';
|
|
4
5
|
export { setDefaults, rehydrateEndpointsForOperation } from './setDefaults.js';
|
|
5
6
|
export { getByPath } from './getByPath.js';
|
|
6
7
|
export { resolveLiteralsInString } from './resolveLiteralsInString.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { setResult } from './setResult.js';
|
|
2
2
|
export { setResults } from './setResults.js';
|
|
3
3
|
export { setHost } from './setHost.js';
|
|
4
|
+
export { setContainerIp } from './setContainerIp.js';
|
|
4
5
|
export { setDefaults, rehydrateEndpointsForOperation } from './setDefaults.js';
|
|
5
6
|
export { getByPath } from './getByPath.js';
|
|
6
7
|
export { resolveLiteralsInString } from './resolveLiteralsInString.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function setContainerIp(opId, internalIp) {
|
|
2
|
+
const op = (this.globalOpStore[opId] ??= {});
|
|
3
|
+
op.container_ip = internalIp;
|
|
4
|
+
// Host updated; attempt endpoint rehydration for this op
|
|
5
|
+
const flow = this.repository.getFlow(this.job);
|
|
6
|
+
if (flow) {
|
|
7
|
+
this.rehydrateEndpointsForOperation(flow.id, flow.project, flow.jobDefinition, opId);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -136,6 +136,9 @@ export async function runTaskManagerOperation(flow, op, dependent) {
|
|
|
136
136
|
emitter.on('updateOpHost', (body) => {
|
|
137
137
|
this.setHost(op.id, body.name);
|
|
138
138
|
});
|
|
139
|
+
emitter.on('setContainerInternalIp', (ip) => {
|
|
140
|
+
this.setContainerIp(op.id, ip);
|
|
141
|
+
});
|
|
139
142
|
/**
|
|
140
143
|
* Subscribes to the 'start' event, which marks the official beginning of an operation’s execution.
|
|
141
144
|
*
|
|
@@ -212,7 +212,7 @@ export class Provider {
|
|
|
212
212
|
const resourceVolumes = await this.resourceManager.getResourceVolumes(op.args.resources ?? [], controller);
|
|
213
213
|
volumes.push(...resourceVolumes);
|
|
214
214
|
}
|
|
215
|
-
|
|
215
|
+
const createContainerOptions = {
|
|
216
216
|
name,
|
|
217
217
|
cmd,
|
|
218
218
|
env,
|
|
@@ -225,8 +225,22 @@ export class Provider {
|
|
|
225
225
|
aliases,
|
|
226
226
|
restart_policy: op.args.restart_policy,
|
|
227
227
|
runtime: op.args.trusted_execution_env
|
|
228
|
-
}
|
|
228
|
+
};
|
|
229
|
+
if (op.args.trusted_execution_env) {
|
|
230
|
+
await this.containerOrchestration.pullImage("busybox");
|
|
231
|
+
await this.resourceManager.images.setImage("busybox");
|
|
232
|
+
await this.containerOrchestration.runFlowContainer("busybox", {
|
|
233
|
+
name: `bridge-${name}`,
|
|
234
|
+
cmd: ['sleep', 'infinity'],
|
|
235
|
+
});
|
|
236
|
+
createContainerOptions.bind_network_to_container = `bridge-${name}`;
|
|
237
|
+
}
|
|
238
|
+
container = await this.containerOrchestration.runFlowContainer(op.args.image ?? flow.jobDefinition.global?.image, createContainerOptions);
|
|
239
|
+
const info = await container.inspect();
|
|
229
240
|
emitter.emit('updateOpState', { providerId: container.id });
|
|
241
|
+
if (info.NetworkSettings?.Networks["NOSANA_GATEWAY"].IPAddress) {
|
|
242
|
+
emitter.emit('setContainerInternalIp', info.NetworkSettings.Networks["NOSANA_GATEWAY"].IPAddress);
|
|
243
|
+
}
|
|
230
244
|
stateManager = new ContainerStateManager(container, controller, emitter, op.args.restart_policy);
|
|
231
245
|
await stateManager.startMonitoring();
|
|
232
246
|
if (isOpExposed(op)) {
|
|
@@ -277,8 +291,10 @@ export class Provider {
|
|
|
277
291
|
try {
|
|
278
292
|
const index = getOpStateIndex(flow.jobDefinition.ops, op.id);
|
|
279
293
|
const name = flow.id + '-' + index;
|
|
280
|
-
const opContainer = await
|
|
281
|
-
|
|
294
|
+
const [opContainer, getSupportContainers] = await Promise.all([
|
|
295
|
+
this.containerOrchestration.getContainerByName(name),
|
|
296
|
+
this.containerOrchestration.getContainersByName([`frpc-${name}`, `bridge-${name}`]),
|
|
297
|
+
]);
|
|
282
298
|
if (opContainer) {
|
|
283
299
|
const info = await this.containerOrchestration.stopAndDeleteContainer(opContainer.id);
|
|
284
300
|
if (info) {
|
|
@@ -289,8 +305,8 @@ export class Provider {
|
|
|
289
305
|
});
|
|
290
306
|
}
|
|
291
307
|
}
|
|
292
|
-
if (
|
|
293
|
-
await this.containerOrchestration.stopAndDeleteContainer(
|
|
308
|
+
if (getSupportContainers) {
|
|
309
|
+
await Promise.all(getSupportContainers.map((container) => this.containerOrchestration.stopAndDeleteContainer(container.id)));
|
|
294
310
|
}
|
|
295
311
|
await this.containerOrchestration.deleteNetwork(name);
|
|
296
312
|
if (flow.jobDefinition.ops[index]
|
package/dist/src/NodeManager/provider/containerOrchestration/docker/createDockerRunOptions.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ContainerCreateOptions } from "dockerode";
|
|
2
2
|
import { RunContainerArgs } from "../interface";
|
|
3
|
-
export declare function createDockerRunOptions(image: string, { name, cmd, gpu, volumes, env, work_dir, entrypoint, aliases, restart_policy, runtime }: RunContainerArgs, gpuOption: string): ContainerCreateOptions;
|
|
3
|
+
export declare function createDockerRunOptions(image: string, { name, cmd, gpu, volumes, env, work_dir, entrypoint, aliases, restart_policy, runtime, bind_network_to_container }: RunContainerArgs, gpuOption: string): ContainerCreateOptions;
|
package/dist/src/NodeManager/provider/containerOrchestration/docker/createDockerRunOptions.js
CHANGED
|
@@ -10,7 +10,7 @@ function parseRestartPolicy(restart_policy) {
|
|
|
10
10
|
}
|
|
11
11
|
return undefined;
|
|
12
12
|
}
|
|
13
|
-
export function createDockerRunOptions(image, { name, cmd, gpu, volumes, env, work_dir, entrypoint, aliases, restart_policy, runtime }, gpuOption) {
|
|
13
|
+
export function createDockerRunOptions(image, { name, cmd, gpu, volumes, env, work_dir, entrypoint, aliases, restart_policy, runtime, bind_network_to_container }, gpuOption) {
|
|
14
14
|
const devices = [];
|
|
15
15
|
if (gpu) {
|
|
16
16
|
devices.push({
|
|
@@ -37,11 +37,13 @@ export function createDockerRunOptions(image, { name, cmd, gpu, volumes, env, wo
|
|
|
37
37
|
Image: image,
|
|
38
38
|
WorkingDir: work_dir,
|
|
39
39
|
Entrypoint: entrypoint,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
...(!bind_network_to_container ? {
|
|
41
|
+
NetworkingConfig: {
|
|
42
|
+
EndpointsConfig: {
|
|
43
|
+
NOSANA_GATEWAY: aliases ? { Aliases: aliases } : {},
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
} : {}),
|
|
45
47
|
HostConfig: {
|
|
46
48
|
ExtraHosts: [
|
|
47
49
|
'host.docker.internal:8.8.8.8',
|
|
@@ -53,7 +55,7 @@ export function createDockerRunOptions(image, { name, cmd, gpu, volumes, env, wo
|
|
|
53
55
|
Type: 'volume',
|
|
54
56
|
ReadOnly: readonly || false,
|
|
55
57
|
})),
|
|
56
|
-
NetworkMode: 'bridge',
|
|
58
|
+
NetworkMode: bind_network_to_container ? bind_network_to_container : 'bridge',
|
|
57
59
|
DeviceRequests: devices,
|
|
58
60
|
...(runtime === 'SEV-SNP' ? {
|
|
59
61
|
Devices: [
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nosana/node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8-rc",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@nosana/node",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.8-rc",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@coral-xyz/anchor": "^0.28.1-beta.1",
|