Ignore child pipeline absences in analyzer statuses
What does this MR do and why?
Security inventory marks scanners Stale when child pipelines without security jobs finish on the default branch. Each finished child pipeline was evaluated as its own default-branch pipeline. Every analyzer it did not run got one more consecutive absence, so a parent pipeline that triggers three deployment child pipelines turned its scanners Stale minutes after running them.
This MR stops counting absences for child pipelines in Security::AnalyzersStatus::UpdateService#absent_statuses, the same way business logic scan pipelines are already skipped. A child pipeline that runs a scanner still records that scanner's status. The change is behind the analyzer_status_ignore_child_pipeline_absences feature flag (gitlab_com_derisk, project actor, default off).
Why in the service and not in the pipeline completion hook
Child pipelines without reports reach the service through the after_transition hook in ee/app/models/ee/ci/pipeline.rb. Child pipelines with reports reach it through Security::ReportsIngestedEvent, which is published per pipeline in the hierarchy. Skipping absences in the service covers both paths. The parent pipeline still reaches the service on either path, so an analyzer that is really removed from the CI configuration still goes Stale through the parent's runs.
Known gap, not changed here: the parent pipeline still counts analyzers that only run in child pipelines as absent. A complete fix would evaluate the whole pipeline hierarchy once. That is a follow-up.
References
- Bug: #639261 (closed)
- Related: #590490
- customer Zendesk Ticket: https://gitlab.zendesk.com/agent/tickets/757155 (resolves behaviour reported in this ticket)
Screenshots or screen recordings
Not applicable, backend only. Security::AnalyzerProjectStatus for a reproduction project (SAST and secret detection in the parent, three child pipelines without security jobs):
| Before (flag off) | After (flag on) |
|---|---|
sast, secret_detection: stale, count 3 after the third child pipeline |
sast, secret_detection: success, count 0 after all three child pipelines |
How to set up and validate locally
-
Create a project in a group on an Ultimate instance, using the
.gitlab-ci.yml,deploy.ymlanddeploy-env.ymlfrom the issue's steps to reproduce. -
Run a pipeline on the default branch and let its three child pipelines finish. In the Rails console, the statuses are now
stale:Security::AnalyzerProjectStatus.where(project: Project.find_by_full_path('<group>/<project>')).pluck(:analyzer_type, :status, :consecutive_absence_count) -
Enable the flag for the project:
Feature.enable(:analyzer_status_ignore_child_pipeline_absences, Project.find_by_full_path('<group>/<project>')) -
Run another default branch pipeline and let its child pipelines finish. The statuses are
successwith a count of 0, and Secure > Security inventory shows the scanners as enabled.
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.