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

[Ingest Manager] Fix agent tests and short polling timeout #79442

Merged
merged 2 commits into from
Oct 5, 2020
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
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 @@ -123,7 +128,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