Feat(Subscripion activation): add error handling
What does this MR do and why?
Adds handling to following license activation errors:
- Your subscription cannot be located, thrown here
- True-up value validation, thrown here
- Billing value validation, thrown here
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 |
---|---|---|
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.":
-
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.
-
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
-
Apply any valid license at http://localhost:3000/admin/subscription
Simulate subscription overages error:
-
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?]
-
Purchase a license via license dot for less seats than your instance uses ("billable users" at http://localhost:3000/admin/subscription)
-
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:
-
Start a Rails console via
rails c
-
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
-
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
-
Open license dot and renew that license for another period for 20 users, adding 1 or 2 seats for the True-up
-
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.
-
I have evaluated the MR acceptance checklist for this MR.