From 3608e4de507020d1783a7cbbfd4078f892682a60 Mon Sep 17 00:00:00 2001 From: Tim Sullivan Date: Mon, 18 Mar 2024 13:09:05 -0700 Subject: [PATCH] [Reporting/storage] set refresh=wait_for in indexing and update calls (#178783) ## Summary Addresses https://github.com/elastic/kibana/pull/176022#discussion_r1516566703 This is done in a standalone PR to minimize changes needed to convert Reporting storage to use a Data Stream. Useful for https://github.com/elastic/kibana/pull/176022. --- x-pack/plugins/reporting/server/lib/store/store.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/reporting/server/lib/store/store.ts b/x-pack/plugins/reporting/server/lib/store/store.ts index c2246441c29f6..d88f8ca9096bb 100644 --- a/x-pack/plugins/reporting/server/lib/store/store.ts +++ b/x-pack/plugins/reporting/server/lib/store/store.ts @@ -73,7 +73,7 @@ const sourceDoc = (doc: Partial): Partial => { }; }; -const esDoc = ( +const esDocForUpdate = ( report: SavedReport, doc: Partial ): Parameters[0] => { @@ -82,7 +82,7 @@ const esDoc = ( index: report._index, if_seq_no: report._seq_no, if_primary_term: report._primary_term, - refresh: false, + refresh: 'wait_for' as estypes.Refresh, body: { doc }, }; }; @@ -178,7 +178,7 @@ export class ReportingStore { const doc = { index: report._index!, id: report._id, - refresh: false, + refresh: 'wait_for' as estypes.Refresh, body: { ...report.toReportSource(), ...sourceDoc({ @@ -309,7 +309,7 @@ export class ReportingStore { let body: UpdateResponse; try { const client = await this.getClient(); - body = await client.update(esDoc(report, doc)); + body = await client.update(esDocForUpdate(report, doc)); } catch (err) { this.logError(`Error in updating status to processing! Report: ${jobDebugMessage(report)}`, err, report); // prettier-ignore throw err; @@ -341,7 +341,7 @@ export class ReportingStore { let body: UpdateResponse; try { const client = await this.getClient(); - body = await client.update(esDoc(report, doc)); + body = await client.update(esDocForUpdate(report, doc)); } catch (err) { this.logError(`Error in updating status to failed! Report: ${jobDebugMessage(report)}`, err, report); // prettier-ignore throw err; @@ -363,7 +363,7 @@ export class ReportingStore { let body: UpdateResponse; try { const client = await this.getClient(); - body = await client.update(esDoc(report, doc)); + body = await client.update(esDocForUpdate(report, doc)); } catch (err) { this.logError(`Error in updating status to failed! Report: ${jobDebugMessage(report)}`, err, report); // prettier-ignore throw err; @@ -391,7 +391,7 @@ export class ReportingStore { let body: UpdateResponse; try { const client = await this.getClient(); - body = await client.update(esDoc(report, doc)); + body = await client.update(esDocForUpdate(report, doc)); } catch (err) { this.logError(`Error in updating status to complete! Report: ${jobDebugMessage(report)}`, err, report); // prettier-ignore throw err;