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

Screenshot_2025-07-30_at_11.50.26_AM

Screenshot_2025-07-30_at_11.50.51_AM

NOTIFICATION: How to set up and validate locally

  1. 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
)
  1. Navigate to http://gdk.test:3000/rails/mailers/notify/pipeline_schedule_owner_unavailable (or replace gdk.test with localhost name)
  2. 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

  1. start a rails console $rails c and enable the feature flag Feature.enable(:notify_pipeline_schedule_owner_unavailable)
  2. Log into gdk as root user or super admin role
  3. Navigate to a project you own and has members
  4. Navigate to Manage --> Members (ie http://gdk.test:3000/flightjs/Flight/-/project_members)
  5. click on the account of an owner (first column) who is a maintainer or owner
  6. Click on the icon to view user in admin area
  7. click button to Impersonate user
  8. While impersonating user create a scheduled pipeline on the project Project Repo view --> Build(sidebar left) --> Pipeline Schedules --> New Schedule
  9. Stop impersonating the user
  10. Navigate back to managing project members (Step #4 (closed))
  11. Click on the users role and change it to any role < Developer
  12. 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)

Edited by Vlad Wolanyk

Merge request reports

Loading