Repository navigation
Description
Part of #9
Story
As a namespace owner, I want to request an appropriate tier with clear approval routing.
Business value
The plan (#6) sets this release exit for phase 3: "prod placement uses stored snapshots without a Thanos call; fresh-capacity rnd medium auto-approval succeeds; oversized quota change requires platform approval."
Context
The capacity guard of auto-approval always passes today (#62). The quota writes beyond the namespace PATCH are not built (build-tracker.md, "Not built, by area").
Acceptance criteria
- Quota listing/search/filter/sort/CSV follows shared contract, shown by
cmapi/tests/core/test_render_listquery_config.py::test_paging_forward_and_backand::test_export_same_orderfor the shared contract, and a new test incmapi/tests/service/for the quota endpoints, not written yet - Existing-namespace changes use live 14-day usage; insufficient data is explicit, shown by a new test in
cmapi/tests/service/, not written yet - Oversized changes route to platform approval, shown by
cmapi/tests/service/test_flow.py::test_large_namespace_needs_a_platform_leadandcmapi/tests/core/test_approvals.py::test_quota_increase_and_capacity_warn_add_up - Auto-approval requires fresh placement, all guards and all three switches; each switch can stop it, shown by
cmapi/tests/core/test_approvals.py::test_auto_approval_guards,::test_team_allowance_and_kill_switchand::test_missing_capacity_facts_do_not_auto_approve - Portal quotas and capacity use live APIs, shown by a new test in
cmapi-portal-ui/tests/, not written yet
Tasks
- Build the quota endpoints and the usage analysis (Wave 7).
Out of scope
- The source states none for this story.
Evidence
- None yet.
Definition of done
- Mockup approved, or the work has no screen and no API shape
- Draft pull request open
- Build: tests fail before the change and pass after it
- Documented where a reader looks for it
- Review ruled
- Merged with its proof
- Released on the default branch
- The owner approves, after a comment cites the proof for each criterion and its cluster
Class
INV. The story adds a new capability to the product.
Source
Status: Draft backlog. No sprint commitment.
Owner in Paperclip: Ahsoka. Ahsoka mentors Luke and assigns bounded engineering work after technical review.
Source: OBI-33.
Epic: #9. Plan, release windows, and review gates: #6.
Dependencies: #8 (OBI-26), OBI-19, OBI-20.
Planned story; phase 3, provisional 8 points (Ahsoka/Yoda to validate).
- Attach automated or reproducible evidence for each criterion; cover denial/failure paths.
- Read the plan; Yoda owns design choices. Keep this in backlog until prerequisite phase evidence is accepted. Ahsoka may split and delegate to Luke with mentorship.
Language acceptance criterion
Before sprint entry, the owner must define technical terms and attach language review evidence for this text revision.
Use simple-english 2.1.1, Strict mode. Index #6 records the vocabulary source and review limits.
The source criteria remain unchanged. Language review remains open.
Activity
ephico2real2 commentedon Nov 14, 2026
#232: name the production environments in instance.yaml instead of the literal
prod(recommendation recorded by #222).ephico2real2 commentedon Nov 19, 2026
Work tag In-Progress. Evidence: merged part(s) of this issue: #247, #245, #240, #234, #233. The issue stays open for the rest; status:partly-fixed. Moved up from Backlog (records sweep 2026-11-19).
ephico2real2 commentedon Nov 26, 2026
Filed under this story: #713 (Low, Backlog), the local reference planner's copy of #710's cause, found while fixing #710.
#22 review fixes: the negative SubjectAccessReview checks the real bo…
#22 record: docs/13 test
Merge pull request #726 from ephico2real2/deploy/crc-usage-thanos
ephico2real2 commentedon Nov 27, 2026
The owner approved closing this story on 2026-11-27, after CRC run 45 (main 96b1621). The coordinator first overstated which criteria run 45 proved live, corrected it, and the owner approved again on the corrected picture: each criterion's named test is its proof (as the criterion says), live CRC evidence is added where it exists, and each test-only part is marked below.
Story #22, Quota plans, usage analysis and auto-approval: proof for each acceptance criterion.
Part of #9. Built by #707 (live usage, verdicts; also closes #310 and #712), #726 (CRC reads usage from Thanos), #734 (the reader's own grants on every cluster and the import check; also closes #724), #740 (docs/21) and #725 (reservations, which the auto-approval guard counts). All merged on 2026-11-26. Earlier PRs built the quota listing, approval rules and portal tabs (criteria 1, 3, 4 and 5); the issue's comments name none of them, so see "Not found in the sources".
Where the proof comes from:
workbench/cmapi/ob1-run45/resume.md, logs inob1-run45/logs/. Read-only beyond the deploy and the reader's grants: dry runs only, noIdempotency-Key.workbench/cmapi/story-audit/audit.md) for older CRC runs 13, 15, 23, 24 and 32. Those run files are no longer on disk (removed in a cleanup); these lines rest on the audit's citations.Summary:
insufficient-dataanswer, yes; real figures, noCriterion 1
Built by: an earlier PR (not named in the sources). #707 added the verdict fields, the facets
quota-tight,oversized,idleandneeds-attention, theverdict=filter and the CSVverdictcolumn.Tests:
cmapi/tests/core/test_render_listquery_config.py::test_paging_forward_and_backand::test_export_same_order(both exist on main).cmapi/tests/service/test_quota_read_seam_403.py,test_list_filters.py(2 failed before #310 Live 14-day usage on a quota change, the usage verdicts and the Quotas tab's Verdict column #707, passing after), andtest_usage_verdicts_310.py::test_the_attention_states_and_the_verdict_filter_list_their_rows.Live proof, cluster CRC:
logs/c45b-sweep.out:GET /api/v1/quotas200, 7 rows, each with its verdict.Not proven live in runs 45 and 45b: CSV export. The CSV proof is the run 15 audit line.
Criterion 2
Built by:
UsageSourceinterface:PromUsageruns docs/03's PromQL over aMetricsSource(capacity/thanos.pyis the real one);NoUsageis used whenusage.sourceisnone. A plan of a quota change carriesusage(now, 7-day average, 14-day p95, peak, coverage), cached 10 minutes. Factsusage(ok,insufficient-data,unavailable) andrequestToPeakRatio. "Insufficient data" covers no source, under 80% of the window's 4,032 five-minute steps, a missing sample, NaN, and a quota with nokube_resourcequotahistory. The dailyusage_sweepstores verdicts inanalysis_sweepsandnamespace_verdicts(migration 0010).capacity.yamlgetsusage: {"source":"thanos"}; the reader's grants inopenshift-monitoring(docs/13 step 7).system:authenticated; a missing grant is ausage:finding and the cluster's usage isunavailable.docs/21-usage-from-thanos.md(docs only).Tests:
cmapi/tests/service/test_usage_verdicts_310.py(9 tests in the PR; the file has 12 on main), includingtest_with_no_usage_source_every_row_says_insufficient_data_and_why,test_a_quota_change_plan_carries_the_live_14_day_usage,test_a_plan_with_no_usage_source_says_insufficient_data_and_adds_nothing,test_a_plan_whose_usage_read_fails_needs_a_platform_approval,test_a_failed_sweep_gives_insufficient_data_for_the_day_and_old_verdicts_expire,test_the_daily_sweep_stores_each_verdict_and_the_list_joins_it.cmapi/tests/core/test_usage_verdicts_310.py(38 passed in the PR): the verdict rules at each boundary, coverage 0.8 against 0.7999, no source, NaN, a warned query, the cache, the PromQL.cmapi/tests/service/test_usage_review_707.py(review fixes).test_crc_reads_usage_from_thanos_and_kind_reads_noneandtest_crc_reader_may_query_thanos_through_the_namespaced_monitoring_role_alonefailed on main's manifests and pass;deploy/tests/crc-scripts-test.sh279 ok;doc13-test.py0 failed, 0 mutants survived.cmapi/tests/service/test_reader_thanos_grants_724.py: 18 failed, 1 passed before; 19 passed after. After review, reviewer 2's run: 367 service tests passed;tests/core843 passed;crc-scripts-test.sh287 ok.Counts for #707: before the change the usage test files failed to collect (
No module named 'cmapi.capacity'); after,tests/core813 passed (113 skipped); 367 service tests passed over the related files. Review record: 247 service and 842 core passed. Review fixes: H3 (High), the httpthanosUrl, redaction, bounded reads, malformed answers, usage figures not stored, ceiling hours.Live proof, cluster CRC (run 45 and 45b):
system:authenticatedfalse; after,truewith the reason namingRoleBinding "cmapi-reader-thanos-route/openshift-monitoring","cmapi-reader-metrics-api/openshift-monitoring"and"cmapi-reader-grant-check/openshift-monitoring". Scope control:getprometheuses/apik8sinopenshift-user-workload-monitoring: falsereader-before.txt,reader-after.txt,reader-after-sars.txtcount(kube_resourcequota)= 108, through the reader-discovered Route,partial_response=false, dedup, 10-minute reader token on stdinreader-after.txtGET /api/v1/clustersascmapi.viewerandcmapi.operator: 200; CRCconnected, findings[](0usage:)c45-clusters.outPATCHcmap-live-g-dev?dryRun=true, small to medium: 200.usage.state=facts.usage=insufficient-data, reason "Thanos has no running-pod sample of this namespace in the last 14 days.", figures null. Notunavailable: Thanos answeredc45-quota.outusage_sweepusage_sweepCRCstatus complete, namespaces 7.analysis_sweeps: CRC 2026-11-27, complete, step 5m, 7 namespaces.namespace_verdicts: 14 rows (7 namespaces x CPU, memory), eachinsufficient-data/info with the Thanos reason, window 14d. Next job 11208 due 2026-11-28 08:25Zc45b-sweep.out,c45-sweep/cmapi-configholdsusage: {"source":"thanos"}; withnonethe reason would be "not configured"c45b-sweep.outNot proven live: real figures. Every managed namespace on CRC has 0 pods (
logs/managed-pods.txt), so Thanos has no sample and every answer isinsufficient-data. Theokstate and its figures (7-day average, p95, peak,requestToPeakRatio) are proven by service and core tests against a fake that answers the real PromQL. A one-pod run is scheduled for real figures: the owner authorised one tiny pod,cmapi-usage-probe, incmap-live-g-dev(run 46 brief; no result yet). Theunavailablepath is also tests only.Not live for 4.18: the owner has no OpenShift 4.18 cluster. The 4.18 proof is the primary sources (
openshift/cluster-monitoring-operatorrelease-4.18, identical Role and Route check as 4.22), recorded on #726 and indocs/reviews/2026-11-26-reader-thanos-baseline/README.md.Criterion 3
Built by: earlier PRs (not named in the sources); #707 adds the
usage == "unavailable"rule that addsapprover-platformto each approval-rules.yaml.Tests (both exist on main):
cmapi/tests/service/test_flow.py::test_large_namespace_needs_a_platform_leadcmapi/tests/core/test_approvals.py::test_quota_increase_and_capacity_warn_add_uptest_a_plan_whose_usage_read_fails_needs_a_platform_approvalLive proof, cluster CRC (from the story audit; the run files are no longer on disk): a large namespace waited for
approver-platformand was approved: run 13 l.12 (req-20261116-0003). A sensitive team change took oneapprover-platformslot: run 32 l.153-156.Runs 45 and 45b ran one quota-change dry run: "Approval dev-change, no slot added; capacity fits". That is a small change and does not test the oversized route.
Criterion 4
Built by: earlier PRs for the rules and switches (not named in the sources). #725 makes the capacity guard count open requests' holds, so two requests that each fit alone are not both auto-approved.
Tests:
cmapi/tests/core/test_approvals.py::test_auto_approval_guards,::test_team_allowance_and_kill_switch,::test_missing_capacity_facts_do_not_auto_approve(all exist on main; the guard test includes the casecapacityFresh: False).cmapi/tests/service/test_capacity_reservations_62.py::test_the_auto_approval_guard_counts_the_holds_of_open_requests. Before the fix: "second createapprovedinstead ofpending_approval"; after: passes.Live proof: none. Auto-approval was not exercised on CRC in run 45 or 45b: no request was created. The story audit also lists this criterion as CI only. The reason in the run record: runs 45 and 45b allowed dry runs only. This criterion has test proof only.
Note on "fresh": the guard reads the fact
capacityFresh, which comes from the capacity answer (cap.fresh,test_capacity_unknown_393.py). The stored-snapshot freshness of #738 is checked by placement (criterion 2 of #21), not read by this fact. Confirmed by the coordinator in the code: the plan's facts set"capacityFresh": cap.fresh(core/pipeline.py).Criterion 5
Built by: earlier portal PRs for the first tabs (not named in the sources); #707 (Quotas tab: Verdict column, chips, "Live usage · last 14 days", callouts); #738 (Capacity tab's Snapshot column and pill; New namespace's placement preview).
Tests:
cmapi-portal-ui/tests/api/portal.test.mjs: "310 Quotas usage" (a row's verdict and reason; a plan withokusage, cell by cell; insufficient data; unavailable); "310 Quotas at 1440 and 390 px" (no sideways scroll; axe with no serious or critical finding); check 303 (placement and Capacity, 390, 820 and 1440 px).npm testexit 0: 141 checks in the #707 PR; 199 ok in the #738 review.Live proof, cluster CRC:
logs/ui45b-capacity.out: Capacity tab ascmapi.requester, 6 checks, ALL PASSED, installed Chrome, 1440 and 390 px;GET /api/v1/capacity200; the cell equals the API's snapshot.logs/ui45b-new.out: the placement preview called the livePOST /api/v1/capacity:place?dryRun=true.Not proven live in run 45b: the Quotas tab itself. Run 45b did not drive it. The Quotas tab's live proof is run 15 (before #707). Its new Verdict column and "Live usage" panel were tested against the stand-in API only (the #707 screenshots use fake figures and the "no source" state).
Not found in the sources
Open follow-ups
sweeps:run. namespace_verdicts is not partitioned by month as docs/03 says #705: monthly partitions ofnamespace_verdicts. [Draft] OBI-42: Epic 6: Post-launch recommendations and rightsizing #12: recommendations.For the owner
cmapi-usage-probe, authorised on 2026-11-27).ephico2real2 commentedon Dec 1, 2026
Usage probe result, CRC, 2026-11-30. One pod,
cmapi-usage-probeincmap-live-g-dev(10m CPU, 16Mi, owner-approved on 2026-11-27), ran from 2026-11-27T14:53:49Z. Each dailyusage_sweep(worker log:status complete, namespaces 7) stored these verdicts, read-only fromnamespace_verdicts:insufficient-data: "Thanos has no running-pod sample of this namespace in the last 14 days."insufficient-data: "Pods were seen in 5.23% of the 14-day window's 4,032 five-minute steps; 80% are needed."What this proves live: Thanos samples the namespace's pod, the coverage grows by about 7.15 points a day, and below 80% the answer stays an explicit
insufficient-datawith the measured coverage, never a figure.Real
okfigures would need about 11 days of the pod running, to around 2026-12-08. The pod was approved for a day, so it has been deleted (NotFound confirmed, 2026-11-30). Theokpath stays proven by the service and core tests, as the closing comment says.ephico2real2 commentedon Dec 1, 2026
Follow-up after this story closed: PR #771 merged as
049077f0. It closes #256 (quotaBelowRequestednow reads the live quota's use when a sizable bound is lowered; a use that cannot be read fails closed; a first quota is untouched, as the #710 review decided) and #258 (the team label is metadata-keys.yaml'steamKey). The approval facts behind this story's auto-approval now hold. Record:docs/reviews/2026-12-01-issue-256-258/.