Notify and Deactivate Pipeline Schedule on Membership Change
What does this MR do and why?
This MR is the first in a series to resolve a customer reported issue where pipeline_schedules were no longer running when users were deleted, or removed from a project or group. This MR ensures that when a user's membership in either a group or project changes or is removed, a check is performed to identify any pipeline schedules that would no longer run due to the pipeline_schedule.owner being unavailable.
- the check is performed if the membership is destroyed or if
initial_access_level >= Gitlab::Access::DEVELOPER && the new_access_level < Gitlab::Access::DEVELOPER - if the user is a GroupMember, the check is performed for all user owned pipeline schedules in any of the group's projects
- if the user is a ProjectMember, the same check is performed for the single project
- if any newly unavailable pipeline_schedules are identified, a notification is sent to the project owners and maintainers
- the schedule is deactivated
All functionality is behind a FeatureFlag :notify_pipeline_schedule_owner_unavailable
Screenshots or screen recordings
NOTIFICATION: How to set up and validate locally
- Ensure you have a pipeline schedule created in your local db and if not add one:
$ bundle exec rails console
pry(main)> Ci::Pipeline.create(
description: "Test Pipeline Schedule",
ref: "1234",
cron: "* * * * *",
cron_timezone: "America/New_York",
project_id: Project.first,
owner_id: User.first
)
- Navigate to http://gdk.test:3000/rails/mailers/notify/pipeline_schedule_owner_unavailable (or replace
gdk.testwith localhost name) - Use drop down to change format from html to plan text (or navigate to http://gdk.test:3000/rails/mailers/notify/pipeline_schedule_owner_unavailable.txt?locale=en)
Member Role Change: How to set up and validate locally
- start a rails console
$rails cand enable the feature flagFeature.enable(:notify_pipeline_schedule_owner_unavailable) - Log into gdk as root user or super admin role
- Navigate to a project you own and has members
- Navigate to Manage --> Members (ie http://gdk.test:3000/flightjs/Flight/-/project_members)
- click on the account of an owner (first column) who is a maintainer or owner
- Click on the icon to view user in admin area
- click button to Impersonate user
- While impersonating user create a scheduled pipeline on the project Project Repo view --> Build(sidebar left) --> Pipeline Schedules --> New Schedule
- Stop impersonating the user
- Navigate back to managing project members (Step #4 (closed))
- Click on the users role and change it to any role < Developer
- Navigate back to the Pipeline Schedules view( ie http://gdk.test:3000/flightjs/Flight/-/pipeline_schedules) and observe that the pipeline has been deactivated
Screen Recording of Steps:
deactivate_unavailable_owner_pipeline
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.
Related to #548938 (closed)

