Introduce PolicyConfigurationAssignedEvent and bulk sync flag

What does this MR do and why?

Introduce PolicyConfigurationAssignedEvent and a feature flag that suppresses individual per-policy events when a security policy configuration is assigned to a project or group.

When a policy project is assigned, SyncScanPoliciesWorker triggers PersistSecurityPoliciesWorker, which currently publishes individual PolicyCreatedEvent / PolicyUpdatedEvent / PolicyDeletedEvent events for every policy. For large configurations this fans out into many small jobs. This MR lays the groundwork for replacing that with a single bulk event that fans out once per project.

Behind the sync_policies_in_bulk_on_policy_configuration_assign flag (disabled by default):

  • PersistPolicyService skips EventPublisher#publish (individual policy events) when triggered_by_assign: true
  • PersistSecurityPoliciesWorker instead publishes a single PolicyConfigurationAssignedEvent
  • SyncPolicyConfigurationWorker is registered as the subscriber (no-op stub; fan-out logic in the follow-up MR)

When the flag is disabled, all existing behavior is unchanged.

References

Issue: #600265

This MR is part of a series:

How to set up and validate locally

  1. Enable the feature flag:

    bin/rails runner "Feature.enable(:sync_policies_in_bulk_on_policy_configuration_assign)"
  2. Assign a security policy project to a project via Settings > Security and compliance > Security policies.

  3. In Sidekiq logs, verify PolicyCreatedEvent / PolicyUpdatedEvent are not published during the assign flow, and PolicyConfigurationAssignedEvent is published.

  4. Disable the flag and repeat — individual policy events should fire as before.

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 Imam Hossain

Merge request reports

Loading
Loading