refactor(core): Improve license lifecycle logging (no-changelog) (#10643)

This commit is contained in:
Iván Ovejero 2024-09-03 11:51:29 +02:00 committed by GitHub
parent b4a391536c
commit f0c61d029a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 9 deletions

View file

@ -109,6 +109,7 @@ export class License {
});
await this.manager.initialize();
this.logger.debug('License initialized');
} catch (e: unknown) {
if (e instanceof Error) {
this.logger.error('Could not initialize license manager sdk', e);
@ -132,6 +133,8 @@ export class License {
}
async onFeatureChange(_features: TFeatures): Promise<void> {
this.logger.debug('License feature change detected', _features);
if (config.getEnv('executions.mode') === 'queue' && config.getEnv('multiMainSetup.enabled')) {
const isMultiMainLicensed = _features[LICENSE_FEATURES.MULTIPLE_MAIN_INSTANCES] as
| boolean
@ -198,14 +201,15 @@ export class License {
}
await this.manager.activate(activationKey);
this.logger.debug('License activated');
}
async reload(): Promise<void> {
if (!this.manager) {
return;
}
this.logger.debug('Reloading license');
await this.manager.reload();
this.logger.debug('License reloaded');
}
async renew() {
@ -214,6 +218,7 @@ export class License {
}
await this.manager.renew();
this.logger.debug('License renewed');
}
@OnShutdown()
@ -227,6 +232,7 @@ export class License {
}
await this.manager.shutdown();
this.logger.debug('License shut down');
}
isFeatureEnabled(feature: BooleanLicenseFeature) {
@ -392,5 +398,6 @@ export class License {
async reinit() {
this.manager?.reset();
await this.init('main', true);
this.logger.debug('License reinitialized');
}
}

View file

@ -14,7 +14,6 @@ import { handleCommandMessageMain } from '@/services/orchestration/main/handle-c
import { OrchestrationHandlerMainService } from '@/services/orchestration/main/orchestration.handler.main.service';
import * as helpers from '@/services/orchestration/helpers';
import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee';
import { Logger } from '@/logger';
import { Push } from '@/push';
import { ActiveWorkflowManager } from '@/active-workflow-manager';
import { mockInstance } from '@test/mocking';
@ -47,7 +46,6 @@ const workerRestartEventBusResponse: RedisServiceWorkerResponseObject = {
};
describe('Orchestration Service', () => {
const logger = mockInstance(Logger);
mockInstance(Push);
mockInstance(RedisService);
mockInstance(ExternalSecretsManager);
@ -112,7 +110,6 @@ describe('Orchestration Service', () => {
expect(responseFalseId).toBeDefined();
expect(responseFalseId!.command).toEqual('reloadLicense');
expect(responseFalseId!.senderId).toEqual('test');
expect(logger.error).toHaveBeenCalled();
});
test('should reject command messages from itself', async () => {

View file

@ -53,11 +53,7 @@ export async function handleCommandMessageMain(messageString: string) {
}
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
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;
return message; // this main is the sender, so disregard
}
await Container.get(License).reload();
break;