Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix session cleanup test #126966

Merged

Conversation

jportner
Copy link
Contributor

@jportner jportner commented Mar 4, 2022

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:skip since 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

Copy link
Contributor

@thomheymann thomheymann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Couple comments below.

Comment on lines 494 to 501
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}`);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

@jportner jportner Mar 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

operations.push({ delete: { _id } });
});
if (operations.length > 0) {
const bulkResponse = await this.options.elasticsearchClient.bulk(
haveDeletedSessions = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed here: f4be021

Let me know what you think!

Copy link
Contributor

@thomheymann thomheymann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🥳

@jportner jportner enabled auto-merge (squash) March 7, 2022 22:03
@jportner jportner merged commit 2f83c65 into elastic:main Mar 7, 2022
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.1 Backport failed because of merge conflicts
8.0 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 126966

Questions ?

Please refer to the Backport tool documentation

@jportner jportner deleted the issue-121482-fix-session-cleanup-test branch March 7, 2022 23:35
jportner added a commit to jportner/kibana that referenced this pull request Mar 7, 2022
(cherry picked from commit 2f83c65)

# Conflicts:
#	x-pack/plugins/security/server/session_management/session_index.ts
jportner added a commit to jportner/kibana that referenced this pull request Mar 7, 2022
(cherry picked from commit 2f83c65)

# Conflicts:
#	x-pack/plugins/security/server/session_management/session_index.ts
jportner added a commit that referenced this pull request Mar 8, 2022
(cherry picked from commit 2f83c65)

# Conflicts:
#	x-pack/plugins/security/server/session_management/session_index.ts
jportner added a commit that referenced this pull request Mar 8, 2022
(cherry picked from commit 2f83c65)

# Conflicts:
#	x-pack/plugins/security/server/session_management/session_index.ts
jloleysens added a commit to jloleysens/kibana that referenced this pull request Mar 8, 2022
…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
jloleysens added a commit to jloleysens/kibana that referenced this pull request Mar 8, 2022
…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
lucasfcosta pushed a commit to lucasfcosta/kibana that referenced this pull request Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes v8.0.2 v8.1.1 v8.2.0
Projects
None yet
4 participants