[8.17] [Session Index] Attach alias to index when index name changes (#210176) #210753
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport
This will backport the following commits from
main
to8.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-->