mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
refactor(core): Improve license lifecycle logging (no-changelog) (#10643)
This commit is contained in:
parent
b4a391536c
commit
f0c61d029a
|
@ -109,6 +109,7 @@ export class License {
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.manager.initialize();
|
await this.manager.initialize();
|
||||||
|
this.logger.debug('License initialized');
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
if (e instanceof Error) {
|
if (e instanceof Error) {
|
||||||
this.logger.error('Could not initialize license manager sdk', e);
|
this.logger.error('Could not initialize license manager sdk', e);
|
||||||
|
@ -132,6 +133,8 @@ export class License {
|
||||||
}
|
}
|
||||||
|
|
||||||
async onFeatureChange(_features: TFeatures): Promise<void> {
|
async onFeatureChange(_features: TFeatures): Promise<void> {
|
||||||
|
this.logger.debug('License feature change detected', _features);
|
||||||
|
|
||||||
if (config.getEnv('executions.mode') === 'queue' && config.getEnv('multiMainSetup.enabled')) {
|
if (config.getEnv('executions.mode') === 'queue' && config.getEnv('multiMainSetup.enabled')) {
|
||||||
const isMultiMainLicensed = _features[LICENSE_FEATURES.MULTIPLE_MAIN_INSTANCES] as
|
const isMultiMainLicensed = _features[LICENSE_FEATURES.MULTIPLE_MAIN_INSTANCES] as
|
||||||
| boolean
|
| boolean
|
||||||
|
@ -198,14 +201,15 @@ export class License {
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.manager.activate(activationKey);
|
await this.manager.activate(activationKey);
|
||||||
|
this.logger.debug('License activated');
|
||||||
}
|
}
|
||||||
|
|
||||||
async reload(): Promise<void> {
|
async reload(): Promise<void> {
|
||||||
if (!this.manager) {
|
if (!this.manager) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.logger.debug('Reloading license');
|
|
||||||
await this.manager.reload();
|
await this.manager.reload();
|
||||||
|
this.logger.debug('License reloaded');
|
||||||
}
|
}
|
||||||
|
|
||||||
async renew() {
|
async renew() {
|
||||||
|
@ -214,6 +218,7 @@ export class License {
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.manager.renew();
|
await this.manager.renew();
|
||||||
|
this.logger.debug('License renewed');
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnShutdown()
|
@OnShutdown()
|
||||||
|
@ -227,6 +232,7 @@ export class License {
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.manager.shutdown();
|
await this.manager.shutdown();
|
||||||
|
this.logger.debug('License shut down');
|
||||||
}
|
}
|
||||||
|
|
||||||
isFeatureEnabled(feature: BooleanLicenseFeature) {
|
isFeatureEnabled(feature: BooleanLicenseFeature) {
|
||||||
|
@ -392,5 +398,6 @@ export class License {
|
||||||
async reinit() {
|
async reinit() {
|
||||||
this.manager?.reset();
|
this.manager?.reset();
|
||||||
await this.init('main', true);
|
await this.init('main', true);
|
||||||
|
this.logger.debug('License reinitialized');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import { handleCommandMessageMain } from '@/services/orchestration/main/handle-c
|
||||||
import { OrchestrationHandlerMainService } from '@/services/orchestration/main/orchestration.handler.main.service';
|
import { OrchestrationHandlerMainService } from '@/services/orchestration/main/orchestration.handler.main.service';
|
||||||
import * as helpers from '@/services/orchestration/helpers';
|
import * as helpers from '@/services/orchestration/helpers';
|
||||||
import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee';
|
import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee';
|
||||||
import { Logger } from '@/logger';
|
|
||||||
import { Push } from '@/push';
|
import { Push } from '@/push';
|
||||||
import { ActiveWorkflowManager } from '@/active-workflow-manager';
|
import { ActiveWorkflowManager } from '@/active-workflow-manager';
|
||||||
import { mockInstance } from '@test/mocking';
|
import { mockInstance } from '@test/mocking';
|
||||||
|
@ -47,7 +46,6 @@ const workerRestartEventBusResponse: RedisServiceWorkerResponseObject = {
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('Orchestration Service', () => {
|
describe('Orchestration Service', () => {
|
||||||
const logger = mockInstance(Logger);
|
|
||||||
mockInstance(Push);
|
mockInstance(Push);
|
||||||
mockInstance(RedisService);
|
mockInstance(RedisService);
|
||||||
mockInstance(ExternalSecretsManager);
|
mockInstance(ExternalSecretsManager);
|
||||||
|
@ -112,7 +110,6 @@ describe('Orchestration Service', () => {
|
||||||
expect(responseFalseId).toBeDefined();
|
expect(responseFalseId).toBeDefined();
|
||||||
expect(responseFalseId!.command).toEqual('reloadLicense');
|
expect(responseFalseId!.command).toEqual('reloadLicense');
|
||||||
expect(responseFalseId!.senderId).toEqual('test');
|
expect(responseFalseId!.senderId).toEqual('test');
|
||||||
expect(logger.error).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should reject command messages from itself', async () => {
|
test('should reject command messages from itself', async () => {
|
||||||
|
|
|
@ -53,11 +53,7 @@ export async function handleCommandMessageMain(messageString: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMainInstance && !config.getEnv('multiMainSetup.enabled')) {
|
if (isMainInstance && !config.getEnv('multiMainSetup.enabled')) {
|
||||||
// at this point in time, only a single main instance is supported, thus this command _should_ never be caught currently
|
return message; // this main is the sender, so disregard
|
||||||
logger.error(
|
|
||||||
'Received command to reload license via Redis, but this should not have happened and is not supported on the main instance yet.',
|
|
||||||
);
|
|
||||||
return message;
|
|
||||||
}
|
}
|
||||||
await Container.get(License).reload();
|
await Container.get(License).reload();
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue