Skip to content

Commit

Permalink
[Reporting CSV] Fix scroll ID bug for deprecated csv export (elastic#…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
tsullivan and kibanamachine committed Jul 30, 2021
1 parent 1bf7d01 commit c167745
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe('CSV Execute Job', function () {
);

expect(mockEsClient.scroll).toHaveBeenCalledWith(
expect.objectContaining({ scroll_id: scrollId })
expect.objectContaining({ body: { scroll_id: scrollId } })
);
});

Expand Down Expand Up @@ -261,7 +261,7 @@ describe('CSV Execute Job', function () {
);

expect(mockEsClient.clearScroll).toHaveBeenCalledWith(
expect.objectContaining({ scroll_id: lastScrollId })
expect.objectContaining({ body: { scroll_id: lastScrollId } })
);
});

Expand Down Expand Up @@ -295,7 +295,7 @@ describe('CSV Execute Job', function () {
);

expect(mockEsClient.clearScroll).toHaveBeenCalledWith(
expect.objectContaining({ scroll_id: lastScrollId })
expect.objectContaining({ body: { scroll_id: lastScrollId } })
);
});
});
Expand Down Expand Up @@ -754,7 +754,7 @@ describe('CSV Execute Job', function () {

expect(mockEsClient.clearScroll).toHaveBeenCalledWith(
expect.objectContaining({
scroll_id: scrollId,
body: { scroll_id: scrollId },
})
);
});
Expand Down Expand Up @@ -1151,7 +1151,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' } })
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
})
);
}
Expand All @@ -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
Expand Down

0 comments on commit c167745

Please sign in to comment.