[Reporting CSV] Fix scroll ID bug for deprecated csv export (#106892)

* [Reporting CSV] Fix scroll ID bug for deprecated csv export

* fix unit test

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Tim Sullivan 2021-07-30 08:17:29 -07:00 committed by GitHub
parent 5294f1ca17
commit 03ca8c7d35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

View file

@ -175,7 +175,7 @@ describe('CSV Execute Job', function () {
);
expect(mockEsClient.scroll).toHaveBeenCalledWith(
expect.objectContaining({ scroll_id: scrollId })
expect.objectContaining({ body: { scroll_id: scrollId } })
);
});
@ -261,7 +261,7 @@ describe('CSV Execute Job', function () {
);
expect(mockEsClient.clearScroll).toHaveBeenCalledWith(
expect.objectContaining({ scroll_id: lastScrollId })
expect.objectContaining({ body: { scroll_id: lastScrollId } })
);
});
@ -295,7 +295,7 @@ describe('CSV Execute Job', function () {
);
expect(mockEsClient.clearScroll).toHaveBeenCalledWith(
expect.objectContaining({ scroll_id: lastScrollId })
expect.objectContaining({ body: { scroll_id: lastScrollId } })
);
});
});
@ -753,7 +753,7 @@ describe('CSV Execute Job', function () {
expect(mockEsClient.clearScroll).toHaveBeenCalledWith(
expect.objectContaining({
scroll_id: scrollId,
body: { scroll_id: scrollId },
})
);
});
@ -1150,7 +1150,7 @@ describe('CSV Execute Job', function () {
await runTask('job123', jobParams, cancellationToken);
expect(mockEsClient.scroll).toHaveBeenCalledWith(
expect.objectContaining({ scroll: scrollDuration })
expect.objectContaining({ body: { scroll: scrollDuration, scroll_id: 'scrollId' } })
);
});
});

View file

@ -60,12 +60,14 @@ export function createHitIterator(logger: LevelLogger) {
);
}
async function scroll(scrollId: string | undefined) {
async function scroll(scrollId: string) {
logger.debug('executing scroll request');
return parseResponse(
await elasticsearchClient.scroll({
scroll_id: scrollId,
scroll: scrollSettings.duration,
body: {
scroll_id: scrollId,
scroll: scrollSettings.duration,
},
})
);
}
@ -74,7 +76,7 @@ export function createHitIterator(logger: LevelLogger) {
logger.debug('executing clearScroll request');
try {
await elasticsearchClient.clearScroll({
scroll_id: scrollId,
body: { scroll_id: scrollId },
});
} catch (err) {
// Do not throw the error, as the job can still be completed successfully