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

[8.17] [Session Index] Attach alias to index when index name changes (#210176) #210753

Closed

Conversation

SiddharthMantri
Copy link
Contributor

Backport

This will backport the following commits from main to 8.17:

Questions ?

Please refer to the Backport tool documentation

\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n\n\nCo-authored-by: Sid "}},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com//pull/210738","number":210738,"state":"MERGED","mergeCommit":{"sha":"13dddd96e0904f8010ed2d53c6067664aac94e45","message":"[8.18] [Session Index] Attach alias to index when index name changes (#210176) (#210738)\n\n# Backport\n\nThis will backport the following commits from `main` to `8.18`:\n- [[Session Index] Attach alias to index when index name changes\n(#210176)](https://github.com//pull/210176)\n\n\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n\n\nCo-authored-by: Sid "}},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com//pull/210176","number":210176,"mergeCommit":{"message":"[Session Index] Attach alias to index when index name changes (#210176)\n\nCloses https://github.com//issues/210179\r\n\r\n## Summary\r\n\r\nWhile attempting to attach an alias to the session index, we were using\r\n`.kibana_security_session_1` as the index name. However, the session\r\nindex, if upgraded using the Upgrade assistant gets renamed to\r\n`.kibana_security_session_1-reindexed-for-9` and\r\n`.kibana_security_session_1` is set as an alias pointing to this index.\r\nWhen we try to reattach the alias using this as the index name, ES\r\nthrows an error. This doesn't affect Kibana functionality but it\r\nincreases the number of errors thrown in the logs.\r\n\r\n**This PR corrects this issue by attaching the alias to the index only\r\nwhen alias isn't already present. We now only assign the alias if not\r\npresent - and not during creation of the index as it is created with the\r\nalias in it's settings.**\r\n\r\n### Release note\r\nFixes the assignment of the Session index alias by only attaching it if\r\nnot already present.\r\n\r\n## How to test\r\n\r\nTo see the error in the logs, you'll need at least 7.x and 8.x checked\r\nout locally. Once done, run bootstrap.\r\n\r\n#### Step 1: On 7.17\r\n- Start ES with `yarn es snapshot --license trial -E\r\npath.data=/tmp/esdata`\r\n- Start Kibana and login with elastic user\r\n- You can check the contents of Kibana session index:\r\n\r\n```\r\nGET .kibana_security_session_1/_search\r\n{\r\n \"query\": {\r\n \"match_all\": {}\r\n }\r\n}\r\n```\r\nShould return a single document\r\n- You can now shut kibana and ES\r\n\r\n\r\n#### Step 2: on 8.x\r\n- Make a backup of the esdata above `cp -r /tmp/esdata /tmp/esdatabkp`\r\n- Start ES as above `yarn es snapshot --license trial -E\r\npath.data=/tmp/esdata`\r\n- Start kibana and login\r\n- Navigate to Upgrade assistant. You should see at least 2 System\r\nindices that require migration (Security and Kibana)\r\n- Start the migrate index process (Step 2 in the UA interface)\r\n- Once done, trigger a local restart of kibana either by restarting\r\nusing the start script or just triggering a file save on any file in\r\nyour IDE\r\n- You should start seeing the error described above in 100ms increments\r\ntill it reaches 10000ms and then it's every 10 seconds\r\n- Navigate to Dev tools and run\r\n```\r\nGET .kibana_security_session/_alias\r\n```\r\nYou should see the index as \r\n```\r\n.kibana_security_session_reindexed-for-9 {\r\n aliases: {\r\n // aliases of the index including kibana_security_session_1\r\n }\r\n}\r\n```\r\n\r\n#### Verify the fix\r\nTo verify, we have a couple of options - either clone the PR and go\r\nthrough the same steps as Step 2 above but for 9.0. The easier option is\r\nreplace the code of function `attachAliasToIndex` in `session_index.ts`\r\nin 8.x with the changes in this PR. This should restart your kibana\r\nserver and you will no longer see the error in the logs.\r\n\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following conditions. \r\n\r\nReviewers should verify this PR satisfies this list as well.\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine ","sha":"45d9fa01feaba65d433473519215982c5a600947"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"url":"https://github.com//pull/210739","number":210739,"state":"MERGED","mergeCommit":{"sha":"e2984813e6ae6f692e3bb0c4cd329b7e444cef8a","message":"[8.x] [Session Index] Attach alias to index when index name changes (#210176) (#210739)\n\n# Backport\n\nThis will backport the following commits from `main` to `8.x`:\n- [[Session Index] Attach alias to index when index name changes\n(#210176)](https://github.com//pull/210176)\n\n\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n\n\nCo-authored-by: Sid "}}]}] BACKPORT-->

Closes elastic#191714

Update process router to generate authz descriptions based on the new
Route Security objects.

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit a168458)
@SiddharthMantri SiddharthMantri enabled auto-merge (squash) February 12, 2025 09:11
auto-merge was automatically disabled February 12, 2025 09:13

Pull request was closed

@elasticmachine
Copy link
Contributor

elasticmachine commented Feb 12, 2025

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #6 / Session index #initialize creates index if neither index or alias exists
  • [job] [logs] Jest Tests #6 / Session index #initialize creates index if neither index or alias exists
  • [job] [logs] Jest Tests #6 / Session index #initialize does not create index if alias exists
  • [job] [logs] Jest Tests #6 / Session index #initialize does not create index if alias exists
  • [job] [logs] Jest Tests #6 / Session index #initialize does not create index if index exists
  • [job] [logs] Jest Tests #6 / Session index #initialize does not create index if index exists

Metrics [docs]

✅ unchanged

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants