Skip to content

Add a new service GitlabSubscriptions::CheckLastTermService [RUN ALL RSPEC] [RUN AS-IF-FOSS]

Vijay Hawoldar requested to merge vij-add-subscription-term-service into master

What does this MR do?

When a customer's subscription is due for renewal, they are displayed a banner prompting action.

It was discovered/discussed in https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/2624 that this banner does not take into account that the customer may have already renewed and so incorrectly displays for those that do.

That happens because on GitLab, we only store the current subscription's term dates and currently have no access to whether or not the customer has renewed already, so we need to query our CustomersDot app to retrieve the information needed, i.e. if the namespace has a "future renewal", or in other words, whether or not they're on the last term for their subscription.

We've already added support to query this via GraphQL on CustomersDot (https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/2866), and this MR introduces a new service that can be used to consume that info.

I've opted to use caching here, because we want to careful with how much unneccessary traffic we send to CustomersDot. This caching should mean that we only make one query per day for each expiring namespace

As yet, this service is unused, as I'd like to introduce it behind a feature flag as discussed here: https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/2624#note_516936253

Testing

Testing this can be a little tricky unless you have a working CustomersDot setup (installation docs), or already have a group with a subscription with a future renewal.

If/once you have CustomersDot setup:

  • add a subscription to a namespace
  • renew that subscription so that it has a future dated renewal
  • (skip to here if you already have the correct data setup) modify your current GitLab subscription to have an end date in the near future, i.e. considered expiring:
GitlabSubscription.last.update(end_date: Date.today + 10.days)
  • navigate to your namespace and view the expiry message which in theory you shouldn't see because of the future renewal
  • enable the feature flag to view the result of this MR:
Feature.enable(:gitlab_subscription_future_renewal)
  • refresh your page, the expiry message should no longer be present

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Mayra Cabrera

Merge request reports