Backfill migration for Reachability field

What does this MR do and why?

Backfills the reachability field on ES based on schema version.

References

Screenshots or screen recordings

After:

Screenshot_2025-07-16_at_2.06.09_PM

Screenshot_2025-07-16_at_2.06.21_PM

How to set up and validate locally

  1. Apply this patch
diff --git a/ee/lib/search/elastic/references/vulnerability.rb b/ee/lib/search/elastic/references/vulnerability.rb
index 0c3d9bcf6096..a4703fa1f6e5 100644
--- a/ee/lib/search/elastic/references/vulnerability.rb
+++ b/ee/lib/search/elastic/references/vulnerability.rb
@@ -7,7 +7,7 @@ class Vulnerability < Reference
         include Search::Elastic::Concerns::DatabaseReference
         include ::Gitlab::Utils::StrongMemoize

-        SCHEMA_VERSION = 25_26
+        SCHEMA_VERSION = 25_25
         DOC_TYPE = 'vulnerability'
         INDEX_NAME = 'vulnerabilities'
  1. Start Rails console with SASS GITLAB_SIMULATE_SAAS=1 bundle exec rails console

  2. Run the manual bookkeeping command

Vulnerabilities::Read.all.each { |v| ::Elastic::ProcessBookkeepingService.track!(Search::Elastic::References::Vulnerability.new(v.vulnerability_id, "group_#{v.project.namespace.root_ancestor.id}")) }
  1. Run process bookkeeping multiple times till the results are shown as [0, 0].
Elastic::ProcessBookkeepingService.new.execute
  1. Reset the above patch and change SCHEMA_VERSION = 25_26. Restart rails console GITLAB_SIMULATE_SAAS=1 bundle exec rails console and gdk rails-background-jobs.

  2. Run the migration and initialbookkeeping service

Elastic::DataMigrationService[20250702131957].migrate
::Elastic::ProcessInitialBookkeepingService.new.execute
  1. Verify with the below query that there are no older schema records and the count returns 0.
GET /gitlab-development-vulnerabilities-20250710-0625/_count
{
  "query": {
    "term": {
      "schema_version": 2525
    }
  }
}

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #543494 (closed)

Edited by Bala Kumar

Merge request reports

Loading