Skip to content

Commit

Permalink
[Ingest Manager] Fix agent tests and short polling timeout (#79442) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet authored Oct 5, 2020
1 parent b6d3f33 commit 5236d76
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
10 changes: 8 additions & 2 deletions x-pack/plugins/ingest_manager/server/routes/agent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@

import { IRouter, RouteValidationResultFactory } from 'src/core/server';
import Ajv from 'ajv';
import { PLUGIN_ID, AGENT_API_ROUTES, LIMITED_CONCURRENCY_ROUTE_TAG } from '../../constants';
import {
PLUGIN_ID,
AGENT_API_ROUTES,
LIMITED_CONCURRENCY_ROUTE_TAG,
AGENT_POLLING_REQUEST_TIMEOUT_MARGIN_MS,
} from '../../constants';
import {
GetAgentsRequestSchema,
GetOneAgentRequestSchema,
Expand Down Expand Up @@ -124,7 +129,8 @@ export const registerRoutes = (router: IRouter, config: IngestManagerConfigType)
},
options: {
tags: [],
...(pollingRequestTimeout
// If the timeout is too short, do not set socket idle timeout and rely on Kibana global socket timeout
...(pollingRequestTimeout && pollingRequestTimeout > AGENT_POLLING_REQUEST_TIMEOUT_MARGIN_MS
? {
timeout: {
idleSocket: pollingRequestTimeout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ export async function createAgentActionFromPolicyAction(

function getPollingTimeoutMs() {
const pollingTimeoutMs = appContextService.getConfig()?.fleet.pollingRequestTimeout ?? 0;

// If polling timeout is too short do not use margin
if (pollingTimeoutMs <= AGENT_POLLING_REQUEST_TIMEOUT_MARGIN_MS) {
return pollingTimeoutMs;
}

// Set a timeout 20s before the real timeout to have a chance to respond an empty response before socket timeout
return Math.max(
pollingTimeoutMs - AGENT_POLLING_REQUEST_TIMEOUT_MARGIN_MS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export default function (providerContext: FtrProviderContext) {
const supertestWithoutAuth = getSupertestWithoutAuth(providerContext);
const esClient = getService('es');

// Failing: See https://github.com/elastic/kibana/issues/75241
describe.skip('fleet_agent_flow', () => {
describe('fleet_agent_flow', () => {
skipIfNoDockerRegistry(providerContext);
before(async () => {
await esArchiver.load('empty_kibana');
Expand Down

0 comments on commit 5236d76

Please sign in to comment.