Conversation
thomheymann
left a comment
There was a problem hiding this comment.
Looks good. Couple comments below.
| if (haveDeletedSessions) { | ||
| try { | ||
| await elasticsearchClient.indices.refresh({ index: this.indexName }); | ||
| logger.debug(`Refreshed session index.`); | ||
| } catch (err) { | ||
| logger.error(`Failed to refresh session index: ${err.message}`); | ||
| } | ||
| } |
There was a problem hiding this comment.
nit: Maybe put this block in a finally statement if you want it executed irregardless of outcome? Thinks it's cleaner and you don't need to assign the thrown error.
There was a problem hiding this comment.
The old code re-threw the error in the catch. If we just tacked on a finally, it wouldn't get executed in that case, would it?
| }); | ||
| if (operations.length > 0) { | ||
| const bulkResponse = await this.options.elasticsearchClient.bulk( | ||
| haveDeletedSessions = true; |
There was a problem hiding this comment.
Technically speaking we haven't actually deleted anything at this point. Is it worth being stricter here and only marking sessions as having been touched after the bulk delete operation?
There was a problem hiding this comment.
I probably could have clarified this in the comments:
My reasoning for doing it here is that I'm not 100% sure if a failed bulk operation could have resulted in some of the sessions getting deleted. I figured it's safest to trigger an index refresh anyway, but I'm not sure how much of a practical impact this has tbh. I suppose haveAttemptedToDeleteSessions would have been a more accurate variable name but that sounds like a mouthful 😅
There was a problem hiding this comment.
Changed here: f4be021
Let me know what you think!
…ssion-cleanup-test
Also added comments.
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
(cherry picked from commit 2f83c65) # Conflicts: # x-pack/plugins/security/server/session_management/session_index.ts
(cherry picked from commit 2f83c65) # Conflicts: # x-pack/plugins/security/server/session_management/session_index.ts
…ed-unexpectedly-error * 'main' of github.com:elastic/kibana: (46 commits) Fix copy and pasted renderer user_name test (elastic#126663) [Gauge] Vis editors gauge legacy percent mode. (elastic#126318) Remove all cases related code from timelines (elastic#127003) Hide Enterprise search panel when no nodes are present (elastic#127100) [Lens] Fixed flakiness on runtime fields' appearance on the list (elastic#126945) [Security Solution][Lists] - Add missing privileges callout to exception lists page (elastic#126874) [Security Solution][Lists] - Updates exception flyout edit error messages (elastic#126875) [Security Solution][Rules] - Remove rule selection for read only users (elastic#126827) Fix session cleanup test (elastic#126966) [ftr] implement support for accessing ES through CCS (elastic#126547) [type-summarizer] always use normalized paths, fix windows compat (elastic#127055) Revert "[ci] Configure hourly pipeline for a small spot instance trial (elastic#126824)" Revert "[CI] Expand spot instance trial a bit (elastic#126928)" [Alerting] Adding functional tests for alerting and actions telemetry (elastic#126528) [Telemetry] Check permissions when requesting telemetry (elastic#126238) Don't submit empty seed_urls or sitemap_urls when making a partial crawl request (elastic#126972) Remove License Requirement for Enterprise Search App Search Meta Engines (elastic#127046) [ML] Adding data recognizer module config cache (elastic#126338) skip flaky suite (elastic#126027) [Reporting] Improve error logging for rescheduled jobs (elastic#126737) ... # Conflicts: # x-pack/plugins/reporting/server/core.ts # x-pack/plugins/reporting/server/lib/tasks/execute_report.ts
…re-browser-errors * 'main' of github.com:elastic/kibana: (46 commits) Fix copy and pasted renderer user_name test (elastic#126663) [Gauge] Vis editors gauge legacy percent mode. (elastic#126318) Remove all cases related code from timelines (elastic#127003) Hide Enterprise search panel when no nodes are present (elastic#127100) [Lens] Fixed flakiness on runtime fields' appearance on the list (elastic#126945) [Security Solution][Lists] - Add missing privileges callout to exception lists page (elastic#126874) [Security Solution][Lists] - Updates exception flyout edit error messages (elastic#126875) [Security Solution][Rules] - Remove rule selection for read only users (elastic#126827) Fix session cleanup test (elastic#126966) [ftr] implement support for accessing ES through CCS (elastic#126547) [type-summarizer] always use normalized paths, fix windows compat (elastic#127055) Revert "[ci] Configure hourly pipeline for a small spot instance trial (elastic#126824)" Revert "[CI] Expand spot instance trial a bit (elastic#126928)" [Alerting] Adding functional tests for alerting and actions telemetry (elastic#126528) [Telemetry] Check permissions when requesting telemetry (elastic#126238) Don't submit empty seed_urls or sitemap_urls when making a partial crawl request (elastic#126972) Remove License Requirement for Enterprise Search App Search Meta Engines (elastic#127046) [ML] Adding data recognizer module config cache (elastic#126338) skip flaky suite (elastic#126027) [Reporting] Improve error logging for rescheduled jobs (elastic#126737) ... # Conflicts: # x-pack/plugins/reporting/server/lib/tasks/execute_report.ts
This PR fixes the failing test in #121482.
The test asserts that no sessions exist in the index after the cleanup routine is called, but we made a recent change to how we delete sessions (#122419) that no longer forces an index refresh.
Now, we always attempt to refresh the index after deleting expired sessions.
I used
release_note:skipsince this is not a bug fix, it's just a test fix.I plan to backport this to all affected branches.
Flaky test run x50 ✅: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/219