Check the plan and the terms on Artifact Registry activation (AR#2019 stack: 1/4)

What does this MR do and why?

This MR adds two checks that run when an owner activates Artifact Registry for an organization: a trial plan refusal and a CustomersDot terms check. The checks follow the Phase 2 terms check and trial refusal rows of S10 (activation and deactivation spec). It is part 1 of 4 of the split of the billing state driver MR, and it depends on nothing else in the stack.

  • Trial refusal. ArtifactRegistry::ProvisionNamespaceService refuses activation on a free trial plan (:trial_plan). A paying customer who trials a higher tier is not on a trial plan: ultimate_trial_paid_customer on GitLab.com, or a trial license over an active paid license elsewhere.
  • Terms check. The new ArtifactRegistry::UsageLimitResolver asks the CustomersDot resolve endpoint for a verdict. Activation is refused when the overage terms are not accepted (:overage_terms_not_accepted), and a failed call refuses with :terms_check_unavailable and a try-again message. An offline or legacy license runs no terms check.
  • Billing entity. Off GitLab.com there is no billing group, so provisioning keeps PLACEHOLDER_BILLING_ENTITY_ID.

Points for the reviewer:

  • The checks take effect on merge. They run under the existing shared Artifact Registry flag artifact_registry_ui (default on) and add no flag of their own, as the S10 feature flag section states.
  • A third activation refusal. The S10 terms check row names two outcomes: refuse on overage_terms_not_accepted, and refuse when the call fails. This MR adds a branch for three CustomersDot namespace verdicts (402 or 403 with no_billable_source_error, community_plan_error or amazon_q_plan_error): they refuse with :subscription_not_eligible, a message to contact GitLab Support, and no retry. Every other unknown answer still fails closed with the try-again message.
  • The resolver serves the driver too. Part 3 of the stack uses the same verdict for the usage-limit block, which is why Verdict carries alerting?.
Readings taken where the spec says nothing
  • The checks run after the claim throttle, so a refused claim spends the throttle and a burst of claims cannot flood CustomersDot.
  • A 402 with usage_not_allowed does not refuse activation.
  • A 403 with usage_not_allowed is an unknown verdict, because S17 lists only a 402 as blocking.
  • Off GitLab.com, the resolve request uses the self-managed realm with instance_id, unique_instance_id and the license token header. Neither spec gives this request shape.
Why the namespace verdicts get their own refusal
  • CustomersDot gives the same answer for these three reasons on the next attempt, so a try-again message is not true for them.
  • UsageLimitResolver::Verdict#namespace_verdict? names the same set that the driver's fault alert leaves out, so the activation check and the alert read one predicate.

The stack

  1. This MR: activation checks and UsageLimitResolver.
  2. Billing state driver, suspension arm, behind artifact_registry_billing_state_driver.
  3. Billing state driver, usage-limit arm, behind artifact_registry_usage_limit_block.
  4. The scheduled workers and the renewal subscription.

References

Related to the issue

Screenshots or screen recordings

n/a: this MR changes no frontend code. The new refusal messages reach the user through the payload errors of the existing activation mutation.

How to set up and validate locally

These steps need a GDK with the Artifact Registry service and CustomersDot configured. They were not run for this MR.

  1. On a GitLab.com-mode GDK, put a top-level group on a trial plan, then run the activation mutation of ee/app/graphql/mutations/artifact_registry/activate.rb for it. Expect the payload error Artifact Registry is not available on a trial plan.
  2. Put the group on Premium and make CustomersDot answer 402 with overage_terms_not_accepted, then run the mutation again. Expect the payload error Accept the overage terms of your subscription to activate Artifact Registry.

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.

  • Quality. All new and changed specs use spec_helper and need the test database, so CI is their first run. Locally, only RuboCop ran.
  • Database. No migration and no new query.
  • Performance and reliability. Activation makes at most one resolve call, with a 2-second open timeout, a 5-second read timeout, and no retry.
  • Security. The resolve call presents the CustomersDot admin headers on GitLab.com and the license token elsewhere, and never a user token. Log lines carry the status and the reason only, never a request header.
  • Feature flags. None new: the checks run under artifact_registry_ui.
  • Changelog. Commit cdad0ae4 carries Changelog: added and EE: true.
Edited by Pawel Rozlach

Merge request reports

Loading
Loading