pitt-crc / keystone-api

Allocation management API for HPC systems.
0 stars 0 forks source link

Email Notifications for Resource Allocation events #197

Open Comeani opened 4 months ago

Comeani commented 4 months ago

The bank code prior to the last iteration had a system for notifying users when their proposal had either hit a threshold usage relative to the total amount awarded, or hit some threshold number of days into the proposal duration.

Basically having some way to notify users when they need to consider submitting another Resource Allocation Request is the intention of this feature.

Comeani commented 2 months ago

This is becoming an increasingly high priority item, it would be good to focus on it after we have keystone's limit update functionality running in production.

djperrefort commented 2 months ago

User emails should come from LDAP. See https://github.com/pitt-crc/crc-ops/issues/9.

djperrefort commented 2 months ago

Here are some thoughts that have been kicking around a scratch page in my notebook:

Models

Fields, relationships, and methods for each model.

Notification
  • time: DateTimeField
  • message: TextField
  • read: BooleanField
  • user: ForiegnKey(User)
Preference
  • alloc_thresholds:ArrayField(IntegerField)
  • alloc_status_update: BooleanField
  • expiration: BooleanField
  • anything else of use ...
  • user: OneToOneField(User)
DefaultPreference*
  • su_thresholds:ArrayField(IntegerField)
  • expiration: BooleanField

* This table should be a singleton that only ever stores one record.

Shortcuts

Functions that go inside shortcuts.py.

def notify(user: User, message: str) -> None:
    # fetch email address from User table
    # send email (or log error)
    # update notification DB

Endpoints

The endpoints are mostly structured he same way we set up every other app with two exceptions:

  1. Instead of /defaults/ and /defaults/<pk>, there is only a single endpoint /defaults which returns default settings
  2. We should think of the preferred workflow for fetching a user's preferences given their username/UID. The default prferences/<pk> may be cumbersome.
djperrefort commented 2 months ago

Also, it's worth noting in the above that I have used an array field, which means we would have to drop support for SQLite and run PostgreSQL exclusively.

Comeani commented 1 month ago

307 is relevant to this issue, we should see how user alerts might fit into email notifications as we build them out.