forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Session Index] Attach alias to index when index name changes (elasti…
…c#210176) Closes elastic#210179 ## Summary While attempting to attach an alias to the session index, we were using `.kibana_security_session_1` as the index name. However, the session index, if upgraded using the Upgrade assistant gets renamed to `.kibana_security_session_1-reindexed-for-9` and `.kibana_security_session_1` is set as an alias pointing to this index. When we try to reattach the alias using this as the index name, ES throws an error. This doesn't affect Kibana functionality but it increases the number of errors thrown in the logs. **This PR corrects this issue by attaching the alias to the index only when alias isn't already present. We now only assign the alias if not present - and not during creation of the index as it is created with the alias in it's settings.** ### Release note Fixes the assignment of the Session index alias by only attaching it if not already present. ## How to test To see the error in the logs, you'll need at least 7.x and 8.x checked out locally. Once done, run bootstrap. #### Step 1: On 7.17 - Start ES with `yarn es snapshot --license trial -E path.data=/tmp/esdata` - Start Kibana and login with elastic user - You can check the contents of Kibana session index: ``` GET .kibana_security_session_1/_search { "query": { "match_all": {} } } ``` Should return a single document - You can now shut kibana and ES #### Step 2: on 8.x - Make a backup of the esdata above `cp -r /tmp/esdata /tmp/esdatabkp` - Start ES as above `yarn es snapshot --license trial -E path.data=/tmp/esdata` - Start kibana and login - Navigate to Upgrade assistant. You should see at least 2 System indices that require migration (Security and Kibana) - Start the migrate index process (Step 2 in the UA interface) - Once done, trigger a local restart of kibana either by restarting using the start script or just triggering a file save on any file in your IDE - You should start seeing the error described above in 100ms increments till it reaches 10000ms and then it's every 10 seconds - Navigate to Dev tools and run ``` GET .kibana_security_session/_alias ``` You should see the index as ``` .kibana_security_session_reindexed-for-9 { aliases: { // aliases of the index including kibana_security_session_1 } } ``` #### Verify the fix To verify, we have a couple of options - either clone the PR and go through the same steps as Step 2 above but for 9.0. The easier option is replace the code of function `attachAliasToIndex` in `session_index.ts` in 8.x with the changes in this PR. This should restart your kibana server and you will no longer see the error in the logs. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [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 - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
0897d08
commit 45d9fa0
Showing
2 changed files
with
48 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters