@nosana/node 1.1.73-dev.mr80.17351441846 → 1.1.73
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 +1 -1
- package/dist/package.json +9 -10
- package/dist/packages/container-orchestrator/src/docker/createDockerRunOptions.d.ts +1 -1
- package/dist/packages/container-orchestrator/src/docker/dockerExtended/index.d.ts +1 -1
- package/dist/packages/container-orchestrator/src/docker/index.d.ts +1 -3
- package/dist/packages/container-orchestrator/src/docker/index.js +21 -16
- package/dist/packages/container-orchestrator/src/hooks.d.ts +2 -9
- package/dist/packages/container-orchestrator/src/hooks.js +0 -5
- package/dist/packages/container-orchestrator/src/index.d.ts +0 -1
- package/dist/packages/container-orchestrator/src/index.js +0 -1
- package/dist/packages/container-orchestrator/src/interface.d.ts +1 -4
- package/dist/packages/container-orchestrator/src/labels.d.ts +0 -2
- package/dist/packages/container-orchestrator/src/labels.js +0 -2
- package/dist/packages/container-orchestrator/src/podman/index.js +9 -4
- package/dist/packages/container-orchestrator/src/podman/utils/createPodmanRunOptions.d.ts +1 -1
- package/dist/packages/container-orchestrator/src/types.d.ts +5 -0
- package/dist/src/NodeManager/clients/hostManager/index.js +3 -3
- package/dist/src/NodeManager/clients/types.utils.d.ts +1 -0
- package/dist/src/NodeManager/configs/configs.d.ts +2 -1
- package/dist/src/NodeManager/configs/configs.js +1 -0
- package/dist/src/NodeManager/db/index.d.ts +44 -11
- package/dist/src/NodeManager/db/index.js +3 -5
- package/dist/src/NodeManager/errors/NodeNotQualifiedError.js +2 -2
- package/dist/src/NodeManager/index.js +14 -25
- package/dist/src/NodeManager/input/OperatorInput.d.ts +2 -0
- package/dist/src/NodeManager/jobs/index.d.ts +6 -1
- package/dist/src/NodeManager/jobs/index.js +45 -2
- package/dist/src/NodeManager/monitoring/log/NodeLog.d.ts +8 -6
- package/dist/src/NodeManager/monitoring/log/NodeLog.js +461 -38
- package/dist/src/NodeManager/monitoring/log/console/ConsoleLogger.d.ts +1 -0
- package/dist/src/NodeManager/monitoring/log/console/ConsoleLogger.js +5 -5
- package/dist/{packages/common/src → src/NodeManager/monitoring/proxy}/loggingProxy.d.ts +1 -0
- package/dist/{packages/common/src → src/NodeManager/monitoring/proxy}/loggingProxy.js +1 -0
- package/dist/src/NodeManager/monitoring/reportError.js +3 -2
- package/dist/src/NodeManager/monitoring/state/NodeState.d.ts +1 -1
- package/dist/src/NodeManager/monitoring/state/NodeState.js +29 -1
- package/dist/src/NodeManager/node/Node.d.ts +8 -28
- package/dist/src/NodeManager/node/Node.js +45 -81
- package/dist/src/NodeManager/node/api/ApiEventEmitter.d.ts +1 -0
- package/dist/src/NodeManager/node/api/ApiHandler.d.ts +7 -21
- package/dist/src/NodeManager/node/api/ApiHandler.js +46 -67
- package/dist/src/NodeManager/node/api/eventsource/index.d.ts +6 -0
- package/dist/src/NodeManager/node/api/middlewares/index.d.ts +1 -0
- package/dist/src/NodeManager/node/api/middlewares/index.js +2 -0
- package/dist/src/NodeManager/node/api/middlewares/rest/verifyJobOwnerSignatureMiddleware.d.ts +5 -0
- package/dist/src/NodeManager/node/api/middlewares/rest/verifyJobOwnerSignatureMiddleware.js +29 -0
- package/dist/src/NodeManager/node/api/middlewares/ws/verifyWSJobOwnerSignatureMiddleware.js +8 -6
- package/dist/src/NodeManager/node/api/routes/get/index.d.ts +7 -0
- package/dist/src/NodeManager/node/api/routes/get/index.js +7 -0
- package/dist/src/NodeManager/node/api/routes/get/job-definition.d.ts +5 -0
- package/dist/src/NodeManager/node/api/routes/get/job-definition.js +16 -0
- package/dist/src/NodeManager/node/api/routes/get/job-info/buildInfoObject.d.ts +17 -0
- package/dist/src/NodeManager/node/api/routes/get/job-info/buildInfoObject.js +15 -0
- package/dist/src/NodeManager/node/api/routes/get/job-info/job-info.d.ts +5 -0
- package/dist/src/NodeManager/node/api/routes/get/job-info/job-info.js +18 -0
- package/dist/src/NodeManager/node/api/routes/get/job-info/pollActiveJob.d.ts +6 -0
- package/dist/src/NodeManager/node/api/routes/get/job-info/pollActiveJob.js +42 -0
- package/dist/src/NodeManager/node/api/routes/get/job-operation-info.d.ts +28 -0
- package/dist/src/NodeManager/node/api/routes/get/job-operation-info.js +53 -0
- package/dist/src/NodeManager/node/api/routes/get/job-results.d.ts +5 -0
- package/dist/src/NodeManager/node/api/routes/get/job-results.js +15 -0
- package/dist/src/NodeManager/node/api/routes/get/job-stats-stream.d.ts +5 -0
- package/dist/{packages/job-runtime/src/api/routes/stats.js → src/NodeManager/node/api/routes/get/job-stats-stream.js} +5 -25
- package/dist/src/NodeManager/node/api/routes/get/job-stats.d.ts +5 -0
- package/dist/src/NodeManager/node/api/routes/get/job-stats.js +22 -0
- package/dist/src/NodeManager/node/api/routes/get/service-url.d.ts +5 -0
- package/dist/src/NodeManager/node/api/routes/get/service-url.js +27 -0
- package/dist/src/NodeManager/node/api/routes/index.d.ts +1 -0
- package/dist/src/NodeManager/node/api/routes/index.js +1 -0
- package/dist/src/NodeManager/node/api/routes/post/index.d.ts +4 -0
- package/dist/src/NodeManager/node/api/routes/post/index.js +4 -0
- package/dist/src/NodeManager/node/api/routes/post/job-definition.d.ts +6 -0
- package/dist/src/NodeManager/node/api/routes/post/job-definition.js +15 -0
- package/dist/src/NodeManager/node/api/routes/post/job-operation-actions.d.ts +20 -0
- package/dist/src/NodeManager/node/api/routes/post/job-operation-actions.js +63 -0
- package/dist/src/NodeManager/node/api/routes/post/service-stop.d.ts +5 -0
- package/dist/src/NodeManager/node/api/routes/post/service-stop.js +13 -0
- package/dist/src/NodeManager/node/api/routes/post/ssh-authorize.d.ts +17 -0
- package/dist/src/NodeManager/node/api/routes/post/ssh-authorize.js +53 -0
- package/dist/src/NodeManager/node/api/routes/wss/index.d.ts +2 -0
- package/dist/src/NodeManager/node/api/routes/wss/index.js +2 -0
- package/dist/src/NodeManager/node/api/routes/wss/log.d.ts +9 -0
- package/dist/src/NodeManager/node/api/routes/wss/log.js +55 -2
- package/dist/src/NodeManager/node/api/routes/wss/status.js +4 -2
- package/dist/{packages/job-runtime/src/api/terminal/terminalBridge.d.ts → src/NodeManager/node/api/routes/wss/terminal/terminal.d.ts} +7 -6
- package/dist/{packages/job-runtime/src/api/terminal/terminalBridge.js → src/NodeManager/node/api/routes/wss/terminal/terminal.js} +23 -15
- package/dist/{packages/job-runtime/src/api → src/NodeManager/node/api/routes/wss}/terminal/terminalAuthorization.d.ts +1 -0
- package/dist/{packages/job-runtime/src/api → src/NodeManager/node/api/routes/wss}/terminal/terminalAuthorization.js +3 -3
- package/dist/src/NodeManager/node/api/types/index.d.ts +2 -2
- package/dist/{packages/job-runtime/src/api → src/NodeManager/node/api/utils}/interval.d.ts +5 -2
- package/dist/{packages/job-runtime/src/api → src/NodeManager/node/api/utils}/interval.js +1 -1
- package/dist/src/NodeManager/node/balance/balanceHandler.d.ts +5 -4
- package/dist/src/NodeManager/node/balance/balanceHandler.js +5 -6
- package/dist/src/NodeManager/node/expiry/expiryHandler.d.ts +10 -2
- package/dist/src/NodeManager/node/expiry/expiryHandler.js +36 -8
- package/dist/src/NodeManager/node/grid/gridHandler.d.ts +13 -0
- package/dist/src/NodeManager/node/grid/gridHandler.js +35 -0
- package/dist/src/NodeManager/node/health/healthHandler.d.ts +4 -3
- package/dist/src/NodeManager/node/health/healthHandler.js +8 -5
- package/dist/src/NodeManager/node/job/JobRegistry.d.ts +6 -16
- package/dist/src/NodeManager/node/job/JobRegistry.js +22 -68
- package/dist/src/NodeManager/node/job/defination/JobDefinitionStrategy.d.ts +13 -0
- package/dist/src/NodeManager/node/job/defination/JobDefinitionStrategy.js +21 -0
- package/dist/src/NodeManager/node/job/defination/strategy/ApiJobDefinitionStrategy.d.ts +8 -0
- package/dist/{packages/job-runtime/src/logistics/definition → src/NodeManager/node/job/defination/strategy}/ApiJobDefinitionStrategy.js +5 -5
- package/dist/{packages/job-runtime/src/logistics/definition → src/NodeManager/node/job/defination/strategy}/ApiListenJobDefinitionStrategy.d.ts +3 -2
- package/dist/src/NodeManager/node/job/defination/strategy/IpfsJobDefinitionStrategy.d.ts +5 -0
- package/dist/src/NodeManager/node/job/defination/strategy/IpfsJobDefinitionStrategy.js +11 -0
- package/dist/src/NodeManager/node/job/jobExternalUtil.d.ts +10 -0
- package/dist/src/NodeManager/node/job/jobExternalUtil.js +96 -0
- package/dist/src/NodeManager/node/job/jobHandler.d.ts +14 -78
- package/dist/src/NodeManager/node/job/jobHandler.js +129 -224
- package/dist/src/NodeManager/node/job/result/ResultReturnStrategy.d.ts +13 -0
- package/dist/src/NodeManager/node/job/result/ResultReturnStrategy.js +21 -0
- package/dist/{packages/job-runtime/src/logistics/result → src/NodeManager/node/job/result/startegy}/ApiListenResultReturnStrategy.d.ts +2 -1
- package/dist/src/NodeManager/node/job/result/startegy/ApiResultReturnStrategy.d.ts +8 -0
- package/dist/{packages/job-runtime/src/logistics/result → src/NodeManager/node/job/result/startegy}/ApiResultReturnStrategy.js +5 -5
- package/dist/src/NodeManager/node/key/keyHandler.d.ts +9 -15
- package/dist/src/NodeManager/node/key/keyHandler.js +9 -18
- package/dist/src/NodeManager/node/market/benchmark.d.ts +4 -11
- package/dist/src/NodeManager/node/market/benchmark.js +40 -55
- package/dist/src/NodeManager/node/market/hostManager.d.ts +16 -14
- package/dist/src/NodeManager/node/market/hostManager.js +12 -0
- package/dist/src/NodeManager/node/market/marketAccess.d.ts +3 -9
- package/dist/src/NodeManager/node/market/marketAccess.js +9 -27
- package/dist/src/NodeManager/node/market/marketHandler.d.ts +7 -11
- package/dist/src/NodeManager/node/market/marketHandler.js +18 -33
- package/dist/src/NodeManager/node/register/index.js +1 -1
- package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createResourceName.d.ts +1 -1
- package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createResourceName.js +1 -1
- package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createS3Args.d.ts +1 -1
- package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createS3Args.js +1 -1
- package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/isAuthGatedResource.d.ts +1 -1
- package/dist/src/NodeManager/node/resource/image/imageManager.d.ts +16 -12
- package/dist/src/NodeManager/node/resource/image/imageManager.js +35 -21
- package/dist/src/NodeManager/node/resource/resourceManager.d.ts +10 -26
- package/dist/src/NodeManager/node/resource/resourceManager.js +40 -48
- package/dist/src/NodeManager/node/resource/volume/volumeManager.d.ts +75 -11
- package/dist/src/NodeManager/node/resource/volume/volumeManager.js +347 -25
- package/dist/src/NodeManager/node/run/runHandler.d.ts +4 -17
- package/dist/src/NodeManager/node/run/runHandler.js +46 -69
- package/dist/src/NodeManager/node/stake/StakeHandler.d.ts +5 -18
- package/dist/src/NodeManager/node/stake/StakeHandler.js +24 -56
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/TaskManager.d.ts +47 -16
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/TaskManager.js +59 -20
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/createExecutionPlan.js +1 -0
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/createOperationMap.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/finalizeEnv.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/interpolateOperation.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setDefaults.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setDefaults.js +13 -10
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/stanatizeArrays.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/transformCollections.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/helpers/createDefaultOpState.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/helpers/createInitialFlow.d.ts +2 -2
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/loggers/StatsBuffer.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/enforceOperationTimeout.d.ts +1 -0
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/runTaskManagerOperation.d.ts +2 -2
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/runTaskManagerOperation.js +3 -2
- package/dist/{packages/job-runtime/src/resources/helpers → src/NodeManager/node/utils}/extractLogsAndResultsFromLogBuffer.d.ts +3 -1
- package/dist/{packages/job-runtime/src/resources/helpers → src/NodeManager/node/utils}/extractLogsAndResultsFromLogBuffer.js +2 -2
- package/dist/{packages/common/src → src/NodeManager/node/utils}/extractResultsFromLogs.d.ts +1 -1
- package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/utils}/multiProgressBarReporter.d.ts +2 -4
- package/dist/src/NodeManager/node/utils/multiProgressBarReporter.js +22 -0
- package/dist/src/NodeManager/node/utils/poll.d.ts +1 -1
- package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/utils}/progressBarReporter.d.ts +2 -4
- package/dist/src/NodeManager/node/utils/progressBarReporter.js +28 -0
- package/dist/{packages/job-runtime/src → src/NodeManager}/provider/ContainerStateManager.d.ts +3 -10
- package/dist/{packages/job-runtime/src → src/NodeManager}/provider/ContainerStateManager.js +5 -23
- package/dist/{packages/job-runtime/src → src/NodeManager}/provider/ExposedPortHealthCheck.d.ts +5 -4
- package/dist/src/NodeManager/provider/Provider.d.ts +92 -69
- package/dist/src/NodeManager/provider/Provider.js +534 -205
- package/dist/{packages/job-runtime/src → src/NodeManager}/provider/SshAccessManager.d.ts +4 -4
- package/dist/src/NodeManager/provider/orchestrationHooks.js +2 -2
- package/dist/{packages/job-runtime/src → src/NodeManager}/provider/sshSidecar.d.ts +7 -7
- package/dist/{packages/job-runtime/src → src/NodeManager}/provider/sshSidecar.js +4 -2
- package/dist/src/NodeManager/provider/types.d.ts +9 -0
- package/dist/{packages/container-orchestrator/src → src/NodeManager/provider}/utils/parseBuffer.d.ts +3 -1
- package/dist/{packages/job-runtime/src/provider → src/NodeManager/provider/utils}/parseDockerStat.d.ts +1 -1
- package/dist/src/NodeManager/provider/webTerminal.d.ts +24 -0
- package/dist/{packages/job-runtime/src/api/runtime/terminal.js → src/NodeManager/provider/webTerminal.js} +9 -13
- package/dist/src/NodeManager/repository/NodeRepository.d.ts +41 -5
- package/dist/src/NodeManager/repository/NodeRepository.js +155 -8
- package/dist/src/NodeManager/sdk/index.d.ts +9 -6
- package/dist/src/NodeManager/sdk/index.js +94 -78
- package/dist/src/NodeManager/types/index.d.ts +9 -0
- package/dist/src/NodeManager/utils/expose-util.d.ts +14 -0
- package/dist/{packages/job-runtime/src/provider/expose.js → src/NodeManager/utils/expose-util.js} +39 -8
- package/dist/src/NodeManager/utils/jobDefinitionParser.d.ts +4 -0
- package/dist/src/NodeManager/utils/jobDefinitionParser.js +7 -1
- package/dist/src/NodeManager/utils/ops-util.d.ts +3 -0
- package/dist/src/NodeManager/utils/ops-util.js +19 -0
- package/dist/src/NodeManager/utils/tolerateBrokenStdio.d.ts +1 -0
- package/dist/src/NodeManager/utils/utils.d.ts +2 -1
- package/dist/src/NodeManager/utils/utils.js +4 -1
- package/dist/src/cli/commands/address/action.js +2 -3
- package/dist/src/cli/commands/run/action.d.ts +0 -5
- package/dist/src/cli/commands/run/action.js +18 -65
- package/dist/src/cli/commands/run/generateDeploymentEndpointsTable.d.ts +2 -2
- package/dist/src/cli/commands/run/generateDeploymentEndpointsTable.js +5 -6
- package/dist/src/cli/commands/sharedOptions/--api.d.ts +2 -0
- package/dist/src/cli/commands/sharedOptions/--api.js +2 -0
- package/dist/src/cli/commands/sharedOptions/--tee-runtime.js +1 -1
- package/dist/src/cli/commands/sharedOptions/--timeout.d.ts +2 -0
- package/dist/src/cli/commands/sharedOptions/--timeout.js +12 -0
- package/dist/src/cli/commands/start/action.d.ts +1 -0
- package/dist/src/cli/commands/start/action.js +1 -0
- package/dist/src/cli/createNosanaCli.js +4 -2
- package/dist/src/index.d.ts +1 -0
- package/dist/src/ipfs/IpfsClient.d.ts +1 -3
- package/dist/src/ipfs/IpfsClient.js +1 -1
- package/dist/src/output-formatter/outputEvents.d.ts +1 -1
- package/dist/src/static/index.d.ts +1 -1
- package/npm-shrinkwrap.json +1466 -3257
- package/package.json +9 -10
- package/dist/packages/common/src/OperationError.d.ts +0 -14
- package/dist/packages/common/src/OperationError.js +0 -18
- package/dist/packages/common/src/expose-id.d.ts +0 -12
- package/dist/packages/common/src/expose-id.js +0 -23
- package/dist/packages/common/src/index.d.ts +0 -11
- package/dist/packages/common/src/index.js +0 -11
- package/dist/packages/common/src/jobPhaseLog.d.ts +0 -42
- package/dist/packages/common/src/jobPhaseLog.js +0 -207
- package/dist/packages/job-runtime/src/api/eventsource.d.ts +0 -6
- package/dist/packages/job-runtime/src/api/middlewares/verifyJobOwnerSignature.d.ts +0 -13
- package/dist/packages/job-runtime/src/api/middlewares/verifyJobOwnerSignature.js +0 -39
- package/dist/packages/job-runtime/src/api/middlewares/verifyWSSignatures.d.ts +0 -10
- package/dist/packages/job-runtime/src/api/middlewares/verifyWSSignatures.js +0 -34
- package/dist/packages/job-runtime/src/api/paths.d.ts +0 -52
- package/dist/packages/job-runtime/src/api/paths.js +0 -52
- package/dist/packages/job-runtime/src/api/router.d.ts +0 -10
- package/dist/packages/job-runtime/src/api/router.js +0 -64
- package/dist/packages/job-runtime/src/api/routes/definitionAndResults.d.ts +0 -8
- package/dist/packages/job-runtime/src/api/routes/definitionAndResults.js +0 -69
- package/dist/packages/job-runtime/src/api/routes/info.d.ts +0 -23
- package/dist/packages/job-runtime/src/api/routes/info.js +0 -69
- package/dist/packages/job-runtime/src/api/routes/operations.d.ts +0 -36
- package/dist/packages/job-runtime/src/api/routes/operations.js +0 -120
- package/dist/packages/job-runtime/src/api/routes/ssh.d.ts +0 -11
- package/dist/packages/job-runtime/src/api/routes/ssh.js +0 -83
- package/dist/packages/job-runtime/src/api/routes/stats.d.ts +0 -4
- package/dist/packages/job-runtime/src/api/runtime/terminal.d.ts +0 -15
- package/dist/packages/job-runtime/src/api/types.d.ts +0 -170
- package/dist/packages/job-runtime/src/api/wsClose.d.ts +0 -6
- package/dist/packages/job-runtime/src/api/wsClose.js +0 -10
- package/dist/packages/job-runtime/src/api/wsHandler.d.ts +0 -10
- package/dist/packages/job-runtime/src/api/wsHandler.js +0 -145
- package/dist/packages/job-runtime/src/chain.d.ts +0 -28
- package/dist/packages/job-runtime/src/chain.js +0 -72
- package/dist/packages/job-runtime/src/config.d.ts +0 -39
- package/dist/packages/job-runtime/src/config.js +0 -57
- package/dist/packages/job-runtime/src/host/HostClient.d.ts +0 -29
- package/dist/packages/job-runtime/src/host/HostClient.js +0 -91
- package/dist/packages/job-runtime/src/host/contract.d.ts +0 -171
- package/dist/packages/job-runtime/src/host/contract.js +0 -163
- package/dist/packages/job-runtime/src/host/hostPorts.d.ts +0 -7
- package/dist/packages/job-runtime/src/host/hostPorts.js +0 -13
- package/dist/packages/job-runtime/src/host/index.d.ts +0 -10
- package/dist/packages/job-runtime/src/host/index.js +0 -10
- package/dist/packages/job-runtime/src/logistics/JobDefinitionStrategy.d.ts +0 -21
- package/dist/packages/job-runtime/src/logistics/JobDefinitionStrategy.js +0 -27
- package/dist/packages/job-runtime/src/logistics/ResultReturnStrategy.d.ts +0 -21
- package/dist/packages/job-runtime/src/logistics/ResultReturnStrategy.js +0 -27
- package/dist/packages/job-runtime/src/logistics/definition/ApiJobDefinitionStrategy.d.ts +0 -11
- package/dist/packages/job-runtime/src/logistics/ports.d.ts +0 -10
- package/dist/packages/job-runtime/src/logistics/ports.js +0 -1
- package/dist/packages/job-runtime/src/logistics/result/ApiResultReturnStrategy.d.ts +0 -11
- package/dist/packages/job-runtime/src/main.d.ts +0 -1
- package/dist/packages/job-runtime/src/main.js +0 -83
- package/dist/packages/job-runtime/src/provider/ContainerProvider.d.ts +0 -82
- package/dist/packages/job-runtime/src/provider/ContainerProvider.js +0 -449
- package/dist/packages/job-runtime/src/provider/expose.d.ts +0 -12
- package/dist/packages/job-runtime/src/provider/gpu/gpuSampler.d.ts +0 -24
- package/dist/packages/job-runtime/src/provider/gpu/gpuSampler.js +0 -97
- package/dist/packages/job-runtime/src/provider/gpu/gpuStats.d.ts +0 -63
- package/dist/packages/job-runtime/src/provider/gpu/gpuStats.js +0 -144
- package/dist/packages/job-runtime/src/provider/ports.d.ts +0 -59
- package/dist/packages/job-runtime/src/provider/ports.js +0 -1
- package/dist/packages/job-runtime/src/resources/FileResourceRecords.d.ts +0 -21
- package/dist/packages/job-runtime/src/resources/FileResourceRecords.js +0 -53
- package/dist/packages/job-runtime/src/resources/ImageCache.d.ts +0 -35
- package/dist/packages/job-runtime/src/resources/ImageCache.js +0 -55
- package/dist/packages/job-runtime/src/resources/VolumeCache.d.ts +0 -110
- package/dist/packages/job-runtime/src/resources/VolumeCache.js +0 -359
- package/dist/packages/job-runtime/src/resources/index.d.ts +0 -13
- package/dist/packages/job-runtime/src/resources/index.js +0 -13
- package/dist/packages/job-runtime/src/resources/jobResources.d.ts +0 -12
- package/dist/packages/job-runtime/src/resources/jobResources.js +0 -88
- package/dist/packages/job-runtime/src/resources/multiProgressBarReporter.js +0 -12
- package/dist/packages/job-runtime/src/resources/progressBarReporter.js +0 -12
- package/dist/packages/job-runtime/src/resources/records.d.ts +0 -67
- package/dist/packages/job-runtime/src/resources/records.js +0 -6
- package/dist/packages/job-runtime/src/runtime/RuntimeLog.d.ts +0 -26
- package/dist/packages/job-runtime/src/runtime/RuntimeLog.js +0 -79
- package/dist/packages/job-runtime/src/runtime/retrieveJobDefinition.d.ts +0 -6
- package/dist/packages/job-runtime/src/runtime/retrieveJobDefinition.js +0 -19
- package/dist/packages/job-runtime/src/runtime/runJob.d.ts +0 -31
- package/dist/packages/job-runtime/src/runtime/runJob.js +0 -534
- package/dist/packages/job-runtime/src/runtime/streams.d.ts +0 -32
- package/dist/packages/job-runtime/src/runtime/streams.js +0 -81
- package/dist/packages/job-runtime/src/server.d.ts +0 -23
- package/dist/packages/job-runtime/src/server.js +0 -66
- package/dist/packages/job-runtime/src/store/FlowStore.d.ts +0 -62
- package/dist/packages/job-runtime/src/store/FlowStore.js +0 -170
- package/dist/packages/job-runtime/src/taskManager/index.d.ts +0 -11
- package/dist/packages/job-runtime/src/taskManager/index.js +0 -8
- package/dist/packages/job-runtime/src/taskManager/ports/FlowRepository.d.ts +0 -22
- package/dist/packages/job-runtime/src/taskManager/ports/FlowRepository.js +0 -1
- package/dist/packages/job-runtime/src/taskManager/ports/OrchestrationProvider.d.ts +0 -24
- package/dist/packages/job-runtime/src/taskManager/ports/OrchestrationProvider.js +0 -1
- package/dist/packages/job-runtime/src/taskManager/ports/TaskContext.d.ts +0 -9
- package/dist/packages/job-runtime/src/taskManager/ports/TaskContext.js +0 -1
- package/dist/packages/job-runtime/src/taskManager/ports/index.d.ts +0 -3
- package/dist/packages/job-runtime/src/taskManager/ports/index.js +0 -1
- package/dist/packages/job-runtime/src/taskManager/runtimeConfig.d.ts +0 -23
- package/dist/packages/job-runtime/src/taskManager/runtimeConfig.js +0 -14
- package/dist/packages/job-runtime/src/taskManager/stopReasons.d.ts +0 -10
- package/dist/packages/job-runtime/src/taskManager/stopReasons.js +0 -9
- package/dist/packages/job-runtime/src/taskManager/types.d.ts +0 -53
- package/dist/packages/job-runtime/src/taskManager/types.js +0 -3
- package/dist/packages/job-runtime/src/utils/abort.d.ts +0 -17
- package/dist/packages/job-runtime/src/utils/abort.js +0 -55
- package/dist/packages/job-runtime/src/utils/files.d.ts +0 -7
- package/dist/packages/job-runtime/src/utils/files.js +0 -19
- package/dist/src/NodeManager/node/api/jobRuntimeProxy.d.ts +0 -29
- package/dist/src/NodeManager/node/api/jobRuntimeProxy.js +0 -105
- package/dist/src/NodeManager/node/job/JobRuntimeHost.d.ts +0 -26
- package/dist/src/NodeManager/node/job/JobRuntimeHost.js +0 -87
- package/dist/src/NodeManager/node/job/JobRuntimeSession.d.ts +0 -91
- package/dist/src/NodeManager/node/job/JobRuntimeSession.js +0 -213
- package/dist/src/NodeManager/node/utils/subscription.d.ts +0 -8
- package/dist/src/NodeManager/node/utils/subscription.js +0 -37
- package/dist/src/cli/commands/run/jobRuntimeConsole.d.ts +0 -10
- package/dist/src/cli/commands/run/jobRuntimeConsole.js +0 -26
- /package/dist/{packages/job-runtime/src/api/eventsource.js → src/NodeManager/node/api/eventsource/index.js} +0 -0
- /package/dist/{packages/job-runtime/src/logistics/definition → src/NodeManager/node/job/defination/strategy}/ApiListenJobDefinitionStrategy.js +0 -0
- /package/dist/{packages/job-runtime/src/logistics/result → src/NodeManager/node/job/result/startegy}/ApiListenResultReturnStrategy.js +0 -0
- /package/dist/{packages/job-runtime/src/resources/helpers/nosanaBucket.d.ts → src/NodeManager/node/resource/definition/index.d.ts} +0 -0
- /package/dist/{packages/job-runtime/src/resources/helpers/nosanaBucket.js → src/NodeManager/node/resource/definition/index.js} +0 -0
- /package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createHFArgs.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createHFArgs.js +0 -0
- /package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createOllamaArgs.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createOllamaArgs.js +0 -0
- /package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/isAuthGatedResource.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/TaskManagerRegistry.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/TaskManagerRegistry.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/createDependencyMap.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/createDependencyMap.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/createExecutionPlan.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/createOperationMap.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/validateExecutionPlan.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/validateExecutionPlan.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/finalizeEnv.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/getByPath.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/getByPath.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/index.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/index.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/interpolate.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/interpolate.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/interpolateOperation.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/resolveLiteralsInString.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/resolveLiteralsInString.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setContainerIp.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setContainerIp.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setHost.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setHost.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setResult.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setResult.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setResults.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setResults.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/stanatizeArrays.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/transformCollections.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/helpers/createDefaultOpState.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/helpers/createInitialFlow.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/loggers/StatsBuffer.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/loggers/logManager.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/loggers/logManager.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/loggers/statsManager.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/loggers/statsManager.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/enforceOperationTimeout.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/getOperationsInfos.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/getOperationsInfos.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/restartTaskManagerGroupOperation.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/restartTaskManagerGroupOperation.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/restartTaskManagerOperation.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/restartTaskManagerOperation.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/stopAllTaskManagerOperations.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/stopAllTaskManagerOperations.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/stopTaskManagerGroupOperation.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/stopTaskManagerGroupOperation.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/stopTaskManagerOperation.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/stopTaskManagerOperation.js +0 -0
- /package/dist/{packages/job-runtime/src/resources/helpers → src/NodeManager/node/utils}/convertFromBytes.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/resources/helpers → src/NodeManager/node/utils}/convertFromBytes.js +0 -0
- /package/dist/{packages/common/src → src/NodeManager/node/utils}/extractResultsFromLogs.js +0 -0
- /package/dist/{packages/job-runtime/src → src/NodeManager}/provider/ExposedPortHealthCheck.js +0 -0
- /package/dist/{packages/job-runtime/src → src/NodeManager}/provider/SshAccessManager.js +0 -0
- /package/dist/{packages/job-runtime/src/api → src/NodeManager/provider}/types.js +0 -0
- /package/dist/{packages/container-orchestrator/src → src/NodeManager/provider}/utils/parseBuffer.js +0 -0
- /package/dist/{packages/job-runtime/src/provider → src/NodeManager/provider/utils}/parseDockerStat.js +0 -0
- /package/dist/{packages/common/src → src/NodeManager/utils}/formatTime.d.ts +0 -0
- /package/dist/{packages/common/src → src/NodeManager/utils}/formatTime.js +0 -0
- /package/dist/{packages/job-runtime/src/provider → src/NodeManager/utils}/timeoutPromiseWrapper.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/provider → src/NodeManager/utils}/timeoutPromiseWrapper.js +0 -0
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** The error an abort ends a wait with: the signal's reason, as an Error. */
|
|
2
|
-
export declare function abortError(signal: AbortSignal): Error;
|
|
3
|
-
/** Waits `ms`, or until `signal` aborts, which rejects. */
|
|
4
|
-
export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
5
|
-
/** Rejects once `signal` aborts, whatever `promise` is still waiting on. */
|
|
6
|
-
export declare function abortable<T>(promise: Promise<T>, signal: AbortSignal): Promise<T>;
|
|
7
|
-
/**
|
|
8
|
-
* Tries `attempt` up to `attempts` times, `delayMs` apart. A failure
|
|
9
|
-
* `isFinal` says no retry fixes, the last failure, and an abort are thrown.
|
|
10
|
-
*/
|
|
11
|
-
export declare function retry<T>(attempt: () => Promise<T>, options: {
|
|
12
|
-
attempts: number;
|
|
13
|
-
delayMs: number;
|
|
14
|
-
signal?: AbortSignal;
|
|
15
|
-
isFinal?: (error: unknown) => boolean;
|
|
16
|
-
onFailure?: (error: unknown, tries: number) => void;
|
|
17
|
-
}): Promise<T>;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/** The error an abort ends a wait with: the signal's reason, as an Error. */
|
|
2
|
-
export function abortError(signal) {
|
|
3
|
-
return signal.reason instanceof Error
|
|
4
|
-
? signal.reason
|
|
5
|
-
: new Error(`aborted: ${String(signal.reason ?? 'stopped')}`);
|
|
6
|
-
}
|
|
7
|
-
/** Waits `ms`, or until `signal` aborts, which rejects. */
|
|
8
|
-
export function sleep(ms, signal) {
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
if (signal?.aborted)
|
|
11
|
-
return reject(abortError(signal));
|
|
12
|
-
const timer = setTimeout(done, ms);
|
|
13
|
-
function done() {
|
|
14
|
-
signal?.removeEventListener('abort', onAbort);
|
|
15
|
-
resolve();
|
|
16
|
-
}
|
|
17
|
-
function onAbort() {
|
|
18
|
-
clearTimeout(timer);
|
|
19
|
-
reject(abortError(signal));
|
|
20
|
-
}
|
|
21
|
-
signal?.addEventListener('abort', onAbort, { once: true });
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
/** Rejects once `signal` aborts, whatever `promise` is still waiting on. */
|
|
25
|
-
export function abortable(promise, signal) {
|
|
26
|
-
if (signal.aborted)
|
|
27
|
-
return Promise.reject(abortError(signal));
|
|
28
|
-
return new Promise((resolve, reject) => {
|
|
29
|
-
const onAbort = () => reject(abortError(signal));
|
|
30
|
-
signal.addEventListener('abort', onAbort, { once: true });
|
|
31
|
-
promise
|
|
32
|
-
.then(resolve, reject)
|
|
33
|
-
.finally(() => signal.removeEventListener('abort', onAbort));
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Tries `attempt` up to `attempts` times, `delayMs` apart. A failure
|
|
38
|
-
* `isFinal` says no retry fixes, the last failure, and an abort are thrown.
|
|
39
|
-
*/
|
|
40
|
-
export async function retry(attempt, options) {
|
|
41
|
-
const { attempts, delayMs, signal, isFinal, onFailure } = options;
|
|
42
|
-
for (let tries = 1;; tries++) {
|
|
43
|
-
if (signal?.aborted)
|
|
44
|
-
throw abortError(signal);
|
|
45
|
-
try {
|
|
46
|
-
return await attempt();
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
if (isFinal?.(error) || signal?.aborted || tries >= attempts)
|
|
50
|
-
throw error;
|
|
51
|
-
onFailure?.(error, tries);
|
|
52
|
-
await sleep(delayMs, signal);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Writes `data` as JSON in one step: to a file beside it, then renamed over
|
|
3
|
-
* it, so a reader never sees half of it, whoever dies mid-write.
|
|
4
|
-
*/
|
|
5
|
-
export declare function writeJsonAtomic(file: string, data: unknown): void;
|
|
6
|
-
/** The JSON in `file`; undefined when it is not there or not JSON. */
|
|
7
|
-
export declare function readJson<T>(file: string): T | undefined;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
/**
|
|
3
|
-
* Writes `data` as JSON in one step: to a file beside it, then renamed over
|
|
4
|
-
* it, so a reader never sees half of it, whoever dies mid-write.
|
|
5
|
-
*/
|
|
6
|
-
export function writeJsonAtomic(file, data) {
|
|
7
|
-
const partial = `${file}.${process.pid}.partial`;
|
|
8
|
-
fs.writeFileSync(partial, JSON.stringify(data));
|
|
9
|
-
fs.renameSync(partial, file);
|
|
10
|
-
}
|
|
11
|
-
/** The JSON in `file`; undefined when it is not there or not JSON. */
|
|
12
|
-
export function readJson(file) {
|
|
13
|
-
try {
|
|
14
|
-
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import WebSocket from 'ws';
|
|
2
|
-
import type { NextFunction, Request, Response } from 'express';
|
|
3
|
-
/**
|
|
4
|
-
* A running job's API is served by its runtime sidecar, at
|
|
5
|
-
* `https://<job>.<frp server>`. The node's own `/job/<job>/...` routes and WS
|
|
6
|
-
* paths forward to it, so clients of the node's job API keep working, and say
|
|
7
|
-
* where the job's API lives now.
|
|
8
|
-
*/
|
|
9
|
-
/** Where the job's runtime serves its job API; undefined when it has none. */
|
|
10
|
-
export type JobRuntimeLocator = (jobId: string) => Promise<string | undefined>;
|
|
11
|
-
/**
|
|
12
|
-
* Forwards `/job/<job>/...` to the job's runtime while it has one, request
|
|
13
|
-
* and answer streamed as they are (an SSE answer stays open). Mounted before
|
|
14
|
-
* the node's body parsing and auth: the runtime checks the job owner's
|
|
15
|
-
* signature itself. A job without a runtime falls through to the node's
|
|
16
|
-
* own routes.
|
|
17
|
-
*/
|
|
18
|
-
export declare function jobRuntimeHttpProxy(locate: JobRuntimeLocator): (req: Request<{
|
|
19
|
-
jobId: string;
|
|
20
|
-
}>, res: Response, next: NextFunction) => Promise<void>;
|
|
21
|
-
/** The WS paths a job's runtime serves for the node: `/status` stays the
|
|
22
|
-
* node's, which streams the node's own progress through the job. */
|
|
23
|
-
export declare const JOB_RUNTIME_WS_PATHS: Set<string>;
|
|
24
|
-
/**
|
|
25
|
-
* Hands a WS connection over to the job's runtime: the frames it sent before
|
|
26
|
-
* this was decided (the subscribe frame first) and everything after go to the
|
|
27
|
-
* runtime, and its answers come back. Either side closing closes the other.
|
|
28
|
-
*/
|
|
29
|
-
export declare function pipeToJobRuntime(client: WebSocket, target: string, jobId: string, earlyFrames: WebSocket.Data[]): void;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import http from 'http';
|
|
2
|
-
import WebSocket from 'ws';
|
|
3
|
-
import { configs } from '../../configs/configs.js';
|
|
4
|
-
/**
|
|
5
|
-
* When the node's job API began forwarding to job runtimes (RFC 9745's
|
|
6
|
-
* `Deprecation`, seconds since the epoch).
|
|
7
|
-
*/
|
|
8
|
-
const NODE_JOB_API_DEPRECATED_AT = Date.UTC(2026, 9, 20) / 1000;
|
|
9
|
-
/** Hop-by-hop headers (RFC 9110 §7.6.1), which a proxy does not forward. */
|
|
10
|
-
const HOP_BY_HOP = new Set([
|
|
11
|
-
'connection',
|
|
12
|
-
'keep-alive',
|
|
13
|
-
'proxy-authenticate',
|
|
14
|
-
'proxy-authorization',
|
|
15
|
-
'te',
|
|
16
|
-
'trailer',
|
|
17
|
-
'transfer-encoding',
|
|
18
|
-
'upgrade',
|
|
19
|
-
'host',
|
|
20
|
-
]);
|
|
21
|
-
function forwardable(headers) {
|
|
22
|
-
return Object.fromEntries(Object.entries(headers).filter(([name]) => !HOP_BY_HOP.has(name.toLowerCase())));
|
|
23
|
-
}
|
|
24
|
-
/** The job's own API, where this request belongs from now on. */
|
|
25
|
-
function successor(jobId, path) {
|
|
26
|
-
return `https://${jobId}.${configs().frp.serverAddr}${path}`;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Forwards `/job/<job>/...` to the job's runtime while it has one, request
|
|
30
|
-
* and answer streamed as they are (an SSE answer stays open). Mounted before
|
|
31
|
-
* the node's body parsing and auth: the runtime checks the job owner's
|
|
32
|
-
* signature itself. A job without a runtime falls through to the node's
|
|
33
|
-
* own routes.
|
|
34
|
-
*/
|
|
35
|
-
export function jobRuntimeHttpProxy(locate) {
|
|
36
|
-
return async (req, res, next) => {
|
|
37
|
-
const { jobId } = req.params;
|
|
38
|
-
const target = await locate(jobId).catch(() => undefined);
|
|
39
|
-
if (!target)
|
|
40
|
-
return next();
|
|
41
|
-
const path = req.originalUrl;
|
|
42
|
-
const upstream = http.request(`${target}${path}`, {
|
|
43
|
-
method: req.method,
|
|
44
|
-
headers: forwardable(req.headers),
|
|
45
|
-
});
|
|
46
|
-
upstream.on('response', (answer) => {
|
|
47
|
-
res.writeHead(answer.statusCode ?? 502, {
|
|
48
|
-
...forwardable(answer.headers),
|
|
49
|
-
Deprecation: `@${NODE_JOB_API_DEPRECATED_AT}`,
|
|
50
|
-
Link: `<${successor(jobId, path)}>; rel="successor-version"`,
|
|
51
|
-
});
|
|
52
|
-
answer.pipe(res);
|
|
53
|
-
});
|
|
54
|
-
upstream.on('error', () => {
|
|
55
|
-
if (res.headersSent) {
|
|
56
|
-
res.destroy();
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
res.status(503).send('The job runtime is not reachable');
|
|
60
|
-
});
|
|
61
|
-
// A client that leaves (an SSE reader closing) ends the upstream request.
|
|
62
|
-
res.on('close', () => upstream.destroy());
|
|
63
|
-
req.pipe(upstream);
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
/** The WS paths a job's runtime serves for the node: `/status` stays the
|
|
67
|
-
* node's, which streams the node's own progress through the job. */
|
|
68
|
-
export const JOB_RUNTIME_WS_PATHS = new Set(['/log', '/flog', '/terminal']);
|
|
69
|
-
/**
|
|
70
|
-
* Hands a WS connection over to the job's runtime: the frames it sent before
|
|
71
|
-
* this was decided (the subscribe frame first) and everything after go to the
|
|
72
|
-
* runtime, and its answers come back. Either side closing closes the other.
|
|
73
|
-
*/
|
|
74
|
-
export function pipeToJobRuntime(client, target, jobId, earlyFrames) {
|
|
75
|
-
const upstream = new WebSocket(`${target.replace(/^http/, 'ws')}/job/${jobId}`);
|
|
76
|
-
// A text frame arrives as a string and a binary one as a Buffer, and each
|
|
77
|
-
// is sent on as the same kind of frame.
|
|
78
|
-
const pending = [...earlyFrames];
|
|
79
|
-
client.on('message', (data) => {
|
|
80
|
-
if (upstream.readyState === WebSocket.OPEN)
|
|
81
|
-
upstream.send(data);
|
|
82
|
-
else
|
|
83
|
-
pending.push(data);
|
|
84
|
-
});
|
|
85
|
-
upstream.on('open', () => {
|
|
86
|
-
for (const data of pending.splice(0))
|
|
87
|
-
upstream.send(data);
|
|
88
|
-
});
|
|
89
|
-
upstream.on('message', (data) => {
|
|
90
|
-
if (client.readyState === WebSocket.OPEN)
|
|
91
|
-
client.send(data);
|
|
92
|
-
});
|
|
93
|
-
upstream.on('close', (code, reason) => {
|
|
94
|
-
if (client.readyState === WebSocket.OPEN) {
|
|
95
|
-
// 1005/1006 are reported, never sent.
|
|
96
|
-
client.close(code === 1005 || code === 1006 ? 1011 : code, reason);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
upstream.on('error', () => {
|
|
100
|
-
if (client.readyState === WebSocket.OPEN) {
|
|
101
|
-
client.close(1011, 'The job runtime is not reachable');
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
client.on('close', () => upstream.close());
|
|
105
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type StopReason } from '../../../../packages/job-runtime/src/host/index.js';
|
|
2
|
-
export interface JobRuntimeHostOptions {
|
|
3
|
-
/** The socket the server listens on, in the directory the sidecar binds. */
|
|
4
|
-
socketPath: string;
|
|
5
|
-
/** The one job this socket is for. */
|
|
6
|
-
jobAddress: string;
|
|
7
|
-
/** Signs an authorization header for the job address with the node wallet. */
|
|
8
|
-
sign: (jobAddress: string) => Promise<string>;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* The node's side of a job's runtime socket (see @nosana/job-runtime/host):
|
|
12
|
-
* what the job's sidecar needs of the node live, for the one job it was made
|
|
13
|
-
* for: the node's signature, and the job's stop.
|
|
14
|
-
*/
|
|
15
|
-
export declare class JobRuntimeHost {
|
|
16
|
-
private readonly options;
|
|
17
|
-
private readonly server;
|
|
18
|
-
private stopRequest;
|
|
19
|
-
private readonly stopWaiters;
|
|
20
|
-
constructor(options: JobRuntimeHostOptions);
|
|
21
|
-
listen(): Promise<void>;
|
|
22
|
-
/** Answers the sidecar's `/stop`, now and on every later poll. */
|
|
23
|
-
stop(reason: StopReason): void;
|
|
24
|
-
close(): Promise<void>;
|
|
25
|
-
private routes;
|
|
26
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import http from 'http';
|
|
2
|
-
import fs from 'fs/promises';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import express from 'express';
|
|
5
|
-
import { describeError } from '../../../../packages/common/src/index.js';
|
|
6
|
-
import { JOB_RUNTIME_HOST_PATHS as PATHS, } from '../../../../packages/job-runtime/src/host/index.js';
|
|
7
|
-
/** The longest unix socket path every platform takes (macOS: 104 with the NUL). */
|
|
8
|
-
const MAX_SOCKET_PATH_BYTES = 103;
|
|
9
|
-
/** A handler whose rejection goes to the error handler. */
|
|
10
|
-
function handle(fn) {
|
|
11
|
-
return (req, res, next) => {
|
|
12
|
-
Promise.resolve(fn(req, res)).catch(next);
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* The node's side of a job's runtime socket (see @nosana/job-runtime/host):
|
|
17
|
-
* what the job's sidecar needs of the node live, for the one job it was made
|
|
18
|
-
* for: the node's signature, and the job's stop.
|
|
19
|
-
*/
|
|
20
|
-
export class JobRuntimeHost {
|
|
21
|
-
constructor(options) {
|
|
22
|
-
this.options = options;
|
|
23
|
-
this.stopWaiters = new Set();
|
|
24
|
-
this.server = http.createServer(this.routes());
|
|
25
|
-
// `/stop` is held open until the job is stopped.
|
|
26
|
-
this.server.requestTimeout = 0;
|
|
27
|
-
this.server.timeout = 0;
|
|
28
|
-
}
|
|
29
|
-
async listen() {
|
|
30
|
-
const { socketPath } = this.options;
|
|
31
|
-
const length = Buffer.byteLength(socketPath);
|
|
32
|
-
if (length > MAX_SOCKET_PATH_BYTES) {
|
|
33
|
-
throw new Error(`The job runtime socket path is ${length} bytes, more than the ` +
|
|
34
|
-
`${MAX_SOCKET_PATH_BYTES} a unix socket takes: ${socketPath}. ` +
|
|
35
|
-
'Use a shorter node data directory (--config).');
|
|
36
|
-
}
|
|
37
|
-
await fs.mkdir(path.dirname(socketPath), { recursive: true });
|
|
38
|
-
// A socket left by a node that died would make listen() fail.
|
|
39
|
-
await fs.rm(socketPath, { force: true });
|
|
40
|
-
await new Promise((resolve, reject) => {
|
|
41
|
-
this.server.once('error', reject);
|
|
42
|
-
this.server.listen(socketPath, () => {
|
|
43
|
-
this.server.off('error', reject);
|
|
44
|
-
resolve();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
// The sidecar may run as another user than the node; it is the only
|
|
48
|
-
// thing that sees this directory.
|
|
49
|
-
await fs.chmod(socketPath, 0o666);
|
|
50
|
-
}
|
|
51
|
-
/** Answers the sidecar's `/stop`, now and on every later poll. */
|
|
52
|
-
stop(reason) {
|
|
53
|
-
this.stopRequest ??= { reason };
|
|
54
|
-
for (const res of this.stopWaiters)
|
|
55
|
-
res.json(this.stopRequest);
|
|
56
|
-
this.stopWaiters.clear();
|
|
57
|
-
}
|
|
58
|
-
async close() {
|
|
59
|
-
for (const res of this.stopWaiters)
|
|
60
|
-
res.destroy();
|
|
61
|
-
this.stopWaiters.clear();
|
|
62
|
-
this.server.closeAllConnections();
|
|
63
|
-
await new Promise((resolve) => this.server.close(() => resolve()));
|
|
64
|
-
await fs.rm(this.options.socketPath, { force: true }).catch(() => undefined);
|
|
65
|
-
}
|
|
66
|
-
routes() {
|
|
67
|
-
const { options } = this;
|
|
68
|
-
const app = express();
|
|
69
|
-
// The job address, and nothing the sidecar sent.
|
|
70
|
-
app.get(PATHS.signAuth, handle(async (_req, res) => {
|
|
71
|
-
res.json({ authorization: await options.sign(options.jobAddress) });
|
|
72
|
-
}));
|
|
73
|
-
app.get(PATHS.stop, (_req, res) => {
|
|
74
|
-
if (this.stopRequest)
|
|
75
|
-
return res.json(this.stopRequest);
|
|
76
|
-
this.stopWaiters.add(res);
|
|
77
|
-
res.once('close', () => this.stopWaiters.delete(res));
|
|
78
|
-
});
|
|
79
|
-
app.use((_req, res) => {
|
|
80
|
-
res.status(404).json({ error: 'not found' });
|
|
81
|
-
});
|
|
82
|
-
app.use((error, _req, res, _next) => {
|
|
83
|
-
res.status(400).json({ error: describeError(error) });
|
|
84
|
-
});
|
|
85
|
-
return app;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import type { JobDefinition, NosanaClient } from '@nosana/kit';
|
|
2
|
-
import { type JobRuntimeConsole, type JobRuntimeStatus, type StopReason } from '../../../../packages/job-runtime/src/host/index.js';
|
|
3
|
-
import type { Provider } from '../../provider/Provider.js';
|
|
4
|
-
import type { ResourceManager } from '../resource/resourceManager.js';
|
|
5
|
-
export interface JobRuntimeSessionOptions {
|
|
6
|
-
/** The node's client: it signs what the sidecar asks it to. */
|
|
7
|
-
sdk: NosanaClient;
|
|
8
|
-
provider: Provider;
|
|
9
|
-
/** The node's data directory; the job's directory is made under it. */
|
|
10
|
-
dataDir: string;
|
|
11
|
-
jobAddress: string;
|
|
12
|
-
/**
|
|
13
|
-
* Whose images and resources these are: an onchain job's project, and the
|
|
14
|
-
* node itself for an inline run, which also runs as it.
|
|
15
|
-
*/
|
|
16
|
-
project: string;
|
|
17
|
-
/** An inline run's definition; absent for an onchain job. */
|
|
18
|
-
inline?: JobDefinition;
|
|
19
|
-
/** The sidecar's status as it changes, while it runs. */
|
|
20
|
-
onStatus?: (status: JobRuntimeStatus) => void;
|
|
21
|
-
/** What the sidecar's console carries (see JobRuntimeConsole). */
|
|
22
|
-
console?: JobRuntimeConsole;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* One job's runtime from the node's side: the job's directory (the seed in,
|
|
26
|
-
* the status and the cache changes out), the socket served in it, and the
|
|
27
|
-
* sidecar, which the node starts and then waits for to exit. The onchain job
|
|
28
|
-
* handler, the market benchmark and `nosana node run` all run their job
|
|
29
|
-
* through one.
|
|
30
|
-
*/
|
|
31
|
-
export declare class JobRuntimeSession {
|
|
32
|
-
private readonly options;
|
|
33
|
-
private readonly host;
|
|
34
|
-
private readonly dir;
|
|
35
|
-
private exited;
|
|
36
|
-
private removing;
|
|
37
|
-
private statusPoll;
|
|
38
|
-
constructor(options: JobRuntimeSessionOptions);
|
|
39
|
-
/**
|
|
40
|
-
* The sidecar's latest status, undefined until it wrote one, or when what
|
|
41
|
-
* it wrote is not one the node can read.
|
|
42
|
-
*/
|
|
43
|
-
get status(): JobRuntimeStatus | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* Resolves with the sidecar's last status once it has exited for good:
|
|
46
|
-
* with its result, or with whatever it last wrote when it exited without
|
|
47
|
-
* one too often (or was removed).
|
|
48
|
-
*/
|
|
49
|
-
get done(): Promise<JobRuntimeStatus | undefined>;
|
|
50
|
-
/**
|
|
51
|
-
* Writes the job's seed, serves the socket and starts the sidecar. On
|
|
52
|
-
* failure whatever was made is removed again and the error thrown.
|
|
53
|
-
*/
|
|
54
|
-
start(): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Takes over a sidecar that outlived the node's last process, running or
|
|
57
|
-
* exited: serves its socket again, the requests it has been retrying
|
|
58
|
-
* included, and waits for it as start() does. Its seed and what it wrote
|
|
59
|
-
* since are where it left them.
|
|
60
|
-
*/
|
|
61
|
-
attach(): Promise<void>;
|
|
62
|
-
/** Asks the sidecar to stop the job; it exits once its result is written. */
|
|
63
|
-
stop(reason: StopReason): void;
|
|
64
|
-
/**
|
|
65
|
-
* Removes the sidecar and whatever is left of the job, the socket and the
|
|
66
|
-
* job's directory, after writing back what the job changed in the cache
|
|
67
|
-
* records, however it ended.
|
|
68
|
-
*/
|
|
69
|
-
remove(): Promise<void>;
|
|
70
|
-
/**
|
|
71
|
-
* Lets go of the job and leaves the rest where it is: the sidecar, its data
|
|
72
|
-
* volume and the job's directory, its result in it. For a job whose result
|
|
73
|
-
* could not be submitted: the next start takes the sidecar over and submits
|
|
74
|
-
* from what it wrote, rather than run the job again.
|
|
75
|
-
*/
|
|
76
|
-
release(): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* Removes the directories of jobs nothing will come back for (left by a
|
|
79
|
-
* job the node let go of, then never took over): all but `liveJob`'s.
|
|
80
|
-
* What each job changed in the cache records is written back first, so the
|
|
81
|
-
* volumes it made are known.
|
|
82
|
-
*/
|
|
83
|
-
static removeLeftovers(dataDir: string, resourceManager: ResourceManager, liveJob?: string): Promise<void>;
|
|
84
|
-
private follow;
|
|
85
|
-
/**
|
|
86
|
-
* Waits for the sidecar to exit with its result. One that exits without
|
|
87
|
-
* it (a crash, the runtime restarting) is started again, and resumes the
|
|
88
|
-
* job from its data volume; one that keeps doing so is given up on.
|
|
89
|
-
*/
|
|
90
|
-
private waitForExit;
|
|
91
|
-
}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { describeError } from '../../../../packages/common/src/index.js';
|
|
4
|
-
import { isKnownVersion, JOB_RUNTIME_FILES, JOB_RUNTIME_HOST_SOCKET, JOB_RUNTIME_SEED_VERSION, RESOURCE_CHANGES_VERSION, readJson, writeJsonAtomic, } from '../../../../packages/job-runtime/src/host/index.js';
|
|
5
|
-
import { JobRuntimeHost } from './JobRuntimeHost.js';
|
|
6
|
-
/**
|
|
7
|
-
* How often a sidecar that exits before its result is started again before
|
|
8
|
-
* the job is finished on what it last wrote, and how long apart.
|
|
9
|
-
*/
|
|
10
|
-
const MAX_RUNTIME_RESTARTS = 5;
|
|
11
|
-
const RUNTIME_RESTART_DELAY_MS = 5_000;
|
|
12
|
-
/** How often an `onStatus` listener is handed the sidecar's status. */
|
|
13
|
-
const STATUS_POLL_MS = 1_000;
|
|
14
|
-
/**
|
|
15
|
-
* One job's runtime from the node's side: the job's directory (the seed in,
|
|
16
|
-
* the status and the cache changes out), the socket served in it, and the
|
|
17
|
-
* sidecar, which the node starts and then waits for to exit. The onchain job
|
|
18
|
-
* handler, the market benchmark and `nosana node run` all run their job
|
|
19
|
-
* through one.
|
|
20
|
-
*/
|
|
21
|
-
export class JobRuntimeSession {
|
|
22
|
-
constructor(options) {
|
|
23
|
-
this.options = options;
|
|
24
|
-
this.removing = false;
|
|
25
|
-
this.dir = path.join(options.dataDir, 'jobs', options.jobAddress);
|
|
26
|
-
this.host = new JobRuntimeHost({
|
|
27
|
-
socketPath: path.join(this.dir, JOB_RUNTIME_HOST_SOCKET),
|
|
28
|
-
jobAddress: options.jobAddress,
|
|
29
|
-
sign: async (address) => {
|
|
30
|
-
const headers = await options.sdk.authorization.generateHeaders(address, {
|
|
31
|
-
includeTime: true,
|
|
32
|
-
});
|
|
33
|
-
return headers.get('Authorization') ?? '';
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* The sidecar's latest status, undefined until it wrote one, or when what
|
|
39
|
-
* it wrote is not one the node can read.
|
|
40
|
-
*/
|
|
41
|
-
get status() {
|
|
42
|
-
const status = readJson(path.join(this.dir, JOB_RUNTIME_FILES.status));
|
|
43
|
-
return isReadableStatus(status) ? status : undefined;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Resolves with the sidecar's last status once it has exited for good:
|
|
47
|
-
* with its result, or with whatever it last wrote when it exited without
|
|
48
|
-
* one too often (or was removed).
|
|
49
|
-
*/
|
|
50
|
-
get done() {
|
|
51
|
-
return this.exited ?? Promise.resolve(this.status);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Writes the job's seed, serves the socket and starts the sidecar. On
|
|
55
|
-
* failure whatever was made is removed again and the error thrown.
|
|
56
|
-
*/
|
|
57
|
-
async start() {
|
|
58
|
-
try {
|
|
59
|
-
await fs.mkdir(this.dir, { recursive: true });
|
|
60
|
-
// The sidecar writes here, as root with no capabilities: it cannot
|
|
61
|
-
// override a directory's permissions, and it is the only thing that
|
|
62
|
-
// sees this one.
|
|
63
|
-
await fs.chmod(this.dir, 0o777);
|
|
64
|
-
const { provider, inline, project } = this.options;
|
|
65
|
-
const seed = {
|
|
66
|
-
version: JOB_RUNTIME_SEED_VERSION,
|
|
67
|
-
resources: provider.resourceManager.jobCacheSnapshot(),
|
|
68
|
-
...(inline ? { inline: { definition: inline, project, host: project } } : {}),
|
|
69
|
-
};
|
|
70
|
-
writeJsonAtomic(path.join(this.dir, JOB_RUNTIME_FILES.seed), seed);
|
|
71
|
-
await this.host.listen();
|
|
72
|
-
await provider.startJobRuntime(this.options.jobAddress, this.dir, inline ? 'inline' : 'onchain', this.options.console);
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
await this.remove();
|
|
76
|
-
throw error;
|
|
77
|
-
}
|
|
78
|
-
this.follow();
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Takes over a sidecar that outlived the node's last process, running or
|
|
82
|
-
* exited: serves its socket again, the requests it has been retrying
|
|
83
|
-
* included, and waits for it as start() does. Its seed and what it wrote
|
|
84
|
-
* since are where it left them.
|
|
85
|
-
*/
|
|
86
|
-
async attach() {
|
|
87
|
-
await this.host.listen();
|
|
88
|
-
this.follow();
|
|
89
|
-
}
|
|
90
|
-
/** Asks the sidecar to stop the job; it exits once its result is written. */
|
|
91
|
-
stop(reason) {
|
|
92
|
-
this.host.stop(reason);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Removes the sidecar and whatever is left of the job, the socket and the
|
|
96
|
-
* job's directory, after writing back what the job changed in the cache
|
|
97
|
-
* records, however it ended.
|
|
98
|
-
*/
|
|
99
|
-
async remove() {
|
|
100
|
-
this.removing = true;
|
|
101
|
-
clearInterval(this.statusPoll);
|
|
102
|
-
writeBackCacheChanges(this.dir, this.options.provider.resourceManager, this.options.jobAddress);
|
|
103
|
-
try {
|
|
104
|
-
await this.options.provider.stopJobRuntime(this.options.jobAddress);
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
console.error(`Failed to remove the runtime of job ${this.options.jobAddress}: ${describeError(error)}`);
|
|
108
|
-
}
|
|
109
|
-
await this.host.close().catch(() => undefined);
|
|
110
|
-
await fs.rm(this.dir, { recursive: true, force: true }).catch(() => undefined);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Lets go of the job and leaves the rest where it is: the sidecar, its data
|
|
114
|
-
* volume and the job's directory, its result in it. For a job whose result
|
|
115
|
-
* could not be submitted: the next start takes the sidecar over and submits
|
|
116
|
-
* from what it wrote, rather than run the job again.
|
|
117
|
-
*/
|
|
118
|
-
async release() {
|
|
119
|
-
this.removing = true;
|
|
120
|
-
clearInterval(this.statusPoll);
|
|
121
|
-
await this.host.close().catch(() => undefined);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Removes the directories of jobs nothing will come back for (left by a
|
|
125
|
-
* job the node let go of, then never took over): all but `liveJob`'s.
|
|
126
|
-
* What each job changed in the cache records is written back first, so the
|
|
127
|
-
* volumes it made are known.
|
|
128
|
-
*/
|
|
129
|
-
static async removeLeftovers(dataDir, resourceManager, liveJob) {
|
|
130
|
-
const jobs = path.join(dataDir, 'jobs');
|
|
131
|
-
const entries = await fs.readdir(jobs).catch(() => []);
|
|
132
|
-
for (const job of entries) {
|
|
133
|
-
if (job === liveJob)
|
|
134
|
-
continue;
|
|
135
|
-
const dir = path.join(jobs, job);
|
|
136
|
-
writeBackCacheChanges(dir, resourceManager, job);
|
|
137
|
-
await fs.rm(dir, { recursive: true, force: true }).catch(() => undefined);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
follow() {
|
|
141
|
-
const { onStatus } = this.options;
|
|
142
|
-
if (onStatus) {
|
|
143
|
-
this.statusPoll = setInterval(() => {
|
|
144
|
-
const status = this.status;
|
|
145
|
-
if (status)
|
|
146
|
-
onStatus(status);
|
|
147
|
-
}, STATUS_POLL_MS);
|
|
148
|
-
}
|
|
149
|
-
this.exited = this.waitForExit().finally(() => clearInterval(this.statusPoll));
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Waits for the sidecar to exit with its result. One that exits without
|
|
153
|
-
* it (a crash, the runtime restarting) is started again, and resumes the
|
|
154
|
-
* job from its data volume; one that keeps doing so is given up on.
|
|
155
|
-
*/
|
|
156
|
-
async waitForExit() {
|
|
157
|
-
const { provider, jobAddress } = this.options;
|
|
158
|
-
for (let restarts = 0;; restarts++) {
|
|
159
|
-
const exit = await provider.waitForJobRuntime(jobAddress);
|
|
160
|
-
const status = this.status;
|
|
161
|
-
if (this.removing ||
|
|
162
|
-
!exit ||
|
|
163
|
-
status?.result ||
|
|
164
|
-
exit.exitCode === 0 ||
|
|
165
|
-
restarts >= MAX_RUNTIME_RESTARTS) {
|
|
166
|
-
return status;
|
|
167
|
-
}
|
|
168
|
-
console.error(`The runtime of job ${jobAddress} exited (${exit.exitCode}) before its result; starting it again`);
|
|
169
|
-
await new Promise((resolve) => setTimeout(resolve, RUNTIME_RESTART_DELAY_MS));
|
|
170
|
-
if (this.removing)
|
|
171
|
-
return this.status;
|
|
172
|
-
await provider.restartJobRuntime(jobAddress).catch((error) => console.error(`Failed to start the runtime of job ${jobAddress} again: ${describeError(error)}`));
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Writes what the job in `dir` changed in the cache records back to the
|
|
178
|
-
* node's. Whole or not at all: changes of a version the node does not know
|
|
179
|
-
* are left out of the records rather than half applied.
|
|
180
|
-
*/
|
|
181
|
-
function writeBackCacheChanges(dir, resourceManager, jobAddress) {
|
|
182
|
-
const changes = readJson(path.join(dir, JOB_RUNTIME_FILES.resources));
|
|
183
|
-
if (changes && isKnownVersion(changes.version, RESOURCE_CHANGES_VERSION)) {
|
|
184
|
-
resourceManager.applyJobCacheChanges(changes);
|
|
185
|
-
}
|
|
186
|
-
else if (changes) {
|
|
187
|
-
console.error(`Ignoring the cache changes of job ${jobAddress}: version ` +
|
|
188
|
-
`${String(changes.version)}, this node reads up to ${RESOURCE_CHANGES_VERSION}`);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Whether a status file has what the node reads of it in the shape it reads
|
|
193
|
-
* it: the outcome, the ops (the benchmark's progress) and, once there, the
|
|
194
|
-
* result. A status has no version (see JOB_RUNTIME_SEED_VERSION); one an
|
|
195
|
-
* older sidecar wrote reads the same.
|
|
196
|
-
*/
|
|
197
|
-
function isReadableStatus(value) {
|
|
198
|
-
if (typeof value !== 'object' || value === null)
|
|
199
|
-
return false;
|
|
200
|
-
const status = value;
|
|
201
|
-
if (typeof status.status !== 'string' ||
|
|
202
|
-
!Array.isArray(status.errors) ||
|
|
203
|
-
!Array.isArray(status.opStates)) {
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
if (status.result === undefined)
|
|
207
|
-
return true;
|
|
208
|
-
if (typeof status.result !== 'object' || status.result === null)
|
|
209
|
-
return false;
|
|
210
|
-
const { ipfsHash, error } = status.result;
|
|
211
|
-
return ((ipfsHash === undefined || typeof ipfsHash === 'string') &&
|
|
212
|
-
(error === undefined || typeof error === 'string'));
|
|
213
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hands each notification of an RPC subscription to `onNotification` until
|
|
3
|
-
* `signal` aborts. A websocket that drops ends a @solana/kit subscription
|
|
4
|
-
* with an error, where the old web3.js connection subscribed again by
|
|
5
|
-
* itself: this subscribes again, a moment later, the same way. A
|
|
6
|
-
* notification `onNotification` can't read is passed over.
|
|
7
|
-
*/
|
|
8
|
-
export declare function watch<T>(subscribe: (abortSignal: AbortSignal) => Promise<AsyncIterable<T>>, onNotification: (notification: T) => void, signal: AbortSignal): Promise<void>;
|