Loading
Add the usage-limit block to the Artifact Registry billing state driver (AR#2019 stack: 3/4)
What does this MR do and why?
This MR adds the usage-limit arm of the Artifact Registry billing state driver: on GitLab.com, the driver sets and lifts the registry's usage-limit block from the CustomersDot verdict. It follows S17 (billing state driver spec). It is part 3 of 4 of the stack and builds on the suspension arm, which is merged.
- Usage-limit arm. On GitLab.com only,
ArtifactRegistry::BillingStateDriverServiceasks CustomersDot (the Customers Portal) for a verdict throughArtifactRegistry::UsageLimitResolverfrom part 1, and callslimit_blockorunlimit_block. Every suspension call of a run goes out before the first resolve call, so a slow CustomersDot never delays a suspension. - Lift sweep. The new
sweepmode reads only thelimit_blockednamespaces and lifts each block that CustomersDot allows again. Part 4 schedules it every 5 minutes. - Feature flag. The new
wipflagartifact_registry_usage_limit_block, off by default and checked per organization, gates the arm. With the flag off, a run lifts every block, because only this driver sets the block. - Metrics. The driver emits
artifact_registry_billing_driver_resolve_unknown_total(answers it cannot map to a verdict) andartifact_registry_billing_driver_runs_total(full runs, labeledfaultedwhen a run had an answer that counts toward the fault alert). Both are documented indoc/administration/monitoring/prometheus/gitlab_metrics.md.
Points for the reviewer:
- The diff adds the limit arm back to part 2. Part 2 merged the suspension-only version of the same class and spec, and this MR adds the limit arm back to them. It also restores four spec lines that part 2 reworded to make sense without the limit arm.
- Alert rules are in a follow-up. This MR ships the series the alerts read. The two alert rules (S17 acceptance 38 and 40) are in the follow-up for the alert rules.
Readings taken where the spec says nothing
- The lift sweep lifts a limit block while the usage-limit flag is off, because only this driver sets the block.
- A
403withusage_not_allowedis an unknown verdict, because S17 lists only a402as blocking. - The
faultedlabel leaves out the three CustomersDot namespace verdicts (402or403withno_billable_source_error,community_plan_errororamazon_q_plan_error), the same set asUsageLimitResolver::Verdict#namespace_verdict?.
S17 rows this MR covers
- Acceptance 29 to 32: blocked, allowed, masked and unknown verdicts in a run.
- Acceptance 35: an unknown verdict does not stop a suspension, and an unreadable plan does not stop the limit block.
- Acceptance 36: the lift sweep.
- Acceptance 39 and the series side of 40: the counted-fault series.
- Acceptance 41: every suspension call before the first resolve call.
- Acceptance 42 and 43: no resolve and no limit call on Self-Managed and in the renewal trigger.
- Acceptance 44 to 46: the two flags, each on its own, and an unusable anchor with the usage-limit flag off.
The stack
- Activation checks and
UsageLimitResolver. - Billing state driver, suspension arm.
- This MR: the usage-limit arm.
- The scheduled workers and the renewal subscription.
References
- S17 (billing state driver spec)
- The registry merge request that added the limit-block endpoints (merged).
- Follow-up: alert rules.
Related to the issue
Screenshots or screen recordings
n/a: this MR changes no frontend code.
How to set up and validate locally
This MR has no user-facing change: the arm runs only behind a flag that is off by default, and nothing schedules it until part 4.
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. The changed spec uses
spec_helperand needs the test database, so CI is its first run. Locally, only RuboCop and the docs linters ran. - Database. No migration and no new query.
- Performance and reliability. On GitLab.com a run makes one resolve call per namespace with a usable anchor, with a 2-second open timeout, a 5-second read timeout, and no retry. A failed call is logged and counted, the run continues, and the next run retries it.
- Security. The resolve call presents the CustomersDot admin headers and never a user token.
- Feature flags.
artifact_registry_usage_limit_blockis new,wip, and off by default.
Edited by Pawel Rozlach