diff --git a/x-pack/plugins/ingest_manager/common/constants/agent.ts b/x-pack/plugins/ingest_manager/common/constants/agent.ts index f3990ba78c5391..e9226fa6849253 100644 --- a/x-pack/plugins/ingest_manager/common/constants/agent.ts +++ b/x-pack/plugins/ingest_manager/common/constants/agent.ts @@ -14,3 +14,5 @@ export const AGENT_TYPE_TEMPORARY = 'TEMPORARY'; export const AGENT_POLLING_THRESHOLD_MS = 30000; export const AGENT_POLLING_INTERVAL = 1000; +export const AGENT_UPDATE_LAST_CHECKIN_INTERVAL_MS = 30000; +export const AGENT_UPDATE_ACTIONS_INTERVAL_MS = 5000; diff --git a/x-pack/plugins/ingest_manager/package.json b/x-pack/plugins/ingest_manager/package.json index 052d3d0b42c7e6..8826ed57ab1067 100644 --- a/x-pack/plugins/ingest_manager/package.json +++ b/x-pack/plugins/ingest_manager/package.json @@ -3,5 +3,8 @@ "name": "ingest-manager", "version": "8.0.0", "private": true, - "license": "Elastic-License" + "license": "Elastic-License", + "dependencies": { + "abort-controller": "^3.0.0" + } } diff --git a/x-pack/plugins/ingest_manager/server/constants/index.ts b/x-pack/plugins/ingest_manager/server/constants/index.ts index 6e633c04ed8169..4d60b9031414ee 100644 --- a/x-pack/plugins/ingest_manager/server/constants/index.ts +++ b/x-pack/plugins/ingest_manager/server/constants/index.ts @@ -9,6 +9,8 @@ export { AGENT_TYPE_TEMPORARY, AGENT_POLLING_THRESHOLD_MS, AGENT_POLLING_INTERVAL, + AGENT_UPDATE_LAST_CHECKIN_INTERVAL_MS, + AGENT_UPDATE_ACTIONS_INTERVAL_MS, INDEX_PATTERN_PLACEHOLDER_SUFFIX, // Routes PLUGIN_ID, diff --git a/x-pack/plugins/ingest_manager/server/services/agents/checkin/state.ts b/x-pack/plugins/ingest_manager/server/services/agents/checkin/state.ts index df427ff26f200f..cb459e863241d9 100644 --- a/x-pack/plugins/ingest_manager/server/services/agents/checkin/state.ts +++ b/x-pack/plugins/ingest_manager/server/services/agents/checkin/state.ts @@ -9,8 +9,7 @@ import { Agent } from '../../../types'; import { appContextService } from '../../app_context'; import { agentCheckinStateConnectedAgentsFactory } from './state_connected_agents'; import { agentCheckinStateNewActionsFactory } from './state_new_actions'; - -const UPDATE_LAST_CHECKIN_INTERVAL_MS = 15000; +import { AGENT_UPDATE_LAST_CHECKIN_INTERVAL_MS } from '../../../constants'; function agentCheckinStateFactory() { const agentConnected = agentCheckinStateConnectedAgentsFactory(); @@ -23,7 +22,7 @@ function agentCheckinStateFactory() { } catch (err) { appContextService.getLogger().error(err); } - }, UPDATE_LAST_CHECKIN_INTERVAL_MS); + }, AGENT_UPDATE_LAST_CHECKIN_INTERVAL_MS); } return { 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 ee736f7406a4e2..0f30ab409f3810 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,13 +25,11 @@ import { } from '../../../types'; import { agentConfigService } from '../../agent_config'; import * as APIKeysService from '../../api_keys'; -import { AGENT_SAVED_OBJECT_TYPE } from '../../../constants'; +import { AGENT_SAVED_OBJECT_TYPE, AGENT_UPDATE_ACTIONS_INTERVAL_MS } from '../../../constants'; import { createAgentAction, getNewActionsSince } from '../actions'; import { appContextService } from '../../app_context'; import { toPromiseAbortable, AbortError } from './rxjs_utils'; -const UPDATE_ACTIONS_INTERVAL_MS = 10000; - function getInternalUserSOClient() { const fakeRequest = ({ headers: {}, @@ -53,7 +51,7 @@ function getInternalUserSOClient() { function createAgentConfigSharedObservable(configId: string) { const internalSOClient = getInternalUserSOClient(); - return timer(0, UPDATE_ACTIONS_INTERVAL_MS).pipe( + return timer(0, AGENT_UPDATE_ACTIONS_INTERVAL_MS).pipe( switchMap(() => from(agentConfigService.get(internalSOClient, configId) as Promise) ), @@ -64,7 +62,7 @@ function createAgentConfigSharedObservable(configId: string) { } function createNewActionsSharedObservable(): Observable { - return timer(0, UPDATE_ACTIONS_INTERVAL_MS).pipe( + return timer(0, AGENT_UPDATE_ACTIONS_INTERVAL_MS).pipe( switchMap(() => { const internalSOClient = getInternalUserSOClient(); diff --git a/yarn.lock b/yarn.lock index 14e4cdd62955a1..464c3b7ae0cf8e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6398,6 +6398,13 @@ abort-controller@^2.0.3: dependencies: event-target-shim "^5.0.0" +abort-controller@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" + integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== + dependencies: + event-target-shim "^5.0.0" + abortcontroller-polyfill@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.4.0.tgz#0d5eb58e522a461774af8086414f68e1dda7a6c4"