Add trial plans to fix outage error
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
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:
-
https://customers.staging.gitlab.com/plans.json?plan=free -
valid
-
https://customers.staging.gitlab.com/plans.json?plan=ultimate -
valid
- https://customers.staging.gitlab.com/plans.json?plan=ultimate_trial - invalid and returns the following response:
{"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:
After:
How to set up and validate locally
- Enable simulate saas flag
- Navigate to
Settings
->General
and expand Account and limit group - Enable the
Allow use of licensed EE features
feature underCheck feature availability on namespace
plan section - Create a group and switch the plan to
ultimate_trial
and notice that the group's billing page shows the customers portal outage error. - 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.
-
I have evaluated the MR acceptance checklist for this MR.