Skip to content

Only block pausing indexing if running migration requires it

What does this MR do?

Related to #329273 (closed)

Advanced Search migrations have the option to require indexing to be paused. Currently, the Advanced Search settings page will disable the Pause Elasticsearch indexing checkbox if there are ANY pending migrations and indexing is paused. This has created some problems in the past if users pause indexing before migrations run.

This change updates the logic used to disable the checkbox to check that:

  • a pending migration existing
  • the first pending migration (only 1 migration can run at a time)
    • is running (started, not completed, and not halted)
    • requires indexing to be paused

How to test

Note: Make sure Elasticsearch is setup in gdk, Advanced Search is enabled and the projects/data are indexed.

  1. Navigate to the Admin Settings - Settings - Advanced Search Settings screen
  2. Pause Elasticsearch indexing, save, and verify that Pause Elasticsearch indexing is checked
  3. Create a new migration file that does not require indexing to be paused under /ee/elastic/migrate (see examples below for what I used)
  4. Open rails console
  5. Verify there are pending migrations: Elastic::DataMigrationService.pending_migrations?
  6. Start a Migration Worker Elastic::MigrationWorker.perform_async
  7. Refresh the Advanced Search Settings page and verify that Pause Elasticsearch indexing is checked and enabled
  8. change the migration completed? to return true
  9. Start a Migration Worker Elastic::MigrationWorker.perform_async
  10. Refresh the Advanced Search Settings page and verify that Pause Elasticsearch indexing is checked and enabled
  11. Create a new migration file that requires indexing to be paused under /ee/elastic/migrate (see examples below for what I used)
  12. Verify there are pending migrations: Elastic::DataMigrationService.pending_migrations?
  13. Start a Migration Worker Elastic::MigrationWorker.perform_async
  14. Refresh the Advanced Search Settings page and verify that Pause Elasticsearch indexing is checked and disabled
  15. change the migration completed? to return true
  16. Start a Migration Worker Elastic::MigrationWorker.perform_async
  17. Refresh the Advanced Search Settings page and verify that Pause Elasticsearch indexing is checked and enabled

Example migration file (does not require pause indexing)

# frozen_string_literal: true

class TestMigration < Elastic::Migration
  batched!
  throttle_delay 10.seconds

  def migrate
    # no op
  end

  def completed?
    false
  end
end

Example migration file (requires pause indexing)

# frozen_string_literal: true

class TestMigration < Elastic::Migration
  batched!
  throttle_delay 10.seconds
  pause_indexing!

  def migrate
    # no op
  end

  def completed?
    false
  end
end

Screenshots (strongly suggested)

This should only show up when a migration requires indexing to be paused

image

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • 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 Terri Chu

Merge request reports

Loading