From daa1fe9386143ef65eea371f765914c3004c0bcd Mon Sep 17 00:00:00 2001 From: Cornelius Suermann Date: Wed, 19 Feb 2025 15:56:30 +0100 Subject: [PATCH] chore: Bump license-sdk to v2.16.1 (no-changelog) (#13351) Co-authored-by: Tomi Turtiainen <10324676+tomi@users.noreply.github.com> --- packages/cli/package.json | 2 +- packages/cli/src/license.ts | 84 +++++++++++++++++++++++-------------- pnpm-lock.yaml | 10 ++--- 3 files changed, 59 insertions(+), 37 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index f0b237ee78..fe66208b93 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -97,7 +97,7 @@ "@n8n/task-runner": "workspace:*", "@n8n/typeorm": "0.3.20-12", "@n8n_io/ai-assistant-sdk": "1.13.0", - "@n8n_io/license-sdk": "2.16.0", + "@n8n_io/license-sdk": "2.16.1", "@oclif/core": "4.0.7", "@rudderstack/rudder-sdk-node": "2.0.9", "@sentry/node": "catalog:", diff --git a/packages/cli/src/license.ts b/packages/cli/src/license.ts index c0bece9927..8118405b76 100644 --- a/packages/cli/src/license.ts +++ b/packages/cli/src/license.ts @@ -103,6 +103,11 @@ export class License { }); await this.manager.initialize(); + + const features = this.manager.getFeatures(); + this.checkIsLicensedForMultiMain(features); + this.checkIsLicensedForBinaryDataS3(features); + this.logger.debug('License initialized'); } catch (error: unknown) { if (error instanceof Error) { @@ -129,44 +134,20 @@ export class License { async onFeatureChange(_features: TFeatures): Promise { this.logger.debug('License feature change detected', _features); - if (config.getEnv('executions.mode') === 'queue' && this.globalConfig.multiMainSetup.enabled) { - const isMultiMainLicensed = - (_features[LICENSE_FEATURES.MULTIPLE_MAIN_INSTANCES] as boolean | undefined) ?? false; + this.checkIsLicensedForMultiMain(_features); + this.checkIsLicensedForBinaryDataS3(_features); - this.instanceSettings.setMultiMainLicensed(isMultiMainLicensed); - - if (this.instanceSettings.isMultiMain && !this.instanceSettings.isLeader) { - this.logger - .scoped(['scaling', 'multi-main-setup', 'license']) - .debug('Instance is not leader, skipping sending of "reload-license" command...'); - return; - } - - if (this.globalConfig.multiMainSetup.enabled && !isMultiMainLicensed) { - this.logger - .scoped(['scaling', 'multi-main-setup', 'license']) - .debug( - 'License changed with no support for multi-main setup - no new followers will be allowed to init. To restore multi-main setup, please upgrade to a license that supports this feature.', - ); - } + if (this.instanceSettings.isMultiMain && !this.instanceSettings.isLeader) { + this.logger + .scoped(['scaling', 'multi-main-setup', 'license']) + .debug('Instance is not leader, skipping sending of "reload-license" command...'); + return; } if (config.getEnv('executions.mode') === 'queue') { const { Publisher } = await import('@/scaling/pubsub/publisher.service'); await Container.get(Publisher).publishCommand({ command: 'reload-license' }); } - - const isS3Selected = config.getEnv('binaryDataManager.mode') === 's3'; - const isS3Available = config.getEnv('binaryDataManager.availableModes').includes('s3'); - const isS3Licensed = _features['feat:binaryDataS3']; - - if (isS3Selected && isS3Available && !isS3Licensed) { - this.logger.debug( - 'License changed with no support for external storage - blocking writes on object store. To restore writes, please upgrade to a license that supports this feature.', - ); - - Container.get(ObjectStoreService).setReadonly(true); - } } async saveCertStr(value: TLicenseBlock): Promise { @@ -407,4 +388,45 @@ export class License { await this.init({ forceRecreate: true }); this.logger.debug('License reinitialized'); } + + /** + * Ensures that the instance is licensed for multi-main setup if multi-main mode is enabled + */ + private checkIsLicensedForMultiMain(features: TFeatures) { + const isMultiMainEnabled = + config.getEnv('executions.mode') === 'queue' && this.globalConfig.multiMainSetup.enabled; + if (!isMultiMainEnabled) { + return; + } + + const isMultiMainLicensed = + (features[LICENSE_FEATURES.MULTIPLE_MAIN_INSTANCES] as boolean | undefined) ?? false; + + this.instanceSettings.setMultiMainLicensed(isMultiMainLicensed); + + if (!isMultiMainLicensed) { + this.logger + .scoped(['scaling', 'multi-main-setup', 'license']) + .debug( + 'License changed with no support for multi-main setup - no new followers will be allowed to init. To restore multi-main setup, please upgrade to a license that supports this feature.', + ); + } + } + + /** + * Ensures that the instance is licensed for binary data S3 if S3 is selected and available + */ + private checkIsLicensedForBinaryDataS3(features: TFeatures) { + const isS3Selected = config.getEnv('binaryDataManager.mode') === 's3'; + const isS3Available = config.getEnv('binaryDataManager.availableModes').includes('s3'); + const isS3Licensed = features['feat:binaryDataS3']; + + if (isS3Selected && isS3Available && !isS3Licensed) { + this.logger.debug( + 'License changed with no support for external storage - blocking writes on object store. To restore writes, please upgrade to a license that supports this feature.', + ); + + Container.get(ObjectStoreService).setReadonly(true); + } + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a3fc95eaff..7c0d9112a9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -824,8 +824,8 @@ importers: specifier: 1.13.0 version: 1.13.0 '@n8n_io/license-sdk': - specifier: 2.16.0 - version: 2.16.0 + specifier: 2.16.1 + version: 2.16.1 '@oclif/core': specifier: 4.0.7 version: 4.0.7 @@ -4564,8 +4564,8 @@ packages: resolution: {integrity: sha512-16kftFTeX3/lBinHJaBK0OL1lB4FpPaUoHX4h25AkvgHvmjUHpWNY2ZtKos0rY89+pkzDsNxMZqSUkeKU45iRg==} engines: {node: '>=20.15', pnpm: '>=8.14'} - '@n8n_io/license-sdk@2.16.0': - resolution: {integrity: sha512-MVBqCkapJUX1rWhAXzGnfqOFaqzr0MT2X3ZTuA1BOyypb0doiuG9eh2ABy67Py4QKXGu+gnBAXZYGwG29bay+w==} + '@n8n_io/license-sdk@2.16.1': + resolution: {integrity: sha512-J3zsSzu0JftKAsLnxeKtprKkNSWpfNNMy7kUGkBgEsd6R7kJ6bzKKIcyTu+pHPP+Gfe6iTKw+SXz2TXSZEmK2A==} engines: {node: '>=18.12.1'} '@n8n_io/riot-tmpl@4.0.0': @@ -16961,7 +16961,7 @@ snapshots: '@n8n_io/ai-assistant-sdk@1.13.0': {} - '@n8n_io/license-sdk@2.16.0': + '@n8n_io/license-sdk@2.16.1': dependencies: crypto-js: 4.2.0 node-machine-id: 1.1.12