Loading
Extend SyncPipelineExecutionPolicyMetadataWorker log context
What does this MR do and why?
Extend SyncPipelineExecutionPolicyMetadataWorker so its log lines carry enough context to be searchable per project and per customer.
Previously, when AnalyzePipelineExecutionPolicyConfigService failed inside the worker, the emitted warning only included the worker class name and the error message — no project, no user, no policy identifiers. That made it effectively impossible to find errors for a specific project or customer in Kibana.
Changes:
- Wrap the worker body in
with_context(project: config_project, user: user). This pushes the values ontoGitlab::ApplicationContext, so every log line emitted inside the block (including from downstream services) getsmeta.project,meta.user,meta.user_id, andmeta.root_namespaceinjected by Labkit's logger formatter — matching the structure the rest of the worker fleet uses. - Include
security_policy_idsin the failure payload so the affected policies are also searchable.
References
How to set up and validate locally
- In a rails console, enqueue the worker with arguments that will fail analysis (e.g. a user that does not have access to the config project):
Security::SyncPipelineExecutionPolicyMetadataWorker.new.perform(config_project.id, user.id, 'invalid', [policy.id]) - Inspect the resulting log line in
log/sidekiq.logand confirm it now includesmeta.project,meta.user,meta.user_id,correlation_id, andsecurity_policy_ids.
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.
Edited by Martin Cavoj