Reschedule deduplicated SyncScanPoliciesWorker

What does this MR do and why?

Reschedules SyncScanPoliciesWorker on deduplication since the strategy is :until_executed and a policy edit may get deduplicated while we're still processing a previous edit.

References

n/a

Screenshots or screen recordings

n/a

How to set up and validate locally

  1. Create a new project
  2. Navigate to Secure > Policies and create the following Scan execution policy:
scan_execution_policy:
  - name: Alpha
    enabled: true
    rules:
      - type: pipeline
        branch_type: all
    actions:
      - scan: secret_detection
  1. Merge the MR on the policy project
  2. Patch ee/app/workers/concerns/update_orchestration_policy_configuration.rb to simulate latency:
diff --git a/ee/app/workers/concerns/update_orchestration_policy_configuration.rb b/ee/app/workers/concerns/update_orchestration_policy_configuration.rb
index 752a5b8bc840..824733abf123 100644
--- a/ee/app/workers/concerns/update_orchestration_policy_configuration.rb
+++ b/ee/app/workers/concerns/update_orchestration_policy_configuration.rb
@@ -21,6 +21,8 @@ def update_policy_configuration(configuration)
 
     Security::PersistSecurityPoliciesWorker.perform_async(configuration.id)
 
+    sleep 60
+
     configuration.delete_all_schedules
     configuration.active_scan_execution_policies.each_with_index do |policy, policy_index|
       Security::SecurityOrchestrationPolicies::ProcessRuleService
  1. Open two MRs that change the name of the policy to Beta and Gamma respectively
  2. Merge the first MR, then merge the second
  3. Once the worker completes, verify the policy's mirrored name is Gamma:
pry(main)> Security::OrchestrationPolicyConfiguration.last.security_policies.pluck("name")
=> ["Gamma"]
  1. Repeat on master and verify the policy's mirrored name is Beta

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 Dominic Bauer

Merge request reports

Loading