Skip to content

Feat(Subscripion activation): add error handling

What does this MR do and why?

Adds handling to following license activation errors:

Previously those messages would be handled with a generic error message

Related to #355794

Screenshots or screen recordings

Note: full stops have been removed from the error titles after this discussion

Not Found error Seat overages error True-up value mismatch
Screenshot_2022-09-13_at_19.05.28 Screenshot_2022-09-05_at_15.57.39 Screenshot_2022-09-05_at_14.45.34

How to set up and validate locally

You'll need a GitLab - CDot - ZSim integration working and an account at zuora api sandbox

Ensure that the local instance is run in self managed mode, not in SaaS mode (GITLAB_SIMULATE_SAAS=0)


Reproduce "Your subscription cannot be located.":

  1. When creating an order at zuora, set the "ORDER DATE" (first screen) as a year and a week ago, then proceed normally (leaving all other dates as set by zuora), picking a 1 year Premium self managed subscription.

  2. Alternatively to simulate the error:

    Temporarily change validator at https://gitlab.com/gitlab-org/customers-gitlab-com/-/blob/aa8cf24d1720e16fb1dfd06bb6598d0a1b135a69/app/services/cloud_activations/activate_service.rb to

    - return handle_error('without cloud compatible subscription') unless subscription
    + return handle_error('without cloud compatible subscription') # unless subscription
  3. Apply any valid license at http://localhost:3000/admin/subscription


Simulate subscription overages error:

  1. Temporarily change validator at https://gitlab.com/gitlab-org/gitlab/-/blob/9907da5763147fa2a111c62184019bac2c84234d/ee/app/models/license.rb#L37 to

    - validate :check_restricted_user_count, if: [:new_record?, :reconciliation_completed?]
    + validate :check_restricted_user_count #, if: [:new_record?, :reconciliation_completed?]
  2. Purchase a license via license dot for less seats than your instance uses ("billable users" at http://localhost:3000/admin/subscription)

  3. Apply that license at http://localhost:3000/admin/subscription to get the billable users mismatch error (remove your current subscription if needed)


Reproduce the True-up error:

  1. Start a Rails console via rails c

  2. Update usage count last recorded at date

    HistoricalData.track!
    hd = HistoricalData.last
    hd.recorded_at = 1.week.ago
    hd.save

    e.g. you have 20 seats at this time

  3. Via Zuora sandbox buy a license with less seats than was reported in HistoricalData above, the license should end in recent past (e.g. a day before)

    e.g. you buy 15 seats

  4. Open license dot and renew that license for another period for 20 users, adding 1 or 2 seats for the True-up

  5. Apply the license to the local instance at http://localhost:3000/admin/subscription to get the True-up mismatch error (remove your current subscription if needed)

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 Kos Palchyk

Merge request reports