Skip to content

Allow retry for halted Elasticsearch migrations

Terri Chu requested to merge 297193-retry-button-for-halted-migrations into master

What does this MR do?

Related to #297193 (closed)

A halted migration will block the halted migration and any future migrations from running. Currently, users are notified of pending migrations (not halted) where the "Pause indexing" checkbox is located. This change notifies admin users of halted migrations and allows them to schedule the halted migration to be retried.

  • Retrying the migration will:
    • look up the migration (looked up in the file directory by version)
    • delete the migration record in the migrations index
    • invalidate the cache that tracks halted migrations
    • redirect back to the settings page
  • added retry alert/button in admin > settings > general > advanced search UI + backend support
  • use redis cache in a similar manner to the way we track migration completion
  • update specs & documentation
  • modify MigrateIssuesToSeparateIndex migration so it cleans up if it is retried and only creates the issues index (we plan to add more support for standalone indexes and this migration should only deal with the issues index)

To test this

To test this locally, you will need to :

  • manually mark your last migration as halted I did this through direct calls to Elasticsearch. This should cause the button to show up in the Advanced Search integration settings. Once the button is clicked, the migration should be removed from the migrations index and will be picked up once the MigrationWorker runs.

      curl --request PUT \
           --url http://localhost:9200/gitlab-development-migrations/_doc/20201123123400 \
           --header 'Content-Type: application/json' \
           --data '{
            "completed": false,
            "state": {
    	   "retry_attempt": 30,
    	   "halted": true
               	},
            	"started_at": "2021-01-07T14:14:30.291Z",
          	"completed_at": null
            }'
  • possibly invalidate the cache using the rails console `

      [1] pry(main)> m = Elastic::DataMigrationService[20201123123400]
       => #<Elastic::MigrationRecord:0x00007fc3394f7a28 @filename="/.../gdk/gitlab/ee/elastic/migrate/20201123123400_migrate_issues_to_separate_index.rb", @migration=nil, @name="MigrateIssuesToSeparateIndex", @version=20201123123400>
      [2] pry(main)> Elastic::DataMigrationService.drop_migration_halted_cache!(m)
       => 1

Note: Depending on the state of your existing Elasticsearch index (whether it was created prior to the issues index move or not), you may need to completely reindex or put the migration back to a completed state to get things working again once done testing.

Screenshots (strongly suggested)

A migration has been halted

image

Double check alert

image

Retry migration button clicked (migration found)

image

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Paul Slaughter

Merge request reports

Loading