Skip to content

Migration to backfill archived in wikis

Ravi Kumar requested to merge 416248-migration-backfill-archived-wikis into master

What does this MR do and why?

Backfill the archived field in the wikis index. This is done only for the project wikis because groups can not be archived so there is no need to do the group wikis.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  • Make sure Elasticsearch is enabled
  • Open the Rails console
bundle exec rails c
  • Prepare some wikis with missing archived field

    • Simulate the condition migration add_archived_to_wikis is not finished
      • Early return from the method migration_has_finished?. Replace the method here by the following code
        def migration_has_finished?(name)
          return false if name == :add_archived_to_wikis
          Rails.cache.fetch cache_key(:migration_has_finished, name.to_s.underscore), expires_in: CACHE_TIMEOUT do
            migration_has_finished_uncached?(name)
          end
        end
    • Now create some wikis.
    • Ensure that the archived field is missing in these newly created wikis. The following curl request should show count non zero
    curl -XGET "http://localhost:9200/gitlab-development-wikis/_count" -H "kbn-xsrf: reporting" -H "Content-Type: application/json" -d'
    {
      "query": {
        "bool": {
          "must_not": [
            {
              "exists": {
                "field": "archived"
              }
            }
          ],
          "must": {
            "exists": {
              "field": "project_id"
            }
          }
        }
      }
    }' | json_pp
  • Run the migration in the rails console

  Elastic::DataMigrationService[20230728104748].send(:migration).migrate
  • Now check again the wiki docs on the wikis index by using the above curl request. It should show count as zero

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Run time

~ 10 minutes

Related to #416248 (closed)

Related to Create a migration to backfill archived (#417743 - closed)

Edited by Ravi Kumar

Merge request reports