fermitools / managed-tokens

Managed Tokens service for FIFE Experiments at Fermilab
Apache License 2.0
0 stars 0 forks source link

Added ability to disable notifications globally or by service #94

Closed shreyb closed 3 months ago

shreyb commented 3 months ago

Closes #92

Summary

Rather than allow operators to not specify any email, I added the ability here to allow the administrators to disable notifications either globally or by service. There are three methods to disable notifications, in order of precedence:

  1. Flag: using the --dont-notify or --disable-notifications flag. This will override (2) and (3), and will disable all notifications for that run.
  2. Configuration at service-level: This is accomplished using the disableNotificationsOverride entry, set to true/false in the role-level configuration in the configuration file.
  3. Configuration at the global-level: This is accomplished using the disableNotifications entry in the configuration file.

Details on precedence

(1) above is simple - it always wins if either version of that flag is set, and no notifications will be sent.

(2) and (3) are a little tricky. The default behavior is to always send notifications (disableNotifications is unset or false in configuration file). Here is a table of possible global and service-level values of disableNotifications and disableNotificationsOverride, and the resultant behavior of whether the code will send Admin or Service level notifications.

disableNotifications disableNotificationsOverride Admin Notifications Sent Service-level notifications sent
unset/false unset/false yes yes
unset/false true yes (but not for disabled service) no
true unset no no
true true no no
true false yes (for only overridden service) yes

Note that in the above table, overrides can be set on more than one service, and these rules apply equally to all services. So, for example, in a three-service configuration, if notifications are disabled globally, but two services indicate that notifications should be sent disableNotificationsOverride: false, then the admin notifications are sent for ONLY those two services, and the service notifications are sent for those services as well. The admin notifications will not contain any errors for the third service, and a service level email for that third service will not be sent.

Testing