PlansFinder should search for plans in Zuora if not found within eager loaded plans
Problem
If a product rate plan is not in the list of preloaded plan ids in PlansFinder
and this plan id is used in PlansFinder.find
, the result is nil
, even if the product rate plan exists in Zuora. This can lead to errors when a subscription is created or updated which uses a product rate plan not listed in the PlansFinder. The results in the Zuora worker failing to process the callout which means no Order record is created for the subscription.
I noticed this when testing an MR where we were adding a new SKU to CustomersDot. See this discussion for more info. This happens quite often as can be seen by these Sentry errors:
- https://sentry.gitlab.net/gitlab/customersgitlabcom/issues/2446974
- https://sentry.gitlab.net/gitlab/customersgitlabcom/issues/2458737
- https://sentry.gitlab.net/gitlab/customersgitlabcom/issues/2465402
- https://sentry.gitlab.net/gitlab/customersgitlabcom/issues/2474979
- https://sentry.gitlab.net/gitlab/customersgitlabcom/issues/2069046
- https://sentry.gitlab.net/gitlab/customersgitlabcom/issues/2374919
Proposal
One way to fix this issue would be to update the PlansFinder.find
method to fallback to searching Zuora if the product rate plan isn't found within the seat of eager_loaded_plans
. Since the product catalog is cached locally anyway, this wouldn't be a very expensive operation as it would have been when this eager loading was originally introduced.
In fact, this eager loading is probably not necessary at all, and we have an issue to investigate removing it. While that would be a better longer term solution, this could be a nice, quick short term solution for this problem. If #2680 (closed) get's prioritized first, we can close this issue.
Result
No more errors like the ones shown above. We could resolve those in Sentry when this is finished.