Skip to content

Add Silent mode application setting

Michael Kozono requested to merge mk/add-silent-mode into master

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:

  1. 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.
  2. 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.

  1. Update to this branch, run migrations
  2. Sign in
  3. In your primary site, gdk tail rails-background-jobs | grep "Delivered\|Skipped delivery"
  4. Trigger various emails. For example, comment on an issue.
  5. Notice log output like Delivered mail 6424f56bcc078_6e8f3bc4-3a@Michaels-MBP.mail (2.3ms). And <gdk url>/rails/letter_opener should show delivered emails.
  6. Get a personal access token for your user
  7. export GITLAB_TOKEN=<your token here>
  8. Use curl commands as shown above to enable Silent mode
  9. Wait about a minute (I am not sure why there is a delay for Silent mode toggling to affect email delivery)
  10. Attempt to trigger various emails again
  11. Notice log output like Skipped delivery of mail 6424f5311896f_6cca3bc4-3a@Michaels-MBP.mail as perform_deliveries is false. And emails should stop appearing in <gdk url>/rails/letter_opener.
  12. Disable Silent mode
  13. Wait about a minute (I am not sure why there is a delay)
  14. 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.

Edited by Michael Kozono

Merge request reports