From cebcc3a2295e6a4eb02e790114c18ce4790cbe25 Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Wed, 19 Aug 2020 07:49:08 -0400 Subject: [PATCH] [Ingest Manager] Fix agent config rollout rate limit to use constants (#75364) --- .../ingest_manager/common/constants/agent.ts | 4 ++-- .../ingest_manager/server/constants/index.ts | 4 ++-- x-pack/plugins/ingest_manager/server/index.ts | 12 ++++++++++-- .../services/agents/checkin/state_new_actions.ts | 13 ++++++++++--- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/ingest_manager/common/constants/agent.ts b/x-pack/plugins/ingest_manager/common/constants/agent.ts index 7652c6ac87bce..d94f536b5659a 100644 --- a/x-pack/plugins/ingest_manager/common/constants/agent.ts +++ b/x-pack/plugins/ingest_manager/common/constants/agent.ts @@ -17,5 +17,5 @@ export const AGENT_POLLING_INTERVAL = 1000; export const AGENT_UPDATE_LAST_CHECKIN_INTERVAL_MS = 30000; export const AGENT_UPDATE_ACTIONS_INTERVAL_MS = 5000; -export const AGENT_CONFIG_ROLLUP_RATE_LIMIT_INTERVAL_MS = 5000; -export const AGENT_CONFIG_ROLLUP_RATE_LIMIT_REQUEST_PER_INTERVAL = 60; +export const AGENT_CONFIG_ROLLOUT_RATE_LIMIT_INTERVAL_MS = 5000; +export const AGENT_CONFIG_ROLLOUT_RATE_LIMIT_REQUEST_PER_INTERVAL = 25; diff --git a/x-pack/plugins/ingest_manager/server/constants/index.ts b/x-pack/plugins/ingest_manager/server/constants/index.ts index 1ec13bd80f0fb..730d8cf7b172c 100644 --- a/x-pack/plugins/ingest_manager/server/constants/index.ts +++ b/x-pack/plugins/ingest_manager/server/constants/index.ts @@ -10,8 +10,8 @@ export { AGENT_POLLING_THRESHOLD_MS, AGENT_POLLING_INTERVAL, AGENT_UPDATE_LAST_CHECKIN_INTERVAL_MS, - AGENT_CONFIG_ROLLUP_RATE_LIMIT_REQUEST_PER_INTERVAL, - AGENT_CONFIG_ROLLUP_RATE_LIMIT_INTERVAL_MS, + AGENT_CONFIG_ROLLOUT_RATE_LIMIT_REQUEST_PER_INTERVAL, + AGENT_CONFIG_ROLLOUT_RATE_LIMIT_INTERVAL_MS, AGENT_UPDATE_ACTIONS_INTERVAL_MS, INDEX_PATTERN_PLACEHOLDER_SUFFIX, // Routes diff --git a/x-pack/plugins/ingest_manager/server/index.ts b/x-pack/plugins/ingest_manager/server/index.ts index e2f659f54d625..9933266a441e2 100644 --- a/x-pack/plugins/ingest_manager/server/index.ts +++ b/x-pack/plugins/ingest_manager/server/index.ts @@ -6,6 +6,10 @@ import { schema, TypeOf } from '@kbn/config-schema'; import { PluginInitializerContext } from 'src/core/server'; import { IngestManagerPlugin } from './plugin'; +import { + AGENT_CONFIG_ROLLOUT_RATE_LIMIT_INTERVAL_MS, + AGENT_CONFIG_ROLLOUT_RATE_LIMIT_REQUEST_PER_INTERVAL, +} from '../common'; export { AgentService, ESIndexPatternService, getRegistryUrl } from './services'; export { IngestManagerSetupContract, @@ -35,8 +39,12 @@ export const config = { host: schema.maybe(schema.string()), ca_sha256: schema.maybe(schema.string()), }), - agentConfigRolloutRateLimitIntervalMs: schema.number({ defaultValue: 5000 }), - agentConfigRolloutRateLimitRequestPerInterval: schema.number({ defaultValue: 5 }), + agentConfigRolloutRateLimitIntervalMs: schema.number({ + defaultValue: AGENT_CONFIG_ROLLOUT_RATE_LIMIT_INTERVAL_MS, + }), + agentConfigRolloutRateLimitRequestPerInterval: schema.number({ + defaultValue: AGENT_CONFIG_ROLLOUT_RATE_LIMIT_REQUEST_PER_INTERVAL, + }), }), }), }; diff --git a/x-pack/plugins/ingest_manager/server/services/agents/checkin/state_new_actions.ts b/x-pack/plugins/ingest_manager/server/services/agents/checkin/state_new_actions.ts index 1547b6b5ea053..418b59e1ca2e9 100644 --- a/x-pack/plugins/ingest_manager/server/services/agents/checkin/state_new_actions.ts +++ b/x-pack/plugins/ingest_manager/server/services/agents/checkin/state_new_actions.ts @@ -25,7 +25,12 @@ import { } from '../../../types'; import { agentConfigService } from '../../agent_config'; import * as APIKeysService from '../../api_keys'; -import { AGENT_SAVED_OBJECT_TYPE, AGENT_UPDATE_ACTIONS_INTERVAL_MS } from '../../../constants'; +import { + AGENT_SAVED_OBJECT_TYPE, + AGENT_UPDATE_ACTIONS_INTERVAL_MS, + AGENT_CONFIG_ROLLOUT_RATE_LIMIT_INTERVAL_MS, + AGENT_CONFIG_ROLLOUT_RATE_LIMIT_REQUEST_PER_INTERVAL, +} from '../../../constants'; import { createAgentAction, getNewActionsSince } from '../actions'; import { appContextService } from '../../app_context'; import { toPromiseAbortable, AbortError, createRateLimiter } from './rxjs_utils'; @@ -135,8 +140,10 @@ export function agentCheckinStateNewActionsFactory() { const newActions$ = createNewActionsSharedObservable(); // Rx operators const rateLimiter = createRateLimiter( - appContextService.getConfig()?.fleet.agentConfigRolloutRateLimitIntervalMs ?? 5000, - appContextService.getConfig()?.fleet.agentConfigRolloutRateLimitRequestPerInterval ?? 50 + appContextService.getConfig()?.fleet.agentConfigRolloutRateLimitIntervalMs ?? + AGENT_CONFIG_ROLLOUT_RATE_LIMIT_INTERVAL_MS, + appContextService.getConfig()?.fleet.agentConfigRolloutRateLimitRequestPerInterval ?? + AGENT_CONFIG_ROLLOUT_RATE_LIMIT_REQUEST_PER_INTERVAL ); async function subscribeToNewActions(