Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Add config option for external secret update interval #7995

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions packages/cli/src/ExternalSecrets/ExternalSecretsManager.ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ import Container, { Service } from 'typedi';
import { Logger } from '@/Logger';

import { jsonParse, type IDataObject, ApplicationError } from 'n8n-workflow';
import {
EXTERNAL_SECRETS_INITIAL_BACKOFF,
EXTERNAL_SECRETS_MAX_BACKOFF,
EXTERNAL_SECRETS_UPDATE_INTERVAL,
} from './constants';
import { EXTERNAL_SECRETS_INITIAL_BACKOFF, EXTERNAL_SECRETS_MAX_BACKOFF } from './constants';
import { License } from '@/License';
import { InternalHooks } from '@/InternalHooks';
import { updateIntervalTime } from './externalSecretsHelper.ee';
import { ExternalSecretsProviders } from './ExternalSecretsProviders.ee';
import { SingleMainSetup } from '@/services/orchestration/main/SingleMainSetup';

Expand Down Expand Up @@ -51,10 +48,7 @@ export class ExternalSecretsManager {
this.initialized = true;
resolve();
this.initializingPromise = undefined;
this.updateInterval = setInterval(
async () => this.updateSecrets(),
EXTERNAL_SECRETS_UPDATE_INTERVAL,
);
this.updateInterval = setInterval(async () => this.updateSecrets(), updateIntervalTime());
});
}
return this.initializingPromise;
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/ExternalSecrets/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const EXTERNAL_SECRETS_DB_KEY = 'feature.externalSecrets';
export const EXTERNAL_SECRETS_UPDATE_INTERVAL = 5 * 60 * 1000;
export const EXTERNAL_SECRETS_INITIAL_BACKOFF = 10 * 1000;
export const EXTERNAL_SECRETS_MAX_BACKOFF = 5 * 60 * 1000;

Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/ExternalSecrets/externalSecretsHelper.ee.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { License } from '@/License';
import config from '@/config';
import Container from 'typedi';

export const updateIntervalTime = () => config.getEnv('externalSecrets.updateInterval') * 1000;

export function isExternalSecretsEnabled() {
const license = Container.get(License);
return license.isExternalSecretsEnabled();
Expand Down
9 changes: 9 additions & 0 deletions packages/cli/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,15 @@ export const schema = {
},
},

externalSecrets: {
updateInterval: {
format: Number,
default: 300,
env: 'N8N_EXTERNAL_SECRETS_UPDATE_INTERVAL',
doc: 'How often (in seconds) to check for secret updates.',
},
},

deployment: {
type: {
format: String,
Expand Down
Loading