Skip to content

[Draft] OBI-33: Quota plans, usage analysis and auto-approval #22

Done
4 of 7 issues completed
Done

Description

@ephico2real2

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_back and ::test_export_same_order for the shared contract, and a new test in cmapi/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_lead and cmapi/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_switch and ::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.

Sub-issues

Sub-issues

4 of 7 Issues completed
Loading 7 sub-issues

Activity

  1. added
    Backlog
    class:INV
    status:open
    story
    on Nov 13, 2026
  2. ephico2real2 commented on Nov 14, 2026

    @ephico2real2
    OwnerAuthor

    #232: name the production environments in instance.yaml instead of the literal prod (recommendation recorded by #222).

  3. added
    In-Progress
    status:partly-fixed
    and removed
    status:open
    Backlog
    on Nov 19, 2026
  4. ephico2real2 commented on Nov 19, 2026

    @ephico2real2
    OwnerAuthor

    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).

  5. ephico2real2 commented on Nov 26, 2026

    @ephico2real2
    OwnerAuthor

    Filed under this story: #713 (Low, Backlog), the local reference planner's copy of #710's cause, found while fixing #710.

  6. added 3 commits that reference this issue on Nov 26, 2026
  7. ephico2real2 commented on Nov 27, 2026

    @ephico2real2
    OwnerAuthor

    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:

    • CRC. Run 45 (main 96b1621, deployed 2026-11-27 03:00Z) and run 45b (same build, no redeploy, 14:37Z to 14:42Z). Records: workbench/cmapi/ob1-run45/resume.md, logs in ob1-run45/logs/. Read-only beyond the deploy and the reader's grants: dry runs only, no Idempotency-Key.
    • Service and core tests. PostgreSQL 16 on 127.0.0.1:55432 and the reference venv, no cluster.
    • The story audit (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:

    # Criterion Tests Live on CRC
    1 Quota listing, search, filter, sort, CSV Yes Yes (audit: run 15; run 45b: list 200)
    2 Live 14-day usage; insufficient data explicit Yes Partly: the explicit insufficient-data answer, yes; real figures, no
    3 Oversized changes route to platform approval Yes Yes (audit: runs 13 and 32)
    4 Auto-approval guards and switches Yes No: service tests only
    5 Portal quotas and capacity use live APIs Yes Yes (audit: runs 15, 23, 24; run 45b: Capacity tab)

    Criterion 1

    Quota listing/search/filter/sort/CSV follows shared contract, shown by cmapi/tests/core/test_render_listquery_config.py::test_paging_forward_and_back and ::test_export_same_order for the shared contract, and a new test in cmapi/tests/service/ for the quota endpoints, not written yet

    Built by: an earlier PR (not named in the sources). #707 added the verdict fields, the facets quota-tight, oversized, idle and needs-attention, the verdict= filter and the CSV verdict column.

    Tests:

    Live proof, cluster CRC:

    • Story audit: Quotas tab 24/24 checks in Chromium and in Chrome; CSV export of 5 rows equals the 5 listed: run 15 l.11-13 (525ca27).
    • Run 45b, logs/c45b-sweep.out: GET /api/v1/quotas 200, 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

    Existing-namespace changes use live 14-day usage; insufficient data is explicit, shown by a new test in cmapi/tests/service/, not written yet

    Built by:

    Tests:

    • cmapi/tests/service/test_usage_verdicts_310.py (9 tests in the PR; the file has 12 on main), including test_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).
    • #22: CRC reads usage from Thanos, with the reader's least grant #726: test_crc_reads_usage_from_thanos_and_kind_reads_none and test_crc_reader_may_query_thanos_through_the_namespaced_monitoring_role_alone failed on main's manifests and pass; deploy/tests/crc-scripts-test.sh 279 ok; doc13-test.py 0 failed, 0 mutants survived.
    • #724: the reader's own Thanos grants on every cluster, and the import check of them #734: 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/core 843 passed; crc-scripts-test.sh 287 ok.

    Counts for #707: before the change the usage test files failed to collect (No module named 'cmapi.capacity'); after, tests/core 813 passed (113 skipped); 367 service tests passed over the related files. Review record: 247 service and 842 core passed. Review fixes: H3 (High), the http thanosUrl, redaction, bounded reads, malformed answers, usage figures not stored, ceiling hours.

    Live proof, cluster CRC (run 45 and 45b):

    Check Result Log
    The reader's three grants, each by its own RoleBinding, no system:authenticated PASS. Before step 7 all three SARs were false; after, true with the reason naming RoleBinding "cmapi-reader-thanos-route/openshift-monitoring", "cmapi-reader-metrics-api/openshift-monitoring" and "cmapi-reader-grant-check/openshift-monitoring". Scope control: get prometheuses/api k8s in openshift-user-workload-monitoring: false reader-before.txt, reader-after.txt, reader-after-sars.txt
    A clean Thanos query as the reader count(kube_resourcequota) = 108, through the reader-discovered Route, partial_response=false, dedup, 10-minute reader token on stdin reader-after.txt
    The import check GET /api/v1/clusters as cmapi.viewer and cmapi.operator: 200; CRC connected, findings [] (0 usage:) c45-clusters.out
    A quota-change dry run PATCH cmap-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. Not unavailable: Thanos answered c45-quota.out
    The daily usage_sweep Job 9625 done 2026-11-27 08:25:04Z, attempts 1, no error; usage_sweep CRC status complete, namespaces 7. analysis_sweeps: CRC 2026-11-27, complete, step 5m, 7 namespaces. namespace_verdicts: 14 rows (7 namespaces x CPU, memory), each insufficient-data/info with the Thanos reason, window 14d. Next job 11208 due 2026-11-28 08:25Z c45b-sweep.out, c45-sweep/
    Source is Thanos, not none cmapi-config holds usage: {"source":"thanos"}; with none the reason would be "not configured" c45b-sweep.out

    Not proven live: real figures. Every managed namespace on CRC has 0 pods (logs/managed-pods.txt), so Thanos has no sample and every answer is insufficient-data. The ok state 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, in cmap-live-g-dev (run 46 brief; no result yet). The unavailable path 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-operator release-4.18, identical Role and Route check as 4.22), recorded on #726 and in docs/reviews/2026-11-26-reader-thanos-baseline/README.md.

    Criterion 3

    Oversized changes route to platform approval, shown by cmapi/tests/service/test_flow.py::test_large_namespace_needs_a_platform_lead and cmapi/tests/core/test_approvals.py::test_quota_increase_and_capacity_warn_add_up

    Built by: earlier PRs (not named in the sources); #707 adds the usage == "unavailable" rule that adds approver-platform to each approval-rules.yaml.

    Tests (both exist on main):

    Live proof, cluster CRC (from the story audit; the run files are no longer on disk): a large namespace waited for approver-platform and was approved: run 13 l.12 (req-20261116-0003). A sensitive team change took one approver-platform slot: 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

    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_switch and ::test_missing_capacity_facts_do_not_auto_approve

    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 case capacityFresh: False).
    • #62 The capacity guard counts the capacity that open requests hold (reservations) #725: cmapi/tests/service/test_capacity_reservations_62.py::test_the_auto_approval_guard_counts_the_holds_of_open_requests. Before the fix: "second create approved instead of pending_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

    Portal quotas and capacity use live APIs, shown by a new test in cmapi-portal-ui/tests/, not written yet

    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 with ok usage, 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 test exit 0: 141 checks in the #707 PR; 199 ok in the #738 review.

    Live proof, cluster CRC:

    • Run 45b, logs/ui45b-capacity.out: Capacity tab as cmapi.requester, 6 checks, ALL PASSED, installed Chrome, 1440 and 390 px; GET /api/v1/capacity 200; the cell equals the API's snapshot.
    • Run 45b, logs/ui45b-new.out: the placement preview called the live POST /api/v1/capacity:place?dryRun=true.
    • Story audit: Quotas live: run 15 l.11-13; Capacity live: run 23 l.25 (44 checks, operator and requester), run 24 l.35-37.

    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

    For the owner

    • Criterion 2's real figures wait for the one-pod run (cmapi-usage-probe, authorised on 2026-11-27).
    • Criterion 4 has test proof only.
  8. ephico2real2 commented on Dec 1, 2026

    @ephico2real2
    OwnerAuthor

    Usage probe result, CRC, 2026-11-30. One pod, cmapi-usage-probe in cmap-live-g-dev (10m CPU, 16Mi, owner-approved on 2026-11-27), ran from 2026-11-27T14:53:49Z. Each daily usage_sweep (worker log: status complete, namespaces 7) stored these verdicts, read-only from namespace_verdicts:

    Sweep Coverage of the 14-day window Verdict (cpu and memory)
    2026-11-27 none insufficient-data: "Thanos has no running-pod sample of this namespace in the last 14 days."
    2026-11-28 5.23% insufficient-data: "Pods were seen in 5.23% of the 14-day window's 4,032 five-minute steps; 80% are needed."
    2026-11-29 12.38% the same, at 12.38%
    2026-11-30 19.52% the same, at 19.52%

    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-data with the measured coverage, never a figure.

    Real ok figures 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). The ok path stays proven by the service and core tests, as the closing comment says.

  9. ephico2real2 commented on Dec 1, 2026

    @ephico2real2
    OwnerAuthor

    Follow-up after this story closed: PR #771 merged as 049077f0. It closes #256 (quotaBelowRequested now 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's teamKey). The approval facts behind this story's auto-approval now hold. Record: docs/reviews/2026-12-01-issue-256-258/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-Progressclass:INVstatus:partly-fixedstory

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions