Cascade Duo settings by name so the latest values win
What does this MR do and why?
Stacked on !264320 (merged). Review that MR first. This MR targets its branch.
Namespaces::CascadeDuoSettingsWorker received the new setting values as job arguments. Every change of value made a different job, so Sidekiq's duplicate check never collapsed them, and each one walked the whole group hierarchy. A job that ran late could also cascade a value the Owner had already changed again.
Behind the cascade_duo_settings_by_name feature flag (default off):
Groups::UpdateServicequeues the worker with setting names, such as["duo_features_enabled"], instead of{ "duo_features_enabled" => true }. A changed foundational flow selection travels in a trailing options hash, because the selection isn't stored onnamespace_settings.- The worker reads the group's current values for those names when it runs.
idempotency_argumentskeys duplicate checks on the group id, the sorted setting names, the user and the options. The values aren't part of the key, so repeated changes to the same settings by the same user collapse into one job, andreschedule_oncecascades the latest values once more after it finishes. The user stays in the key because the cascade runs as that user, for example in the foundational flow sync.loggable_arguments 1, 3logs the setting names and the options, so the jobs are visible in Kibana during the rollout.
Without the flag, the worker also has these changes:
- It accepts both argument formats, so jobs queued before or after the flag flips keep working.
CascadeDuoSettingsWorkerandAi::Catalog::Flows::CascadeSyncFoundationalFlowsWorkergetconcurrency_limit -> { 10 }. The rollout issue names the per-worker kill switch.
Notes for reviewers:
- The flag protects deploys. A Sidekiq node still running the old code fails a job with four arguments, so enable the flag only after every node runs this code.
- Pausing a cascade between batches when the database is unhealthy was considered and left out. It is a generic Sidekiq enhancement and fits better as a separate reusable component.
References
- https://gitlab.com/gitlab-org/gitlab/-/work_items/635299
- !264320 (merged)
- Rollout issue: https://gitlab.com/gitlab-org/gitlab/-/work_items/635514
Screenshots or screen recordings
Not applicable. The change is in background jobs and has no UI.
| Before | After |
|---|---|
How to set up and validate locally
-
In the Rails console, enable the feature flag:
Feature.enable(:cascade_duo_settings_by_name) -
Pick a group that has a subgroup, set a value on the group only, and run the worker with the setting name:
group = Group.find_by_full_path('<group_path>') group.namespace_settings.update!(duo_features_enabled: false) Namespaces::CascadeDuoSettingsWorker.new.perform(group.id, ['duo_features_enabled']) NamespaceSetting.where(namespace_id: group.descendants).pluck(:duo_features_enabled)Every subgroup now has
false, the value the group had when the job ran. -
Change the value on the settings page of the group and save. The subgroups follow it after Sidekiq processes the job.
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.