epam / cloud-pipeline

Cloud agnostic genomics analysis, scientific computation and storage platform
https://cloud-pipeline.com
Apache License 2.0
144 stars 58 forks source link

Cloud Pipeline shall allow users to configure spending quotas #762

Open NewOlya opened 4 years ago

NewOlya commented 4 years ago

Background

The Cloud-Pipeline Billing (spending reports) is implemented and users can view their spendings for different periods. Now, it would be convenient for administrators to have the ability to configure spending quotas - to manage money limits of the platform usage and define different restrictions for users when these limits are achieved that may allow to reduce global spending of the Platform usage.

Approach

  1. We should add to the Billing page two tabs - Spendings and Quotas. To the Spending tab, all currently displayed forms with the Platform billing reports should be placed. In the Quotas, forms with quotas configuring described below should be placed.
  2. Only admins and users with the ROLE_BILLING_MANAGER shall have the ability to configure quotas and have the access to the Quotas tab
  3. There shall be the ability to configure quotas on the following entities:
    • whole Platform - summary spendings on compute instances and data storages
    • separately on compute instances - spendings on jobs running
    • separately on storages - spendings on data storing
  4. Additionally for each entity (except whole Platform), there shall be the ability to specify the following types of quotas:
    • User - quota that should be applied to a specific user
    • User group/role - quota that should be applied to a specific group/role
    • Billing Center - quota that should be applied to a specific billing center. This is a different dimension of the users grouping. Typically this is a meta-group, which is not used to apply security permissions
    • Overall - the overall budget for the current entity Example of Quotas tab view (when no quotas is configured yet): image
  5. There shall be the ability to configure time period for the quotas setting. Possible values should be: month/quarter/year. The default time period should be one calendar month. There shall not be the ability to set different periods for different quotas. Only one period type can be set at once - it should be applied for all existing quotas
  6. For each specific configured quota, there shall be the ability to specify the thresholds in percent (e.g. 50% / 75% / 100%), upon reaching which specific actions shall be performed by the platform. Thresholds shall be specified manually, value can be more than 100%. For each quota, any count of thresholds can be set.
  7. For each quota and threshold, there shall be the ability to configure the action that will be performed when the specified limit (threshold) will be reached.
    • For Compute instances entity, there should be:
      • "Notify" (default) - if sets, corresponding users will be only notified by email about the threshold excess. The access to the platform shall not be restricted
      • "Read mode & disable new jobs" - if sets, corresponding users will be notified by email about the threshold excess and then they will have the "read" access to the platform, they will not be able to launch runs:
      • no new runs can be launched (by these users)
      • all previously launched runs (of these users) will continue their performing
      • all previously paused runs (of these users) can not be resumed, i.e. RESUME operation for them shall be declined
      • "Read mode & stop all jobs" - if sets, corresponding users will be notified by email about the threshold excess and then they will have the "read" access to the platform, they will not be able to launch runs:
      • no new runs can be launched (by these users)
      • all previously launched runs (of these users) will be stopped immediately
      • all previously paused runs (of these users) shall be ignored (not terminated), but also they can not be resumed
      • "Block" - if sets, corresponding users will be blocked and they will not have any access to the platform. Note: this action shall not be applied to admin users. After a time period for which the quota is set, full access to the platform shall be returned to users according to their permissions. Another way to return access for users - to enlarge the exceeded quota. In both cases, corresponding users should be notified about restrictions cancelling.
    • For Data storages section there should be:
      • "Notify" (default) - if sets, corresponding users will be only notified by email about the threshold excess. The access to the platform shall not be restricted
      • "Read mode" - if sets, corresponding users will be notified by email about the threshold excess and then they will have only the "read" permissions to all the storages, on which they have had any access.
      • "Block" - if sets, corresponding users will be blocked and they will not have any access to the platform. Note: this action shall not be applied to admin users. After a time period for which the quota is set, full access to the platform shall be returned to users according to their permissions. Another way to return access for users - to enlarge the exceeded quota.
    • Also for each quota, there shall be the ability to specify user(s ) for whom notifications will be sent about the threshold(s) excess Example of the pop-up Add quota for a user for the Compute instances section: image
  8. The level-priority for the quotas shall be applied in the following order (by descending):
    • whole Platform
    • for each entity - Compute instances/Data storages - independently:
      • Overall
      • Billing center
      • User group/role
      • User
        At the same time:
    • any set quota should not rely or affect to any other. I.e. it should be possible to set the quota 1000 for a user and only 100 for the billing center of that user
    • if quota at any level is not set - the quota of the higher level should be applied
  9. For the notifications sending, a new notification type should be added to the EMAIL NOTIFICATIONS section of the System settings, e.g. BILLING_QUOTA_EXCEEDING. This template should be used at case of reaching any threshold of any quota. Notification type should include:
    • checkbox to enabled sending
    • field to specify an email subject
    • field to specify an email body Template should include the following info:
    • quota section (entity)
    • quota type
    • full quota size
    • reached threshold
    • upcoming action
  10. There shall not be the ability to add several quotas to the same user/group/billing center, etc.
  11. (TBD) There shall be the ability to create and use templates of configuration settings for the thresholds and applying actions.

Use cases

Add quota for the whole Platform

To add quota for a whole Platform:

  1. Admin or billing manager should click the configure button in the Global section at the Quotas tab
  2. The pop-up shall appear: image This pop-up shall contain:
    • Quota period - dropdown list for specifying a time period for the quotas setting. This value should be used for all quotas (it shall not be configured separately)
    • Quota - field for a numeric value of the configured quota
    • Informed users field - field for the specifying users/groups who will be notified in cases when any quota threshold will be reached. Field should support multi values
    • Actions - section to specify quota thresholds and actions on reaching these thresholds
    • Remove button - to remove set quota and close the pop-up
    • Save and Cancel buttons - to save/cancel changes
  3. Admin or billing manager should specify quota and informed users
  4. Then, action(s) should be specified:
    • Threshold - field to specify a numeric threshold value. When the threshold is specified - near the field, the value in currency should appear (calculated as quota * threshold / 100)
    • Action - dropdown list to select an action on the threshold reaching. To create an additional pair threshold-action - click the "+ Action" button. To delete a pair threshold-action - click the corresponding cross-button near it.
  5. After the form is filled in, changes should be saved, e.g.: image Note: to save the quota, shall be specified: quota, informed users and at least one pair of threshold-action

After the saving, the following info should additionally appear in the Global section at the Quotas tab:

To view the Platform quota details, user should click the quota row or a link with a count of configured pairs of threshold-action. Quota can not be edited, only removed.

Add quota to overall of the entity

To add quota to overall the entity (Compute instances or Storages):

  1. Admin or billing manager should click the Add quota button in the corresponding section at the Quotas tab
  2. The pop-up shall appear similar to the described in section (above)[#quota-platform]. A single difference - lack of the Quota period field
  3. Admin or billing manager should specify quota, informed users and add pairs of threshold-action
  4. After the form is filled in, changes should be saved. Note: to save the quota, shall be specified: quota, informed users and at least one pair of threshold-action
  5. The corresponding info should additionally appear in the Overall section at the Quotas tab, e.g.: image Note: the "Add quota" button should disappear as there is only one quota can be configured overall of the entity.

To view the overall quota details, user should click the quota row or a link with a count of configured pairs of threshold-action. Quota can not be edited, only removed.

Add quota to billing center

To add quota to a billing center:

  1. Admin or billing manager should click the Add quota button in the "Billing centers" section
  2. The pop-up shall appear similar to the described in section (above)[#quota-platform]. With the following differences - lack of the Quota period field and presence of the field to specify a billing center for which a quota is configuring, e.g.: image
  3. Admin or billing manager should specify the billing center (multi values are not supported), quota, informed users and add pairs of threshold-action. Note: even if informed users are not specified - notifies shall be sent to all users in that billing center at any threshold reaching
  4. After the form is filled in, changes should be saved.
  5. The corresponding info (billing center, quota, quota time period, count of configured pairs of threshold-action) should additionally appear in the Billing centers section at the Quotas tab, e.g.: image

To view created quota details, user should click the quota row or a link with a count of configured pairs of threshold-action. Quota can not be edited, only removed. To add quota for other billing center, user should click the Add quota button in the "Billing centers" section and repeat the described procedure.

Add quota to group

Adding a quota to the users group is similar to described in section about adding a quota to Billing center. With the difference - instead the field to specify a billing center here the field to specify the users group.

Note: even if informed users are not specified at quota saving - notifies shall be sent to all users in that group at any threshold reaching.

Add quota to user

Adding a quota to the user is similar to described in section about adding a quota to Billing center. With the difference - instead the field to specify a billing center here the field to specify the user.

Note: even if informed users are not specified at quota saving - notifies shall be sent to the user for whom the quota is configured at any threshold reaching.

maryvictol commented 2 years ago

@rodichenko The Add quota button should be hidden if Overall quota has been already configured in the correspond section at the Quotas/Compute instances/Storages tab.

maryvictol commented 2 years ago

@mzueva , @sidoruka

maryvictol commented 2 years ago

@mzueva Billing Quota to Billing centers with action Stop all jobs is applied to admin members of Billing center: all active jobs with admin user owners are stopped as well as for non-admin owners when quota is exceeded.

maryvictol commented 1 year ago

Test cases were created by https://github.com/epam/cloud-pipeline/pull/2705 and located here.