Skip to content

Add trial plans to fix outage error

sameer shaik requested to merge ss-outage into master

What does this MR do and why?

This MR intends to solve the bug: customers-gitlab-com#3698 (closed) and customers-gitlab-com#4201 (closed)

Some users reported that the group's billing page shows the following error:

The GitLab subscription service (customers.gitlab.com) is currently experiencing an outage. You can monitor the status and get updates at status.gitlab.com.

This happens when the group stays on the premium/ultimate trial plans after the trial expiry date. The index method in the billings_controller class renders the customers_dot_unavailable page, when the GitlabSubscriptions::FetchSubscriptionPlansService call fails to receive a successful response.

ee/app/controllers/groups/billings_controller.rb:

  def index
    @hide_search_settings = true
    @top_level_group = @group.root_ancestor if @group.has_parent?
    relevant_group = (@top_level_group || @group)
    current_plan = relevant_group.plan_name_for_upgrading
    @plans_data = GitlabSubscriptions::FetchSubscriptionPlansService
      .new(plan: current_plan, namespace_id: relevant_group.id)
      .execute

    unless @plans_data
      render 'shared/billings/customers_dot_unavailable'
    end
  end

GitlabSubscriptions::FetchSubscriptionPlansService fails to receive a successful response in the following scenario:

It seems like this service sends a request to the customer portal application to get the plan information based on the given params(plan). The param plan is determined based on the value returned by the plan_name_for_upgrading method in the namespace model.

    current_plan = relevant_group.plan_name_for_upgrading

    @plans_data = GitlabSubscriptions::FetchSubscriptionPlansService
      .new(plan: current_plan, namespace_id: relevant_group.id)
      .execute

plan_name_for_upgrading:

This method returns a free plan value if the namespace is on a trial plan. It seems like it was set-up in this way so we can successfully query the customers portal.

  def plan_name_for_upgrading
      return ::Plan::FREE if trial_active? 
      actual_plan_name
    end

Example:

The /plans endpoint is not aware of any trials plans:

{"errors":{"message":"key not found: \"ultimate_trial\"\nDid you mean?  \"ultimate_saas\""}}

As the /plans endpoint is not aware of the trial plans, the call fails and the UI renders customers_dot_unavailable page(which is incorrect). This MR adds a minor change to the plan_name_for_upgrading method to return free plan for all the available trial plans i.e premium_trial and ultimate_trial.

return ::Plan::FREE if trial_active? || ultimate_trial_plan? || premium_trial_plan?

This always sends a valid param to the customer portal application's /plans endpoint and the caller gets a successful response.

Screenshots or screen recordings

Before:

Screenshot_2022-10-25_at_11.06.15_PM

After:

Screenshot_2022-10-25_at_11.07.47_PM

How to set up and validate locally

  1. Enable simulate saas flag
  2. Navigate to Settings -> General and expand Account and limit group
  3. Enable the Allow use of licensed EE features feature under Check feature availability on namespace plan section
  4. Create a group and switch the plan to ultimate_trial and notice that the group's billing page shows the customers portal outage error.
  5. Switch to feature branch and notice that the billing page shows the correct details instead of customers portal outage error.

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 sameer shaik

Merge request reports