feat(core): Add secrets provider reload and refactor (#7277)
This PR adds a message for queue mode which triggers an external secrets provider reload inside the workers if the configuration has changed on the main instance. It also refactors some of the message handler code to remove cyclic dependencies, as well as remove unnecessary duplicate redis clients inside services (thanks to no more cyclic deps)
This commit is contained in:
committed by
GitHub
parent
a80abad3af
commit
53a7502d20
@@ -6,6 +6,7 @@ import * as os from 'os';
|
||||
import Container from 'typedi';
|
||||
import { License } from '@/License';
|
||||
import { MessageEventBus } from '../eventbus/MessageEventBus/MessageEventBus';
|
||||
import { ExternalSecretsManager } from '../ExternalSecrets/ExternalSecretsManager.ee';
|
||||
|
||||
export function getWorkerCommandReceivedHandler(options: {
|
||||
queueModeId: string;
|
||||
@@ -26,6 +27,9 @@ export function getWorkerCommandReceivedHandler(options: {
|
||||
return;
|
||||
}
|
||||
if (message) {
|
||||
LoggerProxy.debug(
|
||||
`RedisCommandHandler(worker): Received command message ${message.command} from ${message.senderId}`,
|
||||
);
|
||||
if (message.targets && !message.targets.includes(options.queueModeId)) {
|
||||
return; // early return if the message is not for this worker
|
||||
}
|
||||
@@ -59,14 +63,46 @@ export function getWorkerCommandReceivedHandler(options: {
|
||||
});
|
||||
break;
|
||||
case 'restartEventBus':
|
||||
await Container.get(MessageEventBus).restart();
|
||||
await options.redisPublisher.publishToWorkerChannel({
|
||||
workerId: options.queueModeId,
|
||||
command: message.command,
|
||||
payload: {
|
||||
result: 'success',
|
||||
},
|
||||
});
|
||||
try {
|
||||
await Container.get(MessageEventBus).restart();
|
||||
await options.redisPublisher.publishToWorkerChannel({
|
||||
workerId: options.queueModeId,
|
||||
command: message.command,
|
||||
payload: {
|
||||
result: 'success',
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
await options.redisPublisher.publishToWorkerChannel({
|
||||
workerId: options.queueModeId,
|
||||
command: message.command,
|
||||
payload: {
|
||||
result: 'error',
|
||||
error: (error as Error).message,
|
||||
},
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'reloadExternalSecretsProviders':
|
||||
try {
|
||||
await Container.get(ExternalSecretsManager).reloadAllProviders();
|
||||
await options.redisPublisher.publishToWorkerChannel({
|
||||
workerId: options.queueModeId,
|
||||
command: message.command,
|
||||
payload: {
|
||||
result: 'success',
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
await options.redisPublisher.publishToWorkerChannel({
|
||||
workerId: options.queueModeId,
|
||||
command: message.command,
|
||||
payload: {
|
||||
result: 'error',
|
||||
error: (error as Error).message,
|
||||
},
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'reloadLicense':
|
||||
await Container.get(License).reload();
|
||||
|
||||
Reference in New Issue
Block a user