Backfill resolved_at, dismissed_at on vulnerability ES index
What does this MR do and why?
Backfills resolved_at, dismissed_at fields on the vulnerability ES index.
Screenshots or screen recordings
| Before | After |
|---|---|
![]() |
![]() |
How to set up and validate locally
- 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_36
DOC_TYPE = 'vulnerability'
INDEX_NAME = 'vulnerabilities'
-
Start Rails console with SASS
GITLAB_SIMULATE_SAAS=1 bundle exec rails console -
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}")) }
- Run process bookkeeping multiple times till the results are shown as
[0, 0].
Elastic::ProcessBookkeepingService.new.execute
- Run the query and verify that the counts shows up and not 0.
GET /gitlab-development-vulnerabilities/_count
{
"query": {
"term": {
"schema_version": 2526
}
}
}
-
Reset the above patch and change to
SCHEMA_VERSION = 25_36. Restart rails consoleGITLAB_SIMULATE_SAAS=1 bundle exec rails consoleandgdk restart rails-background-jobs. -
Run the migration and initialbookkeeping service multiple times till the results show
[0, 0].
Elastic::DataMigrationService[20250910180829].migrate
::Elastic::ProcessInitialBookkeepingService.new.execute
- Verify with the below query that there are no older schema records and the count returns 0.
GET /gitlab-development-vulnerabilities/_count
{
"query": {
"term": {
"schema_version": 2526
}
}
}
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 #563391 (closed)
Edited by Bala Kumar

