Skip to content

Exclude expired subscriptions from seat count usage alerts

Josianne Hyson requested to merge jh-seat_count_alert_fixes into master

What does this MR do and why?

Part of: #348481 (closed)

Update the logic on when to show the seat count usage alerts to;

  1. Exclude trial subscriptions
  2. Exclude expired subscriptions
  3. Cache nil responses from fetching the subscription on CustomersDot (ie, there is no active subscription)

This will reduce the number of useless calls CustomersDot which will help the pages that this alert is rendered on load faster.

How to set up and validate locally

Have both Gitlab and the CustomersDot instance running. The GDK should be running with GITLAB_SIMULATE_SAAS=1

  1. Create a new group with one member
  2. Purchase a subscription for the group with three seats
  3. Enable the feature flag for the group
    • Feature.enable(:seat_count_alerts, group)
  4. Add a developer to the group
  5. Update the namespace statistics
    • UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker.new.perform
  6. View the group homepage - the alert should be displayed
  7. Clear the cached result
    • Rails.cache.delete("subscription:eligible_for_seat_usage_alerts:namespace:#{gitlab_subscription.cache_key}")
  8. In the CustomersDot console, delete the Order record for the corresponding subscription (to test no-subscription, or future dated subscription in CustomersDot case)
  9. Reload the group homepage - alert should not be displayed and there should be a log of the graphql eligibleForSeatUsageAlerts request in the CustomersDot console
  10. Clear the cached result
    • Rails.cache.delete("subscription:eligible_for_seat_usage_alerts:namespace:#{gitlab_subscription.cache_key}")
  11. Expire the subscription (to test the expired subscription case)
    • gitlab_subscription.update!(start_date: 2.years.ago, end_date: 1.year.ago)
  12. Reload the group homepage - alert should not be displayed and there should not be a log of the graphql eligibleForSeatUsageAlerts request in the CustomersDot console

You can also create a trial subscription for a group, enable the feature flag and ensure there are no requests to CustomersDot.

Recording of the above steps:

Get alert to display:

CleanShot_2022-06-15_at_13.12.15-converted_4

Verify changes in this MR:

CleanShot_2022-06-15_at_13.12.15-converted_5

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 Josianne Hyson

Merge request reports