refactor: Rename disabled to enabled in runner config (#11621)

This commit is contained in:
Tomi Turtiainen 2024-11-07 14:22:43 +02:00 committed by GitHub
parent 0c13ad612d
commit d25ae8e0d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 14 additions and 15 deletions

View file

@ -10,9 +10,8 @@ export type TaskRunnerMode = 'internal_childprocess' | 'internal_launcher' | 'ex
@Config @Config
export class TaskRunnersConfig { export class TaskRunnersConfig {
// Defaults to true for now @Env('N8N_RUNNERS_ENABLED')
@Env('N8N_RUNNERS_DISABLED') enabled: boolean = false;
disabled: boolean = true;
// Defaults to true for now // Defaults to true for now
@Env('N8N_RUNNERS_MODE') @Env('N8N_RUNNERS_MODE')

View file

@ -222,7 +222,7 @@ describe('GlobalConfig', () => {
}, },
}, },
taskRunners: { taskRunners: {
disabled: true, enabled: false,
mode: 'internal_childprocess', mode: 'internal_childprocess',
path: '/runners', path: '/runners',
authToken: '', authToken: '',

View file

@ -221,7 +221,7 @@ export class Start extends BaseCommand {
} }
const { taskRunners: taskRunnerConfig } = this.globalConfig; const { taskRunners: taskRunnerConfig } = this.globalConfig;
if (!taskRunnerConfig.disabled) { if (taskRunnerConfig.enabled) {
const { TaskRunnerModule } = await import('@/runners/task-runner-module'); const { TaskRunnerModule } = await import('@/runners/task-runner-module');
const taskRunnerModule = Container.get(TaskRunnerModule); const taskRunnerModule = Container.get(TaskRunnerModule);
await taskRunnerModule.start(); await taskRunnerModule.start();

View file

@ -113,7 +113,7 @@ export class Worker extends BaseCommand {
); );
const { taskRunners: taskRunnerConfig } = this.globalConfig; const { taskRunners: taskRunnerConfig } = this.globalConfig;
if (!taskRunnerConfig.disabled) { if (taskRunnerConfig.enabled) {
const { TaskRunnerModule } = await import('@/runners/task-runner-module'); const { TaskRunnerModule } = await import('@/runners/task-runner-module');
const taskRunnerModule = Container.get(TaskRunnerModule); const taskRunnerModule = Container.get(TaskRunnerModule);
await taskRunnerModule.start(); await taskRunnerModule.start();

View file

@ -22,7 +22,7 @@ require('child_process').spawn = spawnMock;
describe('TaskRunnerProcess', () => { describe('TaskRunnerProcess', () => {
const logger = mockInstance(Logger); const logger = mockInstance(Logger);
const runnerConfig = mockInstance(TaskRunnersConfig); const runnerConfig = mockInstance(TaskRunnersConfig);
runnerConfig.disabled = false; runnerConfig.enabled = true;
runnerConfig.mode = 'internal_childprocess'; runnerConfig.mode = 'internal_childprocess';
const authService = mock<TaskRunnerAuthService>(); const authService = mock<TaskRunnerAuthService>();
let taskRunnerProcess = new TaskRunnerProcess(logger, runnerConfig, authService); let taskRunnerProcess = new TaskRunnerProcess(logger, runnerConfig, authService);

View file

@ -26,7 +26,7 @@ export class TaskRunnerModule {
constructor(private readonly runnerConfig: TaskRunnersConfig) {} constructor(private readonly runnerConfig: TaskRunnersConfig) {}
async start() { async start() {
a.ok(!this.runnerConfig.disabled, 'Task runner is disabled'); a.ok(this.runnerConfig.enabled, 'Task runner is disabled');
await this.loadTaskManager(); await this.loadTaskManager();
await this.loadTaskRunnerServer(); await this.loadTaskRunnerServer();

View file

@ -26,7 +26,7 @@ import { mockInstance } from '../../shared/mocking';
config.set('executions.mode', 'queue'); config.set('executions.mode', 'queue');
config.set('binaryDataManager.availableModes', 'filesystem'); config.set('binaryDataManager.availableModes', 'filesystem');
Container.get(TaskRunnersConfig).disabled = false; Container.get(TaskRunnersConfig).enabled = true;
mockInstance(LoadNodesAndCredentials); mockInstance(LoadNodesAndCredentials);
const binaryDataService = mockInstance(BinaryDataService); const binaryDataService = mockInstance(BinaryDataService);
const externalHooks = mockInstance(ExternalHooks); const externalHooks = mockInstance(ExternalHooks);

View file

@ -18,14 +18,14 @@ describe('TaskRunnerModule in external mode', () => {
describe('start', () => { describe('start', () => {
it('should throw if the task runner is disabled', async () => { it('should throw if the task runner is disabled', async () => {
runnerConfig.disabled = true; runnerConfig.enabled = false;
// Act // Act
await expect(module.start()).rejects.toThrow('Task runner is disabled'); await expect(module.start()).rejects.toThrow('Task runner is disabled');
}); });
it('should start the task runner', async () => { it('should start the task runner', async () => {
runnerConfig.disabled = false; runnerConfig.enabled = true;
// Act // Act
await module.start(); await module.start();

View file

@ -18,14 +18,14 @@ describe('TaskRunnerModule in internal_childprocess mode', () => {
describe('start', () => { describe('start', () => {
it('should throw if the task runner is disabled', async () => { it('should throw if the task runner is disabled', async () => {
runnerConfig.disabled = true; runnerConfig.enabled = false;
// Act // Act
await expect(module.start()).rejects.toThrow('Task runner is disabled'); await expect(module.start()).rejects.toThrow('Task runner is disabled');
}); });
it('should start the task runner', async () => { it('should start the task runner', async () => {
runnerConfig.disabled = false; runnerConfig.enabled = true;
// Act // Act
await module.start(); await module.start();

View file

@ -10,7 +10,7 @@ import { retryUntil } from '@test-integration/retry-until';
describe('TaskRunnerProcess', () => { describe('TaskRunnerProcess', () => {
const authToken = 'token'; const authToken = 'token';
const runnerConfig = Container.get(TaskRunnersConfig); const runnerConfig = Container.get(TaskRunnersConfig);
runnerConfig.disabled = false; runnerConfig.enabled = true;
runnerConfig.mode = 'internal_childprocess'; runnerConfig.mode = 'internal_childprocess';
runnerConfig.authToken = authToken; runnerConfig.authToken = authToken;
runnerConfig.port = 0; // Use any port runnerConfig.port = 0; // Use any port

View file

@ -108,7 +108,7 @@ export class Code implements INodeType {
: 'javaScript'; : 'javaScript';
const codeParameterName = language === 'python' ? 'pythonCode' : 'jsCode'; const codeParameterName = language === 'python' ? 'pythonCode' : 'jsCode';
if (!runnersConfig.disabled && language === 'javaScript') { if (runnersConfig.enabled && language === 'javaScript') {
const code = this.getNodeParameter(codeParameterName, 0) as string; const code = this.getNodeParameter(codeParameterName, 0) as string;
const sandbox = new JsTaskRunnerSandbox(code, nodeMode, workflowMode, this); const sandbox = new JsTaskRunnerSandbox(code, nodeMode, workflowMode, this);