Skip to content

Add logic for manual quarterly co-term banner

Corinna Gogolok requested to merge 346260_manual_quarterly_co_term_banner into master

What does this MR do and why?

Part of https://gitlab.com/gitlab-org/gitlab/-/issues/346260

Depends on !75872 (merged) to be merged first

This change will add the backend logic for the manual quarterly co-term banner that will be displayed to offline customers that have restricted internet access. The logic is behind a feature flag.

The banner will only be displayed for customers with a self-managed cloud license but have restricted internet access that prevents their instance to do the quarterly co-term automatically and have to take manual action. The condition to determine an offline customer is still under discussion though and therefore not added yet. Since the feature is behind a feature flag, the missing condition can be added at a later time.

The banner will show up for upcoming quarterly co-terms within the next 14 days (notification window) or for overdue quarterly co-terms.

To see the banner, the customer has to be logged in as an admin and can see the banner on the admin dashboard (/admin) and the subscription page (/admin/subscription).

Please see the issue for more information.

How to set up and validate locally

The code can be tested in the rails console. Two different upcoming reconciliations have to be created to see the two different versions of the banner message.

  1. Start a rails console.
  2. Enable the feature flag: Feature.enable(:automated_email_provision).
  3. Make sure that Gitlab::CurrentSettings.check_namespace_plan? returns false or you won't be able to create a new record GitlabSubscriptions::UpcomingReconciliation record later.
  4. If it returns true, do ApplicationSetting.first.update(check_namespace_plan: false).
  5. Check if you already have a GitlabSubscriptions::UpcomingReconciliation record: reconciliation = GitlabSubscriptions::UpcomingReconciliation.next.
  6. If one exists, update it to display the banner: date = 14.days.from_now; reconciliation.update(next_reconciliation_date: date, display_alert_from: date - 7.days)
  7. If none exists, create one: date = 14.days.from_now; reconciliation = GitlabSubscriptions::UpcomingReconciliation.create!(next_reconciliation_date: date, display_alert_from: date - 7.days)
  8. Call the class Gitlab::ManualQuarterlyCoTermBannerMessage.new(upcoming_reconciliation: reconciliation).message and see the appropriate messages.
  9. Update the reconciliation record from above to be overdue: date = Date.yesterday; reconciliation.update(next_reconciliation_date: date, display_alert_from: date - 7.days)
  10. Call the class Gitlab::ManualQuarterlyCoTermBannerMessage.new(upcoming_reconciliation: reconciliation).message and see the appropriate messages.

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 Corinna Gogolok

Merge request reports