Add worker architecture for scheduled PEP
What does this MR do and why?
Adds model and Sidekiq worker architecture for pipeline execution policy schedules.
The idea is that for each project that is in scope for a policy, we create a record on the new security_pipeline_execution_schedules
table.
The Security::PipelineExecutionPolicies::ScheduleWorker
worker that runs every 15 minutes only has to queue the security_pipeline_execution_schedules
table without loading the actual policy configuration to enqueue individual workers for each project and policy.
Feature availability
This MR is part of a new feature addition (&14147) it does not contain a feature flag because there is no UI for feature yet that we can hide.
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
- Schema issue: #504088 (closed)
- Sidekiq issue: #504092 (closed)
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
There is no user visible change in this MR which makes it hard to test manually.
- Check the count for project schedules in rails console:
Security::PipelineExecutionProjectSchedule.count
. It should be0
- Create a group with a project in it
- Create another project in the group
- In the new project, add a
policy-ci.yml
file:pipeline execution policy job: stage: .pipeline-policy-pre script: - echo "Enforce your policy here"
- Create a policy configuration file
.gitlab/security-policies/policy.yml
in the project and replace theproject
field with the path to your project:--- pipeline_execution_schedule_policy: - name: test description: '' enabled: true content: include: - project: path/to-your/project file: policy-ci.yml schedule: cadence: 0 * * * * approval_policy: []
- Go back to the group page and select Security & Compliance and Policies on the left sidebar.
- Select Edit policy project.
- Select the project you created and select Save.
- Check the count of schedules again
Security::PipelineExecutionProjectSchedule.count
. It should now be2
. One for each project in the group.
Related to #504088 (closed)