@harperfast/harper 5.3.0-alpha.1 → 5.3.0-beta.2
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/bin/cliOperations.ts +12 -0
- package/bin/restart.ts +66 -6
- package/components/Application.ts +1134 -112
- package/components/DESIGN.md +421 -0
- package/components/OptionsWatcher.ts +368 -102
- package/components/Scope.ts +20 -1
- package/components/componentLoader.ts +43 -4
- package/components/deploymentOperations.ts +4 -1
- package/components/deploymentRecorder.ts +9 -2
- package/components/mcp/DESIGN.md +109 -0
- package/components/mcp/audit.ts +21 -17
- package/components/operations.js +284 -52
- package/components/operationsValidation.js +49 -2
- package/components/packageComponent.ts +25 -1
- package/components/requestRestart.ts +11 -0
- package/config/DESIGN.md +306 -0
- package/config/RootConfigWatcher.ts +191 -37
- package/config/configReadRetry.ts +62 -0
- package/config/configUtils.ts +78 -26
- package/config/parseConfigFile.ts +34 -0
- package/config/readConfigFileSync.ts +44 -0
- package/config/watcherArming.ts +59 -0
- package/config-root.schema.json +4 -0
- package/dataLayer/DESIGN.md +179 -0
- package/dataLayer/harperBridge/ResourceBridge.ts +28 -2
- package/dataLayer/restoreMarker.ts +92 -25
- package/dist/bin/cliOperations.js +13 -0
- package/dist/bin/cliOperations.js.map +1 -1
- package/dist/bin/restart.js +42 -6
- package/dist/bin/restart.js.map +1 -1
- package/dist/components/Application.d.ts +104 -9
- package/dist/components/Application.js +954 -102
- package/dist/components/Application.js.map +1 -1
- package/dist/components/OptionsWatcher.d.ts +4 -1
- package/dist/components/OptionsWatcher.js +378 -104
- package/dist/components/OptionsWatcher.js.map +1 -1
- package/dist/components/Scope.js +15 -1
- package/dist/components/Scope.js.map +1 -1
- package/dist/components/componentLoader.js +35 -3
- package/dist/components/componentLoader.js.map +1 -1
- package/dist/components/deploymentOperations.js +4 -1
- package/dist/components/deploymentOperations.js.map +1 -1
- package/dist/components/deploymentRecorder.d.ts +4 -2
- package/dist/components/deploymentRecorder.js +1 -0
- package/dist/components/deploymentRecorder.js.map +1 -1
- package/dist/components/mcp/audit.d.ts +2 -1
- package/dist/components/mcp/audit.js +21 -17
- package/dist/components/mcp/audit.js.map +1 -1
- package/dist/components/operations.d.ts +28 -0
- package/dist/components/operations.js +263 -54
- package/dist/components/operations.js.map +1 -1
- package/dist/components/operationsValidation.js +48 -2
- package/dist/components/operationsValidation.js.map +1 -1
- package/dist/components/packageComponent.js +24 -0
- package/dist/components/packageComponent.js.map +1 -1
- package/dist/components/requestRestart.d.ts +1 -0
- package/dist/components/requestRestart.js +7 -0
- package/dist/components/requestRestart.js.map +1 -1
- package/dist/config/RootConfigWatcher.d.ts +2 -0
- package/dist/config/RootConfigWatcher.js +189 -35
- package/dist/config/RootConfigWatcher.js.map +1 -1
- package/dist/config/configReadRetry.d.ts +8 -0
- package/dist/config/configReadRetry.js +62 -0
- package/dist/config/configReadRetry.js.map +1 -0
- package/dist/config/configUtils.d.ts +10 -9
- package/dist/config/configUtils.js +63 -27
- package/dist/config/configUtils.js.map +1 -1
- package/dist/config/parseConfigFile.d.ts +4 -0
- package/dist/config/parseConfigFile.js +35 -0
- package/dist/config/parseConfigFile.js.map +1 -0
- package/dist/config/readConfigFileSync.d.ts +1 -0
- package/dist/config/readConfigFileSync.js +47 -0
- package/dist/config/readConfigFileSync.js.map +1 -0
- package/dist/config/watcherArming.d.ts +15 -0
- package/dist/config/watcherArming.js +59 -0
- package/dist/config/watcherArming.js.map +1 -0
- package/dist/dataLayer/harperBridge/ResourceBridge.js +21 -2
- package/dist/dataLayer/harperBridge/ResourceBridge.js.map +1 -1
- package/dist/dataLayer/restoreMarker.d.ts +21 -8
- package/dist/dataLayer/restoreMarker.js +94 -27
- package/dist/dataLayer/restoreMarker.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/json/systemSchema.json +3 -0
- package/dist/resources/DatabaseTransaction.d.ts +25 -0
- package/dist/resources/DatabaseTransaction.js +224 -18
- package/dist/resources/DatabaseTransaction.js.map +1 -1
- package/dist/resources/LMDBTransaction.d.ts +2 -1
- package/dist/resources/LMDBTransaction.js +22 -3
- package/dist/resources/LMDBTransaction.js.map +1 -1
- package/dist/resources/PrimaryRocksDatabase.js +22 -6
- package/dist/resources/PrimaryRocksDatabase.js.map +1 -1
- package/dist/resources/RecordEncoder.d.ts +1 -1
- package/dist/resources/RecordEncoder.js +46 -10
- package/dist/resources/RecordEncoder.js.map +1 -1
- package/dist/resources/Resource.js +97 -13
- package/dist/resources/Resource.js.map +1 -1
- package/dist/resources/ResourceInterface.d.ts +8 -0
- package/dist/resources/RocksIndexStore.js +2 -1
- package/dist/resources/RocksIndexStore.js.map +1 -1
- package/dist/resources/RocksTransactionLogStore.d.ts +10 -0
- package/dist/resources/RocksTransactionLogStore.js +104 -33
- package/dist/resources/RocksTransactionLogStore.js.map +1 -1
- package/dist/resources/Table.d.ts +58 -7
- package/dist/resources/Table.js +1143 -348
- package/dist/resources/Table.js.map +1 -1
- package/dist/resources/analytics/write.d.ts +3 -0
- package/dist/resources/analytics/write.js +49 -16
- package/dist/resources/analytics/write.js.map +1 -1
- package/dist/resources/auditStore.d.ts +170 -0
- package/dist/resources/auditStore.js +457 -11
- package/dist/resources/auditStore.js.map +1 -1
- package/dist/resources/crdt.d.ts +10 -0
- package/dist/resources/crdt.js +22 -0
- package/dist/resources/crdt.js.map +1 -1
- package/dist/resources/dataLoader.js +3 -4
- package/dist/resources/dataLoader.js.map +1 -1
- package/dist/resources/databases.d.ts +16 -13
- package/dist/resources/databases.js +625 -177
- package/dist/resources/databases.js.map +1 -1
- package/dist/resources/derivedIndexRegistry.d.ts +5 -0
- package/dist/resources/derivedIndexRegistry.js +68 -0
- package/dist/resources/derivedIndexRegistry.js.map +1 -0
- package/dist/resources/derivedIndexRuntime.d.ts +215 -0
- package/dist/resources/derivedIndexRuntime.js +2027 -0
- package/dist/resources/derivedIndexRuntime.js.map +1 -0
- package/dist/resources/graphql.js +3 -2
- package/dist/resources/graphql.js.map +1 -1
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.d.ts +102 -9
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js +867 -39
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js.map +1 -1
- package/dist/resources/indexes/fullTextDerivedIndex.d.ts +81 -0
- package/dist/resources/indexes/fullTextDerivedIndex.js +1004 -0
- package/dist/resources/indexes/fullTextDerivedIndex.js.map +1 -0
- package/dist/resources/indexes/fullTextNativeBinding.d.ts +78 -0
- package/dist/resources/indexes/fullTextNativeBinding.js +85 -0
- package/dist/resources/indexes/fullTextNativeBinding.js.map +1 -0
- package/dist/resources/indexes/hnswDerivedIndex.d.ts +67 -0
- package/dist/resources/indexes/hnswDerivedIndex.js +464 -0
- package/dist/resources/indexes/hnswDerivedIndex.js.map +1 -0
- package/dist/resources/indexes/hnswPlaneBinding.d.ts +65 -0
- package/dist/resources/indexes/hnswPlaneBinding.js +91 -0
- package/dist/resources/indexes/hnswPlaneBinding.js.map +1 -0
- package/dist/resources/indexes/nativeFullTextDerivedIndexLifecycle.d.ts +24 -0
- package/dist/resources/indexes/nativeFullTextDerivedIndexLifecycle.js +149 -0
- package/dist/resources/indexes/nativeFullTextDerivedIndexLifecycle.js.map +1 -0
- package/dist/resources/nodeIdMapping.d.ts +5 -0
- package/dist/resources/nodeIdMapping.js +49 -0
- package/dist/resources/nodeIdMapping.js.map +1 -1
- package/dist/resources/recordLock.d.ts +47 -4
- package/dist/resources/recordLock.js +138 -7
- package/dist/resources/recordLock.js.map +1 -1
- package/dist/resources/recordLockCoordinator.d.ts +557 -0
- package/dist/resources/recordLockCoordinator.js +2597 -0
- package/dist/resources/recordLockCoordinator.js.map +1 -0
- package/dist/resources/replayLogs.js +5 -0
- package/dist/resources/replayLogs.js.map +1 -1
- package/dist/resources/replicatedApplyFailure.d.ts +16 -0
- package/dist/resources/replicatedApplyFailure.js +63 -0
- package/dist/resources/replicatedApplyFailure.js.map +1 -0
- package/dist/resources/scheduler/scheduler.js +3 -3
- package/dist/resources/scheduler/scheduler.js.map +1 -1
- package/dist/resources/search.d.ts +10 -4
- package/dist/resources/search.js +160 -40
- package/dist/resources/search.js.map +1 -1
- package/dist/resources/tracked.d.ts +5 -1
- package/dist/resources/tracked.js +74 -23
- package/dist/resources/tracked.js.map +1 -1
- package/dist/resources/transactionBroadcast.js +4 -6
- package/dist/resources/transactionBroadcast.js.map +1 -1
- package/dist/security/auth.js +59 -23
- package/dist/security/auth.js.map +1 -1
- package/dist/security/deferredAuthentication.d.ts +11 -0
- package/dist/security/deferredAuthentication.js +25 -3
- package/dist/security/deferredAuthentication.js.map +1 -1
- package/dist/security/jsLoader.js +9 -4
- package/dist/security/jsLoader.js.map +1 -1
- package/dist/server/REST.js +39 -5
- package/dist/server/REST.js.map +1 -1
- package/dist/server/http.d.ts +5 -1
- package/dist/server/http.js +34 -2
- package/dist/server/http.js.map +1 -1
- package/dist/server/mqtt.js +5 -1
- package/dist/server/mqtt.js.map +1 -1
- package/dist/server/serverHelpers/Headers.d.ts +2 -0
- package/dist/server/serverHelpers/Headers.js +6 -0
- package/dist/server/serverHelpers/Headers.js.map +1 -1
- package/dist/server/serverHelpers/NodeAdapterResponse.d.ts +48 -0
- package/dist/server/serverHelpers/NodeAdapterResponse.js +220 -0
- package/dist/server/serverHelpers/NodeAdapterResponse.js.map +1 -0
- package/dist/server/serverHelpers/Request.d.ts +5 -10
- package/dist/server/serverHelpers/Request.js +38 -136
- package/dist/server/serverHelpers/Request.js.map +1 -1
- package/dist/server/serverHelpers/contentTypes.d.ts +2 -0
- package/dist/server/serverHelpers/contentTypes.js +189 -15
- package/dist/server/serverHelpers/contentTypes.js.map +1 -1
- package/dist/server/serverHelpers/serverUtilities.d.ts +3 -3
- package/dist/server/serverHelpers/serverUtilities.js +110 -20
- package/dist/server/serverHelpers/serverUtilities.js.map +1 -1
- package/dist/server/serverHelpers/uwsServer.js +4 -1
- package/dist/server/serverHelpers/uwsServer.js.map +1 -1
- package/dist/server/serverHelpers/webSocketCloseReason.d.ts +2 -0
- package/dist/server/serverHelpers/webSocketCloseReason.js +29 -0
- package/dist/server/serverHelpers/webSocketCloseReason.js.map +1 -0
- package/dist/server/storageReclamation.js +1 -1
- package/dist/server/storageReclamation.js.map +1 -1
- package/dist/server/threads/isolatedApplications.d.ts +47 -0
- package/dist/server/threads/isolatedApplications.js +171 -0
- package/dist/server/threads/isolatedApplications.js.map +1 -0
- package/dist/server/threads/logRotationTransport.d.ts +1 -0
- package/dist/server/threads/logRotationTransport.js +33 -0
- package/dist/server/threads/logRotationTransport.js.map +1 -0
- package/dist/server/threads/manageThreads.d.ts +64 -6
- package/dist/server/threads/manageThreads.js +261 -12
- package/dist/server/threads/manageThreads.js.map +1 -1
- package/dist/server/threads/socketRouter.d.ts +1 -0
- package/dist/server/threads/socketRouter.js +196 -13
- package/dist/server/threads/socketRouter.js.map +1 -1
- package/dist/server/threads/threadServer.js +30 -7
- package/dist/server/threads/threadServer.js.map +1 -1
- package/dist/utility/errors/hdbError.d.ts +24 -0
- package/dist/utility/errors/hdbError.js +58 -1
- package/dist/utility/errors/hdbError.js.map +1 -1
- package/dist/utility/hdbTerms.d.ts +2 -0
- package/dist/utility/hdbTerms.js +2 -0
- package/dist/utility/hdbTerms.js.map +1 -1
- package/dist/utility/logging/harper_logger.js +218 -38
- package/dist/utility/logging/harper_logger.js.map +1 -1
- package/dist/utility/logging/logGenerationCoordinator.d.ts +35 -0
- package/dist/utility/logging/logGenerationCoordinator.js +184 -0
- package/dist/utility/logging/logGenerationCoordinator.js.map +1 -0
- package/dist/utility/logging/logRotation.d.ts +46 -0
- package/dist/utility/logging/logRotation.js +365 -0
- package/dist/utility/logging/logRotation.js.map +1 -0
- package/dist/utility/logging/logRotator.d.ts +1 -1
- package/dist/utility/logging/logRotator.js +172 -92
- package/dist/utility/logging/logRotator.js.map +1 -1
- package/dist/utility/npmUtilities.js +6 -4
- package/dist/utility/npmUtilities.js.map +1 -1
- package/dist/utility/watcherFallback.d.ts +0 -45
- package/dist/utility/watcherFallback.js +1 -125
- package/dist/utility/watcherFallback.js.map +1 -1
- package/dist/validation/configValidator.js +6 -3
- package/dist/validation/configValidator.js.map +1 -1
- package/index.ts +9 -0
- package/json/systemSchema.json +3 -0
- package/npm-shrinkwrap.json +177 -87
- package/package.json +13 -5
- package/resources/DESIGN.md +689 -19
- package/resources/DatabaseTransaction.ts +230 -17
- package/resources/LMDBTransaction.ts +21 -3
- package/resources/PrimaryRocksDatabase.ts +20 -7
- package/resources/RecordEncoder.ts +52 -10
- package/resources/Resource.ts +97 -13
- package/resources/ResourceInterface.ts +8 -0
- package/resources/RocksIndexStore.ts +2 -1
- package/resources/RocksTransactionLogStore.ts +111 -31
- package/resources/Table.ts +1273 -396
- package/resources/analytics/DESIGN.md +38 -0
- package/resources/analytics/write.ts +50 -17
- package/resources/auditStore.ts +460 -11
- package/resources/crdt.ts +22 -0
- package/resources/dataLoader.ts +3 -4
- package/resources/databases.ts +611 -147
- package/resources/derivedIndexRegistry.ts +56 -0
- package/resources/derivedIndexRuntime.ts +2292 -0
- package/resources/graphql.ts +3 -2
- package/resources/indexes/DESIGN.md +833 -0
- package/resources/indexes/HierarchicalNavigableSmallWorld.ts +924 -46
- package/resources/indexes/fullTextDerivedIndex.ts +1165 -0
- package/resources/indexes/fullTextNativeBinding.ts +146 -0
- package/resources/indexes/hnswDerivedIndex.ts +531 -0
- package/resources/indexes/hnswPlaneBinding.ts +174 -0
- package/resources/indexes/nativeFullTextDerivedIndexLifecycle.ts +181 -0
- package/resources/nodeIdMapping.ts +50 -0
- package/resources/record-locks.md +1407 -0
- package/resources/recordLock.ts +173 -7
- package/resources/recordLockCoordinator.ts +3082 -0
- package/resources/replayLogs.ts +5 -0
- package/resources/replicatedApplyFailure.ts +77 -0
- package/resources/scheduler/DESIGN.md +40 -0
- package/resources/scheduler/scheduler.ts +4 -4
- package/resources/search.ts +169 -49
- package/resources/tracked.ts +73 -22
- package/resources/transactionBroadcast.ts +4 -4
- package/security/DESIGN.md +175 -0
- package/security/auth.ts +53 -24
- package/security/deferredAuthentication.ts +24 -2
- package/security/jsLoader.ts +9 -4
- package/server/DESIGN.md +275 -0
- package/server/REST.ts +42 -6
- package/server/http.ts +34 -2
- package/server/mqtt.ts +6 -4
- package/server/serverHelpers/Headers.ts +5 -1
- package/server/serverHelpers/NodeAdapterResponse.ts +221 -0
- package/server/serverHelpers/Request.ts +33 -131
- package/server/serverHelpers/contentTypes.ts +188 -15
- package/server/serverHelpers/serverUtilities.ts +157 -27
- package/server/serverHelpers/uwsServer.ts +4 -1
- package/server/serverHelpers/webSocketCloseReason.ts +25 -0
- package/server/storageReclamation.ts +2 -2
- package/server/threads/isolatedApplications.ts +157 -0
- package/server/threads/logRotationTransport.ts +40 -0
- package/server/threads/manageThreads.js +254 -12
- package/server/threads/socketRouter.ts +217 -11
- package/server/threads/threadServer.js +30 -7
- package/studio/web/assets/{Chat-BnCBegQz.js → Chat-DADFFGe_.js} +1 -1
- package/studio/web/assets/{FloatingChat-CoDW1ySS.js → FloatingChat-D_mI-rZ7.js} +3 -3
- package/studio/web/assets/{apiToken-Bwk5BLXW.js → apiToken-c2NiSDHa.js} +1 -1
- package/studio/web/assets/{applications-DHxGi7JH.js → applications-DktUqh7G.js} +1 -1
- package/studio/web/assets/{cssMode-s0cWI-_M.js → cssMode-Cs_75Xhw.js} +1 -1
- package/studio/web/assets/{editor-DNcRHK54.js → editor-19b-Y1IN.js} +1 -1
- package/studio/web/assets/{html-Bdssedlg.js → html-DiYEQMpB.js} +1 -1
- package/studio/web/assets/{htmlMode-CoDlJ3fw.js → htmlMode-CmR0y7P_.js} +1 -1
- package/studio/web/assets/{index-D6sxmFLR.js → index-Dm0rfkJ7.js} +5 -5
- package/studio/web/assets/{index.lazy-tmU5BS8s.js → index.lazy-7vqt2CC3.js} +1 -1
- package/studio/web/assets/{javascript-B8meVSTH.js → javascript-BWtCFuOt.js} +1 -1
- package/studio/web/assets/{jsonMode-DpIPd35T.js → jsonMode-Buzzbv9y.js} +1 -1
- package/studio/web/assets/{languageServices-C_5FMJzQ.js → languageServices-SqsFWfTM.js} +1 -1
- package/studio/web/assets/{lspLanguageFeatures-BIzNBzPK.js → lspLanguageFeatures-EMV5cmjo.js} +1 -1
- package/studio/web/assets/{notifications-CvZivSbh.js → notifications-CAB-LZWT.js} +1 -1
- package/studio/web/assets/{notifications-CQf18QKb.js → notifications-DRzmSRxM.js} +1 -1
- package/studio/web/assets/{profile-DdOwtntb.js → profile-BNKAl79n.js} +1 -1
- package/studio/web/assets/{regions-n69fwagr.js → regions-CUow_Zw2.js} +1 -1
- package/studio/web/assets/{register-PfWTCXWB.js → register-Dkt3WUMp.js} +2 -2
- package/studio/web/assets/{setComponentFile-Bg6O7X0S.js → setComponentFile-BZRfMD0N.js} +1 -1
- package/studio/web/assets/{setup-CUx_aUDl.js → setup-D_yiEPO2.js} +2 -2
- package/studio/web/assets/{status-D7BVKqX9.js → status-DhHh1Ge-.js} +1 -1
- package/studio/web/assets/{toggleHighContrast-DBSyXzMr.js → toggleHighContrast-D7L1PDtV.js} +1 -1
- package/studio/web/assets/{tsMode-BByKCjBS.js → tsMode-CCwLk1YS.js} +1 -1
- package/studio/web/assets/{typescript-DDLnLpw9.js → typescript-BP1j1mjn.js} +1 -1
- package/studio/web/assets/{useEntityRestURL-31CHGaHk.js → useEntityRestURL-D7bnYxLw.js} +1 -1
- package/studio/web/assets/{workers-pR3jRY9D.js → workers-tOuCNT17.js} +1 -1
- package/studio/web/assets/{xml-2iRnMhQO.js → xml-BSG_3mQT.js} +1 -1
- package/studio/web/assets/{yaml-Bf92gJpd.js → yaml-DxiLprBB.js} +1 -1
- package/studio/web/index.html +1 -1
- package/utility/DESIGN.md +55 -0
- package/utility/errors/hdbError.ts +54 -0
- package/utility/hdbTerms.ts +2 -0
- package/utility/logging/harper_logger.ts +210 -30
- package/utility/logging/logGenerationCoordinator.ts +196 -0
- package/utility/logging/logRotation.ts +367 -0
- package/utility/logging/logRotator.ts +196 -91
- package/utility/npmUtilities.ts +6 -4
- package/utility/watcherFallback.ts +0 -122
- package/validation/configValidator.ts +6 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const path = require('node:path');
|
|
3
3
|
const { isMainThread, parentPort } = require('node:worker_threads');
|
|
4
|
+
const { isDeepStrictEqual } = require('node:util');
|
|
4
5
|
const fs = require('fs-extra');
|
|
5
6
|
const fg = require('fast-glob');
|
|
6
7
|
const normalize = require('normalize-path');
|
|
@@ -23,6 +24,7 @@ const { server } = require("../server/Server.js");
|
|
|
23
24
|
const { DeploymentRecorder, awaitDeploymentRow, readPayloadBlobWithRetry, coerceTimeoutMs, DEFAULT_AWAIT_ROW_TIMEOUT_MS, } = require("./deploymentRecorder.js");
|
|
24
25
|
const { ProgressEmitter } = require("../server/serverHelpers/progressEmitter.js");
|
|
25
26
|
const DROP_COMPONENT_LOCK_TIMEOUT_MS = 5 * 60 * 1000;
|
|
27
|
+
const ISOLATED_TOPOLOGY_REQUEST_TIMEOUT_MS = 5000;
|
|
26
28
|
function componentDropLockOptions(project) {
|
|
27
29
|
return {
|
|
28
30
|
timeoutMs: DROP_COMPONENT_LOCK_TIMEOUT_MS,
|
|
@@ -464,12 +466,53 @@ async function deployComponent(req) {
|
|
|
464
466
|
// replicated ciphertext (reference, not embed); already-reference entries pass through, and with
|
|
465
467
|
// no custody a literal token stays as a transient, this-node-only fallback (#1158). Peers
|
|
466
468
|
// re-running a replicated deploy already carry references and never re-ingest.
|
|
469
|
+
const { isIsolatedApplication } = require("../server/threads/isolatedApplications.js");
|
|
470
|
+
const requestedIsolation = req.isolated;
|
|
471
|
+
const isReplicatedExecution = typeof req._deploymentId === 'string';
|
|
472
|
+
const mode = req.deployment_id ? 'activate' : req.activate === false ? 'stage' : 'deploy';
|
|
473
|
+
const isActivation = mode === 'activate';
|
|
474
|
+
// this thread's cached config may predate an earlier deploy that changed the entry without a restart
|
|
475
|
+
env.initSync(true);
|
|
476
|
+
const initiallyIsolated = isIsolatedApplication(req.project);
|
|
477
|
+
if (requestedIsolation !== undefined && !req.package) {
|
|
478
|
+
throw handleHDBError(new Error(), `'isolated' is only supported for package deployments; set it on the application's root config entry instead`, HTTP_STATUS_CODES.BAD_REQUEST);
|
|
479
|
+
}
|
|
480
|
+
// Only the originating node rejects admission: replicated peers must commit the same desired config,
|
|
481
|
+
// then report any node-local inability to run it through component lifecycle status.
|
|
482
|
+
const assertIsolationAdmission = async (isolated) => {
|
|
483
|
+
if (!isolated || isReplicatedExecution)
|
|
484
|
+
return;
|
|
485
|
+
const { isolatedApplicationRefusal, isolatedApplicationCapacityRefusal, presentIsolatedApplicationNames, } = require("../server/threads/isolatedApplications.js");
|
|
486
|
+
let runningApplications;
|
|
487
|
+
try {
|
|
488
|
+
runningApplications = await manageThreads.getRunningIsolatedApplications(ISOLATED_TOPOLOGY_REQUEST_TIMEOUT_MS);
|
|
489
|
+
}
|
|
490
|
+
catch (error) {
|
|
491
|
+
throw handleHDBError(error, `Cannot deploy '${req.project}' as an isolated application: the main thread's worker topology is unavailable: ${error.message}`, HTTP_STATUS_CODES.SERVICE_UNAVAILABLE);
|
|
492
|
+
}
|
|
493
|
+
runningApplications = new Set([
|
|
494
|
+
...runningApplications,
|
|
495
|
+
...presentIsolatedApplicationNames().filter((application) => !isolatedApplicationRefusal(application)),
|
|
496
|
+
]);
|
|
497
|
+
const refusal = isolatedApplicationRefusal(req.project) ?? isolatedApplicationCapacityRefusal(req.project, runningApplications);
|
|
498
|
+
if (refusal) {
|
|
499
|
+
throw handleHDBError(new Error(), `Cannot deploy '${req.project}' as an isolated application: ${refusal}`, HTTP_STATUS_CODES.CONFLICT);
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
// Skipped for an activation: the artifact's descriptor is the authority for the isolation it wants, and
|
|
503
|
+
// `admitIsolation` runs the real check under the preparation lock. Admitting the CURRENT value here would
|
|
504
|
+
// refuse an activation whose artifact turns isolation OFF for a component whose present isolated state is
|
|
505
|
+
// itself the refusal — a 409 for the request that would fix it.
|
|
506
|
+
if (!isActivation)
|
|
507
|
+
await assertIsolationAdmission(requestedIsolation ?? initiallyIsolated);
|
|
467
508
|
const { ingestCredentials, resolveCredentials } = require("./secretOperations.js");
|
|
468
|
-
|
|
509
|
+
// An activation resolves, fetches and installs nothing, so there is no credential for it to carry.
|
|
510
|
+
// The validator rejects one; this keeps the ingest itself off the path rather than relying on that.
|
|
511
|
+
if (!isActivation)
|
|
512
|
+
req.credentials = await ingestCredentials(req, req.credentials, req.project);
|
|
469
513
|
// References are safe to persist (config + deployment row) and replicate; a no-custody literal
|
|
470
514
|
// token is not — it is used only for this node's install below, then stripped before replication.
|
|
471
515
|
const credentialReferences = (req.credentials ?? []).filter((entry) => entry && entry.secret !== undefined);
|
|
472
|
-
// Write to root config if the request contains a package identifier
|
|
473
516
|
if (req.package) {
|
|
474
517
|
// Check if trying to overwrite a core component (requires force)
|
|
475
518
|
// Lazy-load to avoid circular dependency with componentLoader
|
|
@@ -477,32 +520,9 @@ async function deployComponent(req) {
|
|
|
477
520
|
if (TRUSTED_RESOURCE_PLUGINS[req.project] && !req.force) {
|
|
478
521
|
throw handleHDBError(new Error(), `Cannot deploy component with name '${req.project}': this is a protected core component name. Use force: true to overwrite.`, HTTP_STATUS_CODES.CONFLICT);
|
|
479
522
|
}
|
|
480
|
-
const applicationConfig = { package: req.package };
|
|
481
|
-
// Avoid writing an empty `install:` block
|
|
482
|
-
if (req.install_command || req.install_timeout || req.install_allow_scripts !== undefined) {
|
|
483
|
-
applicationConfig.install = {
|
|
484
|
-
command: req.install_command,
|
|
485
|
-
timeout: req.install_timeout,
|
|
486
|
-
allowInstallScripts: req.install_allow_scripts,
|
|
487
|
-
};
|
|
488
|
-
}
|
|
489
|
-
if (req.urlPath !== undefined)
|
|
490
|
-
applicationConfig.urlPath = req.urlPath;
|
|
491
|
-
if (req.host !== undefined)
|
|
492
|
-
applicationConfig.host = req.host;
|
|
493
|
-
// Same convention as host/urlPath above, and for the same reason: a package redeploy rebuilds
|
|
494
|
-
// this application's whole root-config entry from request fields, so a deployment-level key that
|
|
495
|
-
// isn't re-supplied here is silently dropped -- for branchedDatabases specifically, that means an
|
|
496
|
-
// application which believed it had a private fork resumes sharing the base after the next
|
|
497
|
-
// restart, with nothing in this operation to say so.
|
|
498
|
-
if (req.branchedDatabases !== undefined)
|
|
499
|
-
applicationConfig.branchedDatabases = req.branchedDatabases;
|
|
500
|
-
// Persist credential references (never tokens) so every cold install of this component —
|
|
501
|
-
// reboot, new peer, rollback — re-resolves the credential from the store.
|
|
502
|
-
if (credentialReferences.length)
|
|
503
|
-
applicationConfig.credentials = credentialReferences;
|
|
504
|
-
await configUtils.addConfig(req.project, applicationConfig);
|
|
505
523
|
}
|
|
524
|
+
let wasIsolated;
|
|
525
|
+
let nowIsolated;
|
|
506
526
|
// Create a hdb_deployment row up front so the deploy is observable and auditable
|
|
507
527
|
// even if the CLI disconnects. The row also holds the payload in a Blob attribute,
|
|
508
528
|
// which doubles as the source for peer replication and (later) rollback.
|
|
@@ -511,7 +531,6 @@ async function deployComponent(req) {
|
|
|
511
531
|
// recording so we don't accumulate one row per node for the same deploy. The row
|
|
512
532
|
// reaches peers via the table's standard replication; the peer-side branch below
|
|
513
533
|
// reads payload_blob back from there.
|
|
514
|
-
const isReplicatedExecution = typeof req._deploymentId === 'string';
|
|
515
534
|
// An SSE-bound caller already attached a ProgressEmitter (created in the server
|
|
516
535
|
// handler so it can also drive the response stream). Reuse it; otherwise spin up a
|
|
517
536
|
// fresh emitter so the recorder still gets phase events for non-SSE deploys.
|
|
@@ -524,6 +543,7 @@ async function deployComponent(req) {
|
|
|
524
543
|
project: req.project,
|
|
525
544
|
package_identifier: req.package ?? null,
|
|
526
545
|
user: req.hdb_user?.username,
|
|
546
|
+
activated_from: req.deployment_id ?? null,
|
|
527
547
|
restart_mode: req.restart === 'rolling' ? 'rolling' : req.restart ? 'immediate' : null,
|
|
528
548
|
// Reference form only — the rollback source for re-resolving the credential.
|
|
529
549
|
credentials: credentialReferences.length ? credentialReferences : null,
|
|
@@ -546,12 +566,19 @@ async function deployComponent(req) {
|
|
|
546
566
|
// Bounded ring buffer of install stdout/stderr so a non-SSE caller sees the tail
|
|
547
567
|
// in the thrown error. SSE callers still stream every line live.
|
|
548
568
|
const installCapture = createInstallCapture();
|
|
569
|
+
let stagedOnOrigin = false;
|
|
549
570
|
try {
|
|
550
571
|
// On the origin, tee the tarball (Buffer or Readable from the multipart parser)
|
|
551
572
|
// through a hash-and-size tap into the row's payload_blob, then re-source extraction
|
|
552
573
|
// from the persisted blob. When `system` replicates, the blob becomes the channel
|
|
553
574
|
// peers read from; when it doesn't, the blob stays local for audit and rollback.
|
|
554
|
-
if (
|
|
575
|
+
if (isActivation) {
|
|
576
|
+
// A replicated activation has exactly the shape the peer-side blob branch below keys on — neither
|
|
577
|
+
// `package` nor `payload` — so without this branch every peer would wait out `deployment_timeout`
|
|
578
|
+
// for a payload its row never had while the origin swapped successfully.
|
|
579
|
+
extractionPayload = undefined;
|
|
580
|
+
}
|
|
581
|
+
else if (recorder && req.payload != null) {
|
|
555
582
|
await recorder.ingestPayload(req.payload);
|
|
556
583
|
extractionPayload = recorder.row.payload_blob.stream();
|
|
557
584
|
}
|
|
@@ -587,9 +614,13 @@ async function deployComponent(req) {
|
|
|
587
614
|
if (isReplicatedExecution) {
|
|
588
615
|
credentialsWaitMs = coerceTimeoutMs(req.deployment_timeout, DEFAULT_AWAIT_ROW_TIMEOUT_MS);
|
|
589
616
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
617
|
+
// Skipped for an activation, which runs no pack, clone or install: waiting for an hdb_secret row to
|
|
618
|
+
// replicate in would only delay a swap that has nothing to authenticate to.
|
|
619
|
+
const resolvedCredentials = isActivation
|
|
620
|
+
? undefined
|
|
621
|
+
: await resolveCredentials(req.credentials, req.project, {
|
|
622
|
+
waitMs: credentialsWaitMs,
|
|
623
|
+
});
|
|
593
624
|
const application = new Application({
|
|
594
625
|
name: req.project,
|
|
595
626
|
payload: extractionPayload,
|
|
@@ -628,12 +659,95 @@ async function deployComponent(req) {
|
|
|
628
659
|
// committed" — so a later failure arrives after both phases reported success. The operation's error
|
|
629
660
|
// is the authority on whether the deploy landed, not the phase stream.
|
|
630
661
|
emit('phase', { phase: 'prepare', status: 'start' });
|
|
662
|
+
// The root-config entry a package deploy publishes. A stage records it with the artifact instead of
|
|
663
|
+
// publishing it, so a staged release nobody activated cannot leave config naming it — and the
|
|
664
|
+
// activation that eventually publishes it does so in the same order a normal deploy does.
|
|
665
|
+
let stagedRootConfig = null;
|
|
631
666
|
await prepareApplication(application, {
|
|
667
|
+
// `.deploy-staging/<artifactId>`. The public deployment id, so the id the caller was handed is
|
|
668
|
+
// the id a later `deployment_id` request can name; an activation names the artifact's own id,
|
|
669
|
+
// not the new row's.
|
|
670
|
+
artifactId: req.deployment_id ?? req._deploymentId,
|
|
671
|
+
mode,
|
|
672
|
+
describeArtifact: () => ({ rootConfig: stagedRootConfig, isolated: Boolean(nowIsolated) }),
|
|
673
|
+
// Returns its own undo. Publication happens BEFORE the swap, in the same order a normal deploy
|
|
674
|
+
// uses, so an activation that fails pre-commit would otherwise leave config naming a release that
|
|
675
|
+
// is not live — and `installApplications()` would resolve and install that package from scratch at
|
|
676
|
+
// the next boot, over a component whose certified artifact is sitting right there. Restoring is
|
|
677
|
+
// best-effort and not durable (that is #2315 step 3's work); it is still the difference between a
|
|
678
|
+
// failed activation that changed nothing and one that re-points the component.
|
|
679
|
+
publishRootConfig: async (entry) => {
|
|
680
|
+
const previous = configUtils.getConfigObj()?.[req.project];
|
|
681
|
+
await configUtils.addConfig(req.project, entry);
|
|
682
|
+
env.initSync(true);
|
|
683
|
+
// Read BACK, not `entry` — see `publishedEntryStillStands`.
|
|
684
|
+
const published = configUtils.getConfigObj()?.[req.project];
|
|
685
|
+
return async () => {
|
|
686
|
+
if (!publishedEntryStillStands(published, () => env.initSync(true), () => configUtils.getConfigObj()?.[req.project])) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
if (previous === undefined)
|
|
690
|
+
configUtils.deleteConfigFromFile([req.project]);
|
|
691
|
+
else
|
|
692
|
+
await configUtils.addConfig(req.project, previous);
|
|
693
|
+
env.initSync(true);
|
|
694
|
+
};
|
|
695
|
+
},
|
|
696
|
+
admitIsolation: async (descriptor) => {
|
|
697
|
+
env.initSync(true);
|
|
698
|
+
wasIsolated = isIsolatedApplication(req.project);
|
|
699
|
+
// A package artifact restores its own root-config entry, so its recorded intent is what will
|
|
700
|
+
// be in force. A payload artifact publishes no config, so the effective configuration is the
|
|
701
|
+
// only authority there — a saved `false` must not admit past an isolation the operator set
|
|
702
|
+
// between the stage and this call.
|
|
703
|
+
nowIsolated = descriptor.rootConfig ? descriptor.isolated : wasIsolated;
|
|
704
|
+
await assertIsolationAdmission(nowIsolated);
|
|
705
|
+
},
|
|
706
|
+
beforePrepare: async () => {
|
|
707
|
+
if (isActivation)
|
|
708
|
+
return;
|
|
709
|
+
env.initSync(true);
|
|
710
|
+
wasIsolated = isIsolatedApplication(req.project);
|
|
711
|
+
nowIsolated = requestedIsolation ?? wasIsolated;
|
|
712
|
+
await assertIsolationAdmission(nowIsolated);
|
|
713
|
+
if (!isReplicatedExecution && req.package)
|
|
714
|
+
req.isolated = nowIsolated;
|
|
715
|
+
if (!req.package)
|
|
716
|
+
return;
|
|
717
|
+
const applicationConfig = { package: req.package };
|
|
718
|
+
if (req.install_command || req.install_timeout || req.install_allow_scripts !== undefined) {
|
|
719
|
+
applicationConfig.install = {
|
|
720
|
+
command: req.install_command,
|
|
721
|
+
timeout: req.install_timeout,
|
|
722
|
+
allowInstallScripts: req.install_allow_scripts,
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
if (req.urlPath !== undefined)
|
|
726
|
+
applicationConfig.urlPath = req.urlPath;
|
|
727
|
+
if (req.host !== undefined)
|
|
728
|
+
applicationConfig.host = req.host;
|
|
729
|
+
if (req.branchedDatabases !== undefined)
|
|
730
|
+
applicationConfig.branchedDatabases = req.branchedDatabases;
|
|
731
|
+
if (nowIsolated)
|
|
732
|
+
applicationConfig.isolated = true;
|
|
733
|
+
if (credentialReferences.length)
|
|
734
|
+
applicationConfig.credentials = credentialReferences;
|
|
735
|
+
if (mode === 'stage') {
|
|
736
|
+
stagedRootConfig = applicationConfig;
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
await configUtils.addConfig(req.project, applicationConfig);
|
|
740
|
+
env.initSync(true);
|
|
741
|
+
},
|
|
632
742
|
validateCandidate: async (candidateDirPath) => {
|
|
633
743
|
emit('phase', { phase: 'prepare', status: 'done' });
|
|
634
744
|
await validateComponentLoads(candidateDirPath, emit);
|
|
635
745
|
},
|
|
636
746
|
});
|
|
747
|
+
// The build is certified on disk from here on, so every later failure — a peer result, or a rejection
|
|
748
|
+
// thrown by the replication layer itself — still leaves an artifact this id can activate.
|
|
749
|
+
if (mode === 'stage')
|
|
750
|
+
stagedOnOrigin = true;
|
|
637
751
|
const rollingRestart = req.restart === 'rolling';
|
|
638
752
|
// if doing a rolling restart set restart to false so that other nodes don't also restart.
|
|
639
753
|
req.restart = rollingRestart ? false : req.restart;
|
|
@@ -676,14 +790,26 @@ async function deployComponent(req) {
|
|
|
676
790
|
// when the per-peer callback already fired for these.
|
|
677
791
|
recorder.recordPeers(response.replicated);
|
|
678
792
|
}
|
|
679
|
-
|
|
793
|
+
// A still-isolated application restarts only its own dedicated worker. Everything else restarts the
|
|
794
|
+
// pool: a shared application, and either direction of an isolation flip, where the reconcile in
|
|
795
|
+
// restartWorkers starts or stops the moving application's own worker.
|
|
796
|
+
const restartScope = wasIsolated && nowIsolated ? application.name : undefined;
|
|
797
|
+
if (mode === 'stage') {
|
|
798
|
+
// No restart and no restart-required flag: nothing about the running component changed. The
|
|
799
|
+
// marker is what tells the origin which peers understood the request — see the confirmation
|
|
800
|
+
// check below — and it is set on every node, origin included, since a peer returns this same
|
|
801
|
+
// object as its operation response.
|
|
802
|
+
response.staged = true;
|
|
803
|
+
response.message = `Staged: ${application.name}`;
|
|
804
|
+
}
|
|
805
|
+
else if (req.restart === true) {
|
|
680
806
|
emit('phase', { phase: 'restart', status: 'start' });
|
|
681
807
|
// Workers not yet replaced keep serving the pre-deploy component set, and where the OS lets
|
|
682
808
|
// replacements share a port they keep accepting connections for the whole rolling restart, so
|
|
683
809
|
// a caller that reads success as "the component is live" can be served by a worker that has
|
|
684
810
|
// never heard of it.
|
|
685
811
|
const { awaitRestart } = require("./awaitRestart.js");
|
|
686
|
-
const restart = await awaitRestart((onProgress) => manageThreads.restartWorkers('http', undefined, undefined, onProgress));
|
|
812
|
+
const restart = await awaitRestart((onProgress) => manageThreads.restartWorkers('http', undefined, undefined, onProgress, restartScope));
|
|
687
813
|
emit('phase', { phase: 'restart', status: 'done' });
|
|
688
814
|
logRestartOutcome(restart, `deploying ${application.name}`);
|
|
689
815
|
response.message = `Successfully deployed: ${application.name}, restarting Harper`;
|
|
@@ -694,6 +820,8 @@ async function deployComponent(req) {
|
|
|
694
820
|
const jobResponse = await serverUtilities.executeJob({
|
|
695
821
|
operation: 'restart_service',
|
|
696
822
|
service: 'http',
|
|
823
|
+
scope: manageThreads.encodeRestartScope(restartScope),
|
|
824
|
+
scopeFallback: restartScope === undefined ? undefined : manageThreads.encodeRestartScope(undefined),
|
|
697
825
|
replicated: true,
|
|
698
826
|
});
|
|
699
827
|
emit('phase', { phase: 'restart', status: 'done' });
|
|
@@ -713,10 +841,8 @@ async function deployComponent(req) {
|
|
|
713
841
|
// An existing component's watched files are handled by Scope/EntryHandler. Package
|
|
714
842
|
// metadata is deliberately outside most plugin globs, so compare it across the atomic
|
|
715
843
|
// swap as well: a dependency or module-entry change also invalidates loaded code.
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
requestRestart();
|
|
719
|
-
}
|
|
844
|
+
const { requestRestartAfterDeploy } = require("./requestRestart.js");
|
|
845
|
+
requestRestartAfterDeploy(application.isNewComponent, application.packageMetadataChanged, wasIsolated, nowIsolated);
|
|
720
846
|
response.message = `Successfully deployed: ${application.name}`;
|
|
721
847
|
}
|
|
722
848
|
// Replication failures don't reject replicateOperation — they surface as 'failed'
|
|
@@ -731,10 +857,32 @@ async function deployComponent(req) {
|
|
|
731
857
|
const detail = failedPeers
|
|
732
858
|
.map((peer) => `${peer.node ?? 'unknown'} (${peer.error?.message ?? 'unknown error'})`)
|
|
733
859
|
.join(', ');
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
`See deployment ${recorder.deploymentId} (get_deployment) for details, or
|
|
737
|
-
`ignore_replication_errors: true to treat replication failures as non-fatal.`);
|
|
860
|
+
const replicationError = new ServerError(`Component '${application.name}' was ${mode === 'stage' ? 'staged' : 'deployed'} on the origin node ` +
|
|
861
|
+
`but failed to replicate to ${failedPeers.length} of ${recorder.row.peer_results.length} peer ` +
|
|
862
|
+
`node(s): ${detail}. See deployment ${recorder.deploymentId} (get_deployment) for details, or ` +
|
|
863
|
+
`pass ignore_replication_errors: true to treat replication failures as non-fatal.`);
|
|
864
|
+
throw replicationError;
|
|
865
|
+
}
|
|
866
|
+
// A peer running a build that predates staged deploys accepts `activate: false` as an unknown
|
|
867
|
+
// field and performs its ordinary deploy, so it is now serving a release the operator asked only
|
|
868
|
+
// to stage. Nothing can prevent that — the operations channel carries no peer version or
|
|
869
|
+
// capability — so the origin reports it, from the one signal that separates the two cases: a node
|
|
870
|
+
// that staged says so in its response. Read from the raw aggregate, because the recorder's peer
|
|
871
|
+
// normalization keeps only node/status/error.
|
|
872
|
+
//
|
|
873
|
+
// The wording stays at "did not confirm". An unreachable peer and one that dropped the request
|
|
874
|
+
// look identical from here, and telling an operator those nodes went live would be a guess.
|
|
875
|
+
if (mode === 'stage') {
|
|
876
|
+
const unconfirmed = unconfirmedStagingPeers(response?.replicated);
|
|
877
|
+
if (unconfirmed.length > 0) {
|
|
878
|
+
const detail = unconfirmed.map((peer) => peer.node ?? 'unknown').join(', ');
|
|
879
|
+
const unconfirmedError = new ServerError(`Component '${application.name}' was staged on the origin node, but ${unconfirmed.length} peer ` +
|
|
880
|
+
`node(s) did not confirm staging: ${detail}. Either they are unreachable, or they run a build ` +
|
|
881
|
+
`that predates staged deploys — which treats this request as an ordinary deploy, so the ` +
|
|
882
|
+
`release is already serving there. Check those nodes before activating deployment ` +
|
|
883
|
+
`${recorder.deploymentId}, or pass ignore_replication_errors: true to accept the difference.`);
|
|
884
|
+
throw unconfirmedError;
|
|
885
|
+
}
|
|
738
886
|
}
|
|
739
887
|
}
|
|
740
888
|
if (recorder) {
|
|
@@ -747,15 +895,27 @@ async function deployComponent(req) {
|
|
|
747
895
|
// the tarball when it's still the artifact you'd debug or retry with: failed deploys
|
|
748
896
|
// don't reach this branch, and a deploy that reached here only because
|
|
749
897
|
// ignore_replication_errors masked failed peers keeps its payload for those peers.
|
|
898
|
+
// Never for a stage: the artifact on disk is not yet a release anyone can re-derive, and retention
|
|
899
|
+
// can evict it (it shares `deployment_stagingRetention_maxCount` with incidental dormant builds),
|
|
900
|
+
// so dropping the tarball here is how a staged release becomes unrecoverable — no tree, no bytes,
|
|
901
|
+
// and a row still reporting `staged`. An operator can still reclaim it deliberately with
|
|
902
|
+
// delete_deployment_payload once they accept that.
|
|
750
903
|
const payloadSize = recorder.row.payload_size;
|
|
751
904
|
const retentionMaxSize = getPayloadRetentionMaxSize();
|
|
752
|
-
if (
|
|
905
|
+
if (mode !== 'stage' &&
|
|
906
|
+
typeof payloadSize === 'number' &&
|
|
907
|
+
payloadSize > retentionMaxSize &&
|
|
908
|
+
recorder.getFailedPeers().length === 0) {
|
|
753
909
|
const freed = recorder.dropPayload();
|
|
754
910
|
if (freed > 0)
|
|
755
911
|
emit('payload_dropped', { payload_size: freed, max_size: retentionMaxSize });
|
|
756
912
|
}
|
|
757
|
-
emit('phase', { phase: 'success', status: 'done' });
|
|
758
|
-
await recorder.finish('success');
|
|
913
|
+
emit('phase', { phase: mode === 'stage' ? 'staged' : 'success', status: 'done' });
|
|
914
|
+
await recorder.finish(mode === 'stage' ? 'staged' : 'success');
|
|
915
|
+
if (mode === 'stage') {
|
|
916
|
+
response.message =
|
|
917
|
+
`Staged: ${application.name}. Deploy it with deploy_component ` + `deployment_id=${recorder.deploymentId}`;
|
|
918
|
+
}
|
|
759
919
|
}
|
|
760
920
|
return response;
|
|
761
921
|
}
|
|
@@ -799,7 +959,7 @@ async function deployComponent(req) {
|
|
|
799
959
|
// install output, and failed_peers the caller needs.
|
|
800
960
|
if (recorder) {
|
|
801
961
|
try {
|
|
802
|
-
await recorder.finish('failed', err);
|
|
962
|
+
await recorder.finish(stagedOnOrigin ? 'staged' : 'failed', err);
|
|
803
963
|
}
|
|
804
964
|
catch (finishErr) {
|
|
805
965
|
log.warn('Failed to record deployment failure row', finishErr);
|
|
@@ -808,6 +968,42 @@ async function deployComponent(req) {
|
|
|
808
968
|
throw outErr;
|
|
809
969
|
}
|
|
810
970
|
}
|
|
971
|
+
/**
|
|
972
|
+
* Whether the root-config entry an activation published is still the one on disk — the condition for that
|
|
973
|
+
* activation's failure to take it back. A `set_configuration` acknowledged while the swap was retrying is
|
|
974
|
+
* not this operation's to overwrite, and restoring a snapshot taken before it would silently drop it.
|
|
975
|
+
*
|
|
976
|
+
* Split out from the caller so it can be tested without a deploy: this is the only guard on a hazard the
|
|
977
|
+
* preparation lock does not cover, and both ways it can regress fail silently. `refreshConfig` is called
|
|
978
|
+
* BEFORE the read and is load-bearing — `set_configuration` writes the config file without refreshing this
|
|
979
|
+
* process's config object, so a cached read compares against a value that predates the very change the
|
|
980
|
+
* guard exists to protect and always concludes nothing moved. It narrows the window rather than closing
|
|
981
|
+
* it; serializing config publication is #2315 step 3.
|
|
982
|
+
*
|
|
983
|
+
* `published` must be the entry as read back after publication, not as passed in: only two values that went
|
|
984
|
+
* through the same write-and-parse round trip are comparable, and comparing against the argument would read
|
|
985
|
+
* any serialization difference as a concurrent change and skip every undo.
|
|
986
|
+
*/
|
|
987
|
+
function publishedEntryStillStands(published, refreshConfig, readCurrentEntry) {
|
|
988
|
+
refreshConfig();
|
|
989
|
+
return isDeepStrictEqual(readCurrentEntry(), published);
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Peers that did not answer a stage with `staged: true` — either unreachable, or running a build that
|
|
993
|
+
* predates staged deploys and therefore treated the request as an ordinary deploy.
|
|
994
|
+
*
|
|
995
|
+
* Split out from the caller so it can be tested without a cluster: this is the only safety net for the
|
|
996
|
+
* mixed-version hazard #2315 records as accepted, and a regression in it fails silently. The entry shape
|
|
997
|
+
* belongs to harper-pro's replicator rather than this repo — `normalizePeerResult` already tolerates more
|
|
998
|
+
* than one — so the marker is read flat or from a wrapped body; assuming flat would report every peer in a
|
|
999
|
+
* fully-upgraded cluster as unconfirmed.
|
|
1000
|
+
*/
|
|
1001
|
+
function unconfirmedStagingPeers(replicated) {
|
|
1002
|
+
if (!Array.isArray(replicated))
|
|
1003
|
+
return [];
|
|
1004
|
+
const confirmed = (peer) => peer?.staged === true || peer?.value?.staged === true || peer?.body?.staged === true;
|
|
1005
|
+
return replicated.filter((peer) => peer && !confirmed(peer));
|
|
1006
|
+
}
|
|
811
1007
|
// Ring buffer of install stdout/stderr lines, capped by both line count and bytes so
|
|
812
1008
|
// a chatty install can't unbounded-grow the error response. snapshot() reports whether
|
|
813
1009
|
// the head was dropped so callers can flag truncation.
|
|
@@ -1163,10 +1359,22 @@ async function dropComponent(req) {
|
|
|
1163
1359
|
const componentsRoot = configUtils.getConfigPath(hdbTerms.CONFIG_PARAMS.COMPONENTSROOT);
|
|
1164
1360
|
const componentPath = path.join(componentsRoot, project);
|
|
1165
1361
|
const pathToComponent = path.join(componentsRoot, projectPath);
|
|
1362
|
+
let restartScope;
|
|
1166
1363
|
let response;
|
|
1167
1364
|
await withComponentPreparationLock(componentPath, async () => {
|
|
1365
|
+
if (req.restart === true) {
|
|
1366
|
+
let runningApplications;
|
|
1367
|
+
try {
|
|
1368
|
+
runningApplications = await manageThreads.getRunningIsolatedApplications(ISOLATED_TOPOLOGY_REQUEST_TIMEOUT_MS);
|
|
1369
|
+
}
|
|
1370
|
+
catch (error) {
|
|
1371
|
+
throw handleHDBError(error, `Cannot drop '${project}' with a restart: the main thread's worker topology is unavailable: ${error.message}`, HTTP_STATUS_CODES.SERVICE_UNAVAILABLE);
|
|
1372
|
+
}
|
|
1373
|
+
if (runningApplications.includes(project))
|
|
1374
|
+
restartScope = project;
|
|
1375
|
+
}
|
|
1168
1376
|
const componentSymlink = path.join(env.get(hdbTerms.CONFIG_PARAMS.ROOTPATH), 'node_modules', project);
|
|
1169
|
-
if (await fs.pathExists(componentSymlink)) {
|
|
1377
|
+
if (!file && (await fs.pathExists(componentSymlink))) {
|
|
1170
1378
|
await fs.unlink(componentSymlink);
|
|
1171
1379
|
}
|
|
1172
1380
|
if (!file) {
|
|
@@ -1176,18 +1384,16 @@ async function dropComponent(req) {
|
|
|
1176
1384
|
await fs.remove(pathToComponent);
|
|
1177
1385
|
}
|
|
1178
1386
|
const packageJsonPath = path.join(env.get(hdbTerms.CONFIG_PARAMS.ROOTPATH), 'package.json');
|
|
1179
|
-
if (await fs.pathExists(packageJsonPath)) {
|
|
1387
|
+
if (!file && (await fs.pathExists(packageJsonPath))) {
|
|
1180
1388
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
|
|
1181
1389
|
if (packageJson?.dependencies?.[project]) {
|
|
1182
1390
|
delete packageJson.dependencies[project];
|
|
1183
1391
|
}
|
|
1184
1392
|
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
|
|
1185
1393
|
}
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
// (A worker's RESTART message refreshes main's config the same way.)
|
|
1190
|
-
if (isMainThread)
|
|
1394
|
+
if (!file)
|
|
1395
|
+
configUtils.deleteConfigFromFile([project]);
|
|
1396
|
+
if (!file && isMainThread)
|
|
1191
1397
|
env.initSync(true);
|
|
1192
1398
|
response = await server.replication.replicateOperation(req);
|
|
1193
1399
|
const { applicationHasBranchStorage, removeBranchesForApplication } = require("../resources/branchDatabase.js");
|
|
@@ -1205,6 +1411,7 @@ async function dropComponent(req) {
|
|
|
1205
1411
|
parentPort.postMessage({
|
|
1206
1412
|
type: hdbTerms.ITC_EVENT_TYPES.RESTART,
|
|
1207
1413
|
workerType: 'http',
|
|
1414
|
+
scope: manageThreads.encodeRestartScope(restartScope),
|
|
1208
1415
|
removeBranchesFor: file ? undefined : project,
|
|
1209
1416
|
});
|
|
1210
1417
|
if (branched) {
|
|
@@ -1214,7 +1421,7 @@ async function dropComponent(req) {
|
|
|
1214
1421
|
return;
|
|
1215
1422
|
}
|
|
1216
1423
|
const { awaitRestart } = require("./awaitRestart.js");
|
|
1217
|
-
const restart = await awaitRestart((onProgress) => manageThreads.restartWorkers('http', undefined, undefined, onProgress));
|
|
1424
|
+
const restart = await awaitRestart((onProgress) => manageThreads.restartWorkers('http', undefined, undefined, onProgress, restartScope));
|
|
1218
1425
|
logRestartOutcome(restart, `dropping ${projectPath}`);
|
|
1219
1426
|
if (!branched)
|
|
1220
1427
|
return;
|
|
@@ -1244,6 +1451,8 @@ exports.addComponent = addComponent;
|
|
|
1244
1451
|
exports.dropCustomFunctionProject = dropCustomFunctionProject;
|
|
1245
1452
|
exports.packageComponent = packageComponent;
|
|
1246
1453
|
exports.deployComponent = deployComponent;
|
|
1454
|
+
exports.unconfirmedStagingPeers = unconfirmedStagingPeers;
|
|
1455
|
+
exports.publishedEntryStillStands = publishedEntryStillStands;
|
|
1247
1456
|
exports.getComponents = getComponents;
|
|
1248
1457
|
exports.getComponentFile = getComponentFile;
|
|
1249
1458
|
exports.setComponentFile = setComponentFile;
|