Skip to content

Commit

Permalink
[Ingest Manager] Fix agent config rollout rate limit to use constants (
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet authored Aug 19, 2020
1 parent 37f4f28 commit cebcc3a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/ingest_manager/common/constants/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 2 additions & 2 deletions x-pack/plugins/ingest_manager/server/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions x-pack/plugins/ingest_manager/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
}),
}),
}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit cebcc3a

Please sign in to comment.