Skip the CustomersDot usage quota call on an offline cloud license
What does this MR do and why?
An instance on an offline license is not meant to contact CustomersDot, and the GitLab Duo Self-Hosted docs say so. Ai::UsageQuotaService#execute still asks CustomersDot for the user's quota on self-managed once its cached answer expires. On an air-gapped network that request can only fail, within the 2-second connect timeout from !258853 (merged), and the check returns success anyway.
This MR returns success before the cache read and the request when the current license is an offline cloud license. A connected legacy license and an online cloud license keep the check, so a 402 or 403 from CustomersDot still blocks them. With no license the check keeps its path. GitLab.com never reaches the branch.
flowchart TD
X["Ai::UsageQuotaService#execute"] --> S{"GitLab.com?"}
S -- yes --> C["Rails.cache, then CustomersDot"]
S -- no --> O{"License.current offline cloud license?"}
O -- "no (online, legacy or none)" --> C
O -- yes --> OK["success, no request<br/>(this MR)"]References
- Resolves https://gitlab.com/gitlab-org/gitlab/-/issues/627285
- Related to https://gitlab.com/groups/gitlab-org/-/work_items/17594
Screenshots or screen recordings
No UI change.
How to set up and validate locally
- In Admin > Settings > Network, expand Outbound requests, select Allow requests to the local network from webhooks and integrations, and select Save changes.
- Start any listener on a free local port.
- Add an offline cloud license. In the Rails console, started with
CUSTOMER_PORTAL_URL=http://127.0.0.1:<port>, runAi::UsageQuotaService.new(user: User.first).execute. It returns success and the listener receives nothing. - Add an online cloud license, or a legacy license, and run it again for a user with no cached answer. The listener receives
HEAD /api/v1/consumers/resolve, as on master.
An AI coding assistant wrote this change. The assistant also checked each claim against the source files this MR cites and ran RuboCop and the documentation linters on the changed files on a GitLab development instance.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.