From 155bdd02af3418d4b5d2228ea034d12c9146f934 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Tue, 24 Dec 2024 20:23:14 +0000 Subject: [PATCH] [ML] File upload fixing inference timeout check (#204722) Fixes issue in serverless where the inference call to deploy elser times out, which is expected, but returns with an unexpected `500` error code. This causes the UI to stop the upload process. ![image](https://github.com/user-attachments/assets/57b3007f-5a67-4c99-b6bd-360c7b5b788f) This PR increases the timeout length to 10mins and allows for `500` errors just in case. Testing this shows that with the extra timeout time in kibana, another timeout happens at 1min but this returns with an expected `408`. Therefore allowing for `500`s might not be needed, but I don't think there is any harm. --- .../components/import_view/auto_deploy.ts | 2 +- .../plugins/private/data_visualizer/server/routes.ts | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/x-pack/platform/plugins/private/data_visualizer/public/application/file_data_visualizer/components/import_view/auto_deploy.ts b/x-pack/platform/plugins/private/data_visualizer/public/application/file_data_visualizer/components/import_view/auto_deploy.ts index a402d203585d2..10389f48d149e 100644 --- a/x-pack/platform/plugins/private/data_visualizer/public/application/file_data_visualizer/components/import_view/auto_deploy.ts +++ b/x-pack/platform/plugins/private/data_visualizer/public/application/file_data_visualizer/components/import_view/auto_deploy.ts @@ -26,7 +26,7 @@ export class AutoDeploy { // we'll know when it's ready from polling the inference endpoints // looking for num_allocations const status = e.response?.status; - if (status === 408 || status === 504 || status === 502) { + if (status === 408 || status === 504 || status === 502 || status === 500) { return; } this.inferError = e; diff --git a/x-pack/platform/plugins/private/data_visualizer/server/routes.ts b/x-pack/platform/plugins/private/data_visualizer/server/routes.ts index 9d213182ad049..244c839b1e9fc 100644 --- a/x-pack/platform/plugins/private/data_visualizer/server/routes.ts +++ b/x-pack/platform/plugins/private/data_visualizer/server/routes.ts @@ -145,10 +145,13 @@ export function routes(coreSetup: CoreSetup, logger: Logger) const inferenceId = request.params.inferenceId; const input = request.body.input; const esClient = (await context.core).elasticsearch.client; - const body = await esClient.asCurrentUser.inference.inference({ - inference_id: inferenceId, - input, - }); + const body = await esClient.asCurrentUser.inference.inference( + { + inference_id: inferenceId, + input, + }, + { maxRetries: 0, requestTimeout: 10 * 60 * 1000 } + ); return response.ok({ body }); } catch (e) {