Skip to content

Add Cinder quota accounting reads - #1

Merged
legit-ninja merged 5 commits into
mainfrom
contrib/cinder-quotas-2b1
Dec 4, 2026
Merged

legit-ninja merged 5 commits into
mainfrom
contrib/cinder-quotas-2b1

Conversation

@davidhulick

Copy link
Copy Markdown

Add independent Cinder quota accounting reads

Summary

Add independent, read-only Cinder quota queries for retrieving active project limits, quota usage, and default-class limits without requiring callers to reconstruct these values from existing joined queries.

Motivation

The existing Cinder quota queries are useful for specific lookups but have limitations for complete quota accounting:

  • The quota-led QuotaGetAllWithUsage query omits projects that have usage records but no explicit quota override.
  • The joined query does not expose reserved usage.
  • Multiple matching usage records can multiply returned limit rows.
  • Existing standalone quota queries focus on selected gigabyte-related resources.

The new queries expose the underlying records independently so consumers can perform aggregation and effective-limit resolution according to their requirements.

Changes

  • Add QuotaGetActiveLimits, QuotaGetActiveUsage, and QuotaGetDefaultClassLimits.
  • Add a QuotaRepository facade for quota reads and current volume-type retrieval.
  • Preserve duplicate rows, nullable values, unlimited/zero limits, and complete resource keys.
  • Extend the Cinder test schema with quota_classes.
  • Add Go unit and MariaDB integration coverage for quota behavior and existing Cinder API compatibility.
  • Add portable Python/SQLite SQL smoke tests and enable their discovery in GitHub Actions.
  • Document the new APIs and their semantics.

Compatibility

The changes are additive. Existing Cinder queries, exported signatures, volume filters, and attachment behavior are preserved.

The quota_classes addition is part of the embedded schema fixture used for tests and code generation; it is not a production database migration.

Validation

  • Reproducible generation with sqlc v1.30.0.
  • Full Go unit and race tests passed.
  • go vet and formatting checks passed.
  • Seven portable SQL tests passed, including GitHub Actions discovery.
  • Native MariaDB integration tests and existing Cinder regression tests passed locally on a Docker-enabled development machine.

The Python/SQLite tests provide fast, Docker-free checks of selected SQL semantics. They are complementary to the native MariaDB tests, not a substitute for them. Because SQLite differs from MariaDB in schema syntax and comparison behavior, the native integration suite remains the database-compatibility check.

We're open to adjustments to the testing approach or public API organization if maintainers prefer different conventions.

ConnectContext pings and closes the pool when the database does not
answer, so a caller that starts during a database outage has no pool
at all. The OpenStack database exporter then reports its services as
down until it is restarted, even after the database is back.

Open does the parsing and pool setup without contacting the server,
and ConnectContext becomes Open plus the ping, so existing callers
behave as before. The pool connects on first use and reconnects
after a lost connection.

Tested with go test -race, go vet, gofmt and the integration suite.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Timon Schnell <timon.schnell@btc-it-services.com>

@adamhackl adamhackl left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The README’s guidance on not adding type-specific and aggregate resources together is helpful. A few things from the observability side:

  1. Document that usage is cached accounting
    QuotaGetActiveUsage reads quota_usages, which is Cinder’s cached counter, not a count of actual volumes or snapshots. It can drift from reality until it’s reconciled. The Manila PR (#3) states this explicitly, and it would help to say the same here. Anyone alerting on this will otherwise assume it’s ground truth.

  2. Owner filtering doesn’t match the other quota PRs
    These reads return rows with NULL or empty project IDs unfiltered. The Neutron (#4), Octavia (#2) and Manila (#3) PRs all exclude them from usage, and Manila excludes them from limits too. Could Cinder follow the same convention, or document why it differs?

  3. Parsing resource keys is easy to get wrong
    Type-specific keys like gigabytes_fast_ssd encode the volume type name. Every consumer will need to split those keys apart. A naive split on the first _ misreads the aggregate keys backup_gigabytes and per_volume_gigabytes. Keys for deleted volume types also won’t match anything GetVolumeTypes returns. Consider a small exported helper that turns a key into its base resource and volume type, using the known prefixes (volumes_, snapshots_, gigabytes_). At minimum, document the parsing rule.

  4. Nit: deterministic ordering
    Duplicate rows are intentionally kept, but neither query has an ORDER BY. Consumers that collapse duplicates will get whichever row comes last, and that can change between calls.

  5. Nit: CI conflict
    #2 and #4 add the same Python unittest step to ci.yaml. Whichever lands second will conflict.

@legit-ninja
legit-ninja force-pushed the contrib/cinder-quotas-2b1 branch from ca4af2b to 6a67861 Compare November 20, 2026 17:32
@davidhulick davidhulick changed the title Add independent Cinder quota accounting reads Add Cinder quota accounting reads Nov 20, 2026
Open adds no dial timeout, so a pool held through a database outage
does not fail fast. Say so in the Open doc comment and the README,
and move the Open note into its own README paragraph.

Signed-off-by: Mohammed Naser <mnaser@vexxhost.com>
Add Open for a pool without the startup ping
fitbeard and others added 2 commits December 1, 2026 10:52
Add three read-only Designate queries for openstack_database_exporter:

- ZoneGetAll: non-deleted zones with status and type.
- RecordsetCountByZone: recordset count per non-deleted zone, including
  zones with no recordsets, without reading individual records.
- RecordsetGetAllWithStatus: recordsets with the status the Designate API
  reports (worst child record status in the order ERROR, PENDING, ACTIVE,
  DELETED; ACTIVE when a recordset has no records).

Zone and recordset IDs are returned as dashed UUIDs, matching the API.
Splitting the queries lets the exporter skip the per-recordset status
query when that metric is disabled.

Signed-off-by: Tadas Sutkaitis <tadas.sutkaitis@vexxhost.com>
Add three read-only Cinder quota queries, named after the Cinder DB API
functions they follow, that read every project at once and return raw
rows:

- QuotaGetAllByProject: active project limits from quotas.
- QuotaUsageGetAllByProject: cached in_use and reserved counters from
  quota_usages, including projects without limit overrides.
- QuotaClassGetDefaults: limits of the persisted default quota class.

Rows with a NULL or empty project ID are excluded, because Cinder quota
rows belong to Keystone projects. Results are ordered by project,
resource and row ID. Duplicate rows, NULL, zero and -1 limits are
returned as stored. The existing exporter quota queries are unchanged.

Add ParseQuotaResource, which splits per-volume-type keys
("<part>_<volume type name>") using Cinder's known parts and global
resource names, so backup_gigabytes and type names with underscores are
not misread.

Add quota_classes to the Cinder schema fixture, a MariaDB integration
test with a quota fixture, smoke calls in TestCinderQueries, and API.md
documentation.

Co-authored-by: David Hulick <dave.hulick@gmail.com>
Signed-off-by: David Hulick <dave.hulick@gmail.com>
Signed-off-by: Jeremy Lee <jeremy.lee1664@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@legit-ninja
legit-ninja force-pushed the contrib/cinder-quotas-2b1 branch from ac0dc8b to 61d4612 Compare December 3, 2026 16:29
@legit-ninja
legit-ninja merged commit ddb4151 into main Dec 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants