mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Adds { maxRetries: 0 } to some transform related API calls (esp. preview) to avoid performance problem in case of retries.
(cherry picked from commit acf3895932
)
Co-authored-by: Walter Rafelsberger <walter.rafelsberger@elastic.co>
This commit is contained in:
parent
e2b8580dec
commit
d08f3d6b6b
1 changed files with 28 additions and 16 deletions
|
@ -155,10 +155,13 @@ export function registerTransformsRoutes(routeDependencies: RouteDependencies) {
|
||||||
async (ctx, req, res) => {
|
async (ctx, req, res) => {
|
||||||
try {
|
try {
|
||||||
const esClient = (await ctx.core).elasticsearch.client;
|
const esClient = (await ctx.core).elasticsearch.client;
|
||||||
const body = await esClient.asCurrentUser.transform.getTransformStats({
|
const body = await esClient.asCurrentUser.transform.getTransformStats(
|
||||||
size: 1000,
|
{
|
||||||
transform_id: '_all',
|
size: 1000,
|
||||||
});
|
transform_id: '_all',
|
||||||
|
},
|
||||||
|
{ maxRetries: 0 }
|
||||||
|
);
|
||||||
return res.ok({ body });
|
return res.ok({ body });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return res.customError(wrapError(wrapEsError(e)));
|
return res.customError(wrapError(wrapEsError(e)));
|
||||||
|
@ -185,9 +188,12 @@ export function registerTransformsRoutes(routeDependencies: RouteDependencies) {
|
||||||
const { transformId } = req.params;
|
const { transformId } = req.params;
|
||||||
try {
|
try {
|
||||||
const esClient = (await ctx.core).elasticsearch.client;
|
const esClient = (await ctx.core).elasticsearch.client;
|
||||||
const body = await esClient.asCurrentUser.transform.getTransformStats({
|
const body = await esClient.asCurrentUser.transform.getTransformStats(
|
||||||
transform_id: transformId,
|
{
|
||||||
});
|
transform_id: transformId,
|
||||||
|
},
|
||||||
|
{ maxRetries: 0 }
|
||||||
|
);
|
||||||
return res.ok({ body });
|
return res.ok({ body });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return res.customError(wrapError(wrapEsError(e)));
|
return res.customError(wrapError(wrapEsError(e)));
|
||||||
|
@ -452,7 +458,7 @@ export function registerTransformsRoutes(routeDependencies: RouteDependencies) {
|
||||||
license.guardApiRoute(async (ctx, req, res) => {
|
license.guardApiRoute(async (ctx, req, res) => {
|
||||||
try {
|
try {
|
||||||
const esClient = (await ctx.core).elasticsearch.client;
|
const esClient = (await ctx.core).elasticsearch.client;
|
||||||
const body = await esClient.asCurrentUser.search(req.body);
|
const body = await esClient.asCurrentUser.search(req.body, { maxRetries: 0 });
|
||||||
return res.ok({ body });
|
return res.ok({ body });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return res.customError(wrapError(wrapEsError(e)));
|
return res.customError(wrapError(wrapEsError(e)));
|
||||||
|
@ -643,16 +649,22 @@ const previewTransformHandler: RequestHandler<
|
||||||
try {
|
try {
|
||||||
const reqBody = req.body;
|
const reqBody = req.body;
|
||||||
const esClient = (await ctx.core).elasticsearch.client;
|
const esClient = (await ctx.core).elasticsearch.client;
|
||||||
const body = await esClient.asCurrentUser.transform.previewTransform({
|
const body = await esClient.asCurrentUser.transform.previewTransform(
|
||||||
body: reqBody,
|
{
|
||||||
});
|
body: reqBody,
|
||||||
|
},
|
||||||
|
{ maxRetries: 0 }
|
||||||
|
);
|
||||||
if (isLatestTransform(reqBody)) {
|
if (isLatestTransform(reqBody)) {
|
||||||
// for the latest transform mappings properties have to be retrieved from the source
|
// for the latest transform mappings properties have to be retrieved from the source
|
||||||
const fieldCapsResponse = await esClient.asCurrentUser.fieldCaps({
|
const fieldCapsResponse = await esClient.asCurrentUser.fieldCaps(
|
||||||
index: reqBody.source.index,
|
{
|
||||||
fields: '*',
|
index: reqBody.source.index,
|
||||||
include_unmapped: false,
|
fields: '*',
|
||||||
});
|
include_unmapped: false,
|
||||||
|
},
|
||||||
|
{ maxRetries: 0 }
|
||||||
|
);
|
||||||
|
|
||||||
const fieldNamesSet = new Set(Object.keys(fieldCapsResponse.fields));
|
const fieldNamesSet = new Set(Object.keys(fieldCapsResponse.fields));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue