From e3064d101ef8e9074431049135d2319335de3117 Mon Sep 17 00:00:00 2001 From: Stefan Matting Date: Mon, 15 Feb 2021 18:45:03 +0100 Subject: [PATCH] Add ES migration instructions for release 2021-02-15 (#1364) --- .../elasticsearch-migration-2021-02-15.md | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 docs/reference/elasticsearch-migration-2021-02-15.md diff --git a/docs/reference/elasticsearch-migration-2021-02-15.md b/docs/reference/elasticsearch-migration-2021-02-15.md new file mode 100644 index 00000000000..4f529de83d5 --- /dev/null +++ b/docs/reference/elasticsearch-migration-2021-02-15.md @@ -0,0 +1,113 @@ +# ElasticSearch migration instructions for release 2021-02-15 + +Release `2021-02-15` of `wire-server` requires creating a new ElasticSearch index for `brig` _before_ deploying the release. Without this new index the user search in TeamSettings will be defunct. + +The index that brig is using, is defined at brig's config at `elasticsearch.index`. This config value of the previous deployment is referred to as `` in the following. + +These following instructions describe how to: + +1. Create the new index `` (you can choose any name that is different from ``) +2. Populate `` with brig's data. +3. Configure brig to use the new index. + +In the following we assume the following env vars are set. + +```bash +ES_HOST= +ES_PORT= # default is 9200 +OLD_INDEX= # (Same as `elasticsearch.index` previous deployment) +NEW_INDEX= # new index name, different from OLD +BRIG_CASSANDRA_HOST= +BRIG_CASSANDRA_PORT= +BRIG_CASSANDRA_KEYSPACE= # probably "brig" +WIRE_VERSION= +SHARDS= # 5 if you are unsure +REPLICAS= # 2 if you are unsure +REFRESH_INTERVAL= # 5 if you are unsure +``` + +Delete the `directory` index template if it exists: + +```bash +curl -XDELETE http://$ES_HOST:$ES_HOST/_template/directory +``` + +The next steps require downtime of brig. If downtime is not acceptable please skip to section [Create the new index without downtime](#create-the-new-index-without-downtime) + +1. Shut down the `brig` service. +2. Create the new index by running +```sh +docker run "quay.io/wire/brig-index:$WIRE_VERSION" create \ + --elasticsearch-server "http://$ES_HOST:$ES_PORT" \ + --elasticsearch-index "$NEW_INDEX" \ + --elastcsearch-shards "$SHARDS" \ + --elastcsearch-replicas "$REPLICAS" \ + --elastcsearch-refresh-interval "$REFRESH_INTERVAL" +``` + +3. Populate the new index by running +```sh +docker run "quay.io/wire/brig-index:$WIRE_VERSION" migrate-data \ + --elasticsearch-server "http://$ES_HOST:$ES_PORT" \ + --elasticsearch-index "$NEW_INDEX" \ + --cassandra-host "$BRIG_CASSANDRA_HOST" \ + --cassandra-port "$BRIG_CASSANDRA_PORT" \ + --cassandra-keyspace "$BRIG_CASSANDRA_KEYSPACE" +``` +This may take sevaral minutes depending on number of users. + +4. Configure brig to use the new index, by setting `elasticsearch.index` to `` and deploy of `brig` with new version "$WIRE_VERSION". +5. Check that team member search in TeamSettings and user search in the app works. +6. Delete the old index +``` +```bash +curl -XDELETE http://$ES_HOST:$ES_HOST/$OLD_INDEX +``` + +## Create the new index without downtime + +1. Create the new index by running + +```sh +docker run "quay.io/wire/brig-index:$WIRE_VERSION" create \ + --elasticsearch-server "http://$ES_HOST:$ES_PORT" \ + --elasticsearch-index "$NEW_INDEX" \ + --elastcsearch-shards "$SHARDS" \ + --elastcsearch-replicas "$REPLICAS" \ + --elastcsearch-refresh-interval "$REFRESH_INTERVAL" +``` + +2. Redeploy brig with `elasticsearch.additionalWriteIndex` set to ``. +3. Make sure no old instances of brig are running. +4. Populate the new index by running +```sh +docker run "quay.io/wire/brig-index:$WIRE_VERSION" migrate-data \ + --elasticsearch-server "http://$ES_HOST:$ES_PORT" \ + --elasticsearch-index "$NEW_INDEX" \ + --cassandra-host "$BRIG_CASSANDRA_HOST" \ + --cassandra-port "$BRIG_CASSANDRA_PORT" \ + --cassandra-keyspace "$BRIG_CASSANDRA_KEYSPACE" +``` +This may take sevaral minutes depending on number of users. + +5. Redeploy brig with these config updates: + - unset `elasticsearch.additionalWriteIndex` + - set `elasticsearch.index` to `` +6. Check that team member search in TeamSettings and user search in the app works. +7. Delete the old index + +```bash +curl -XDELETE http://$ES_HOST:$ES_HOST/$OLD_INDEX +``` + +## Troubleshooting + +### Problem: Brig was deployed without creating the new index beforehand. +Solution: The index can be created after deployment with same instructions as above. + +### Problem: `brig-index migrate-data` failed and refuses to migrate again. +Solution: Delete the migration information from Elasticsearch: + + ```bash + curl -XDELETE http://$ES_HOST:$ES_PORT/wire_brig_migrations + ```