Add Silent mode application setting
What does this MR do?
Describe in detail what your merge request does and why.
- Adds a "Silent mode" application setting (
silent_mode_enabled
) - The setting is manageable via REST API (
/api/v4/application/settings
) - The setting is not yet available in UI
- When enabled, outbound emails are suppressed. (Silent mode will do more in later iterations)
- Default off
- Adds docs that say it's in alpha
Related to #390820 (closed) and #391689 (closed) and #396475 (closed)
Why?
Silent Mode is not intended to become enabled on environments which are in-use. The two major use-cases are:
- You have a secondary Geo site as part of your disaster recovery solution. You want to regularly test promoting it to become a primary site, as a best practice to ensure your DR plan actually works. But you don't want to actually perform an entire failover, since the primary site lives in a region which provides the lowest latency to your users. And you don't want to take downtime during every regular test. So you let the primary site remain up, while you promote the secondary site. You start smoke testing the promoted site. But, the promoted site starts emailing users, the push mirrors push changes to external Git repos, etc. This is where Silent Mode comes in. You can enable it as part of site promotion, to avoid this issue.
- Validating GitLab backups. Similar issue.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
➜ gitlab git:(b5d10640ac86) curl --silent --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "https://gdk2.test:3444/api/v4/application/settings" | jq '.silent_mode_enabled'
false
➜ gitlab git:(b5d10640ac86) curl --silent --request PUT --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "https://gdk2.test:3444/api/v4/application/settings?silent_mode_enabled=true" | jq '.silent_mode_enabled'
true
➜ gitlab git:(b5d10640ac86) curl --silent --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "https://gdk2.test:3444/api/v4/application/settings" | jq '.silent_mode_enabled'
true
➜ gitlab git:(b5d10640ac86) curl --silent --request PUT --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "https://gdk2.test:3444/api/v4/application/settings?silent_mode_enabled=false" | jq '.silent_mode_enabled'
false
➜ gitlab git:(b5d10640ac86) curl --silent --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "https://gdk2.test:3444/api/v4/application/settings" | jq '.silent_mode_enabled'
false
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Update to this branch, run migrations
- Sign in
- In your primary site,
gdk tail rails-background-jobs | grep "Delivered\|Skipped delivery"
- Trigger various emails. For example, comment on an issue.
- Notice log output like
Delivered mail 6424f56bcc078_6e8f3bc4-3a@Michaels-MBP.mail (2.3ms)
. And<gdk url>/rails/letter_opener
should show delivered emails. - Get a personal access token for your user
export GITLAB_TOKEN=<your token here>
- Use
curl
commands as shown above to enable Silent mode - Wait about a minute (I am not sure why there is a delay for Silent mode toggling to affect email delivery)
- Attempt to trigger various emails again
- Notice log output like
Skipped delivery of mail 6424f5311896f_6cca3bc4-3a@Michaels-MBP.mail as
perform_deliveriesis false
. And emails should stop appearing in<gdk url>/rails/letter_opener
. - Disable Silent mode
- Wait about a minute (I am not sure why there is a delay)
- Test again, it should allow email delivery again
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Michael Kozono