Skip to content

feat(cinder): add project and volume-type quota metrics - #162

Open
Jeremy Lee (legit-ninja) wants to merge 6 commits into
vexxhost:mainfrom
samaritanark:contrib/cinder-quotas-2b4
Open

Jeremy Lee (legit-ninja) wants to merge 6 commits into
vexxhost:mainfrom
samaritanark:contrib/cinder-quotas-2b4

Conversation

@legit-ninja

@legit-ninja Jeremy Lee (legit-ninja) commented Dec 2, 2026 •

Copy link
Copy Markdown
Note

Stacked on #161 (Octavia quotas, shared quota configuration). This branch contains #161's three commits; the Cinder changes are the last three commits. Merge #161 first.

Summary

Add a Cinder quota collector, keeping the limits collector as a thin adapter, that reads Cinder's persisted quota accounting: project limits, usage and reservations, default-class limits, and per-volume-type quotas. Cinder capacity metrics move to bytes.

Metrics

All quota metrics have tenant, tenant_id and domain_id labels; volume-type metrics also have volume_type (the full type name). Prefix openstack_cinder_:

Families Values
quota_volumes, quota_snapshots, quota_backups, quota_groups type=limit,in_use,reserved
quota_per_volume_bytes limit only
limits_volume_{max,used,reserved}_bytes aggregate volume capacity
limits_backup_{max,used,reserved}_bytes backup capacity
volume_type_quota_volumes, volume_type_quota_snapshots type=limit,in_use,reserved
volume_type_quota_bytes, volume_type_quota_{in_use,reserved}_bytes per-type capacity
quota_up quota collection health, separate from openstack_cinder_up

The first five also gain a domain_id label, which changes series identity. The openstack_cinder_volume_status size label stays in GiB, and volume inventory labels are unchanged. Only unlimited (-1) limits stay unscaled.

Dependencies

PR #159 also changes the Cinder volumes collector; whichever merges second needs its README section reconciled.

Tests

  • Unit tests for defaults, precedence, accounting, type resolution, record isolation, error sanitization, byte conversion and timeouts.
  • End-to-end coverage of all sixteen quota families with nullable overrides, default-class limits, signed accounting, deleted rows, typed resources, and idle and usage-only projects.

Built and tested (go build, go vet, go test -race ./...) against openstackdb with #10 and #11 applied. MariaDB end-to-end tests have not yet been run against the rebased dependency.

> [!NOTE] > Stacked on #161 (Octavia quotas, shared quota configuration). This branch contains #161's three commits; the Cinder changes are the last three commits. Merge #161 first.

Summary

Add a Cinder quota collector, keeping the limits collector as a thin adapter, that reads Cinder's persisted quota accounting: project limits, usage and reservations, default-class limits, and per-volume-type quotas. Cinder capacity metrics move to bytes.

Metrics

All quota metrics have tenant, tenant_id and domain_id labels; volume-type metrics also have volume_type (the full type name). Prefix openstack_cinder_:

Families Values
quota_volumes, quota_snapshots, quota_backups, quota_groups type=limit,in_use,reserved
quota_per_volume_bytes limit only
limits_volume_{max,used,reserved}_bytes aggregate volume capacity
limits_backup_{max,used,reserved}_bytes backup capacity
volume_type_quota_volumes, volume_type_quota_snapshots type=limit,in_use,reserved
volume_type_quota_bytes, volume_type_quota_{in_use,reserved}_bytes per-type capacity
quota_up quota collection health, separate from openstack_cinder_up

Behavior

  • Limits resolve in Cinder's DbQuotaDriver order: project override, then the active default quota-class entry, then the configured default. A NULL project override falls through. Zero and -1 are preserved. Per-type resources default to -1, independently of the aggregate limit.
  • Usage and reservations are Cinder's recorded accounting, not physical consumption. Signed values are kept. Per-type and aggregate values describe the same allocations and should not be added together.
  • Type keys are resolved against current volume types by full name, so names with underscores parse correctly; deleted types are excluded.
  • Malformed or ambiguous records (duplicate rows, invalid default-class entries, NULL or duplicate type names) omit only the affected scope and are logged with sanitized diagnostics; quota_up stays 1. Query failures and timeouts fail closed with quota_up=0 and no quota samples.
  • Usage-only, override-only and idle Keystone projects are included.

Configuration

  • --quota.defaults-file gains an optional cinder section (volumes, snapshots, backups, groups, gigabytes, backup_gigabytes, per_volume_gigabytes, optional use_default_quota_class). Without it, Cinder 2025.2 defaults are assumed with a warning. Existing Octavia-only files remain valid.
  • --cinder.quota-query-timeout / CINDER_QUOTA_QUERY_TIMEOUT (default 5s): shared deadline for the quota reads.

Breaking metric changes

Six capacity families are renamed to bytes (GiB × 2^30) without aliases:

Previous New
openstack_cinder_limits_volume_max_gb openstack_cinder_limits_volume_max_bytes
openstack_cinder_limits_volume_used_gb openstack_cinder_limits_volume_used_bytes
openstack_cinder_limits_backup_max_gb openstack_cinder_limits_backup_max_bytes
openstack_cinder_limits_backup_used_gb openstack_cinder_limits_backup_used_bytes
openstack_cinder_volume_type_quota_gigabytes openstack_cinder_volume_type_quota_bytes
openstack_cinder_volume_gb openstack_cinder_volume_bytes

The first five also gain a domain_id label, which changes series identity. The openstack_cinder_volume_status size label stays in GiB, and volume inventory labels are unchanged. Only unlimited (-1) limits stay unscaled.

Dependencies

PR #159 also changes the Cinder volumes collector; whichever merges second needs its README section reconciled.

Tests

  • Unit tests for defaults, precedence, accounting, type resolution, record isolation, error sanitization, byte conversion and timeouts.
  • End-to-end coverage of all sixteen quota families with nullable overrides, default-class limits, signed accounting, deleted rows, typed resources, and idle and usage-only projects.

Built and tested (go build, go vet, go test -race ./...) against openstackdb with #10 and #11 applied. MariaDB end-to-end tests have not yet been run against the rebased dependency.

Export stored limits and rebuilt usage for seven Octavia resources, with
project metadata fallback, defaults configuration, bounded SQL reads and
separate quota health. Preserve inventory and other service registration.

Requires the public openstackdb quota APIs; keep the canonical dependency
until those APIs are accepted upstream. Validate through an external Go
workspace in the meantime.

Signed-off-by: David Hulick <dave.hulick@gmail.com>
Extend the existing full-exporter fixture with distinct resource counts,
nullable and explicit limits, deleted resources and an idle project.
Assert every quota family and preserve existing service assertions.

Integration-tag vet passes; native MariaDB execution is pending because
Docker is unavailable in the preparation environment.

Signed-off-by: David Hulick <dave.hulick@gmail.com>
Signed-off-by: David Hulick <dave.hulick@gmail.com>
Read persisted project limits, usage, defaults and active volume types independently. Preserve signed accounting and isolate ambiguous resources with sanitized diagnostics. Extend shared configuration and register one quota collector while retaining the limits adapter.

Expose Cinder capacities in bytes and add domain identity to quota capacities. Keep inventory attachment-row behavior for the separate deduplication fix.

Requires the public openstackdb Cinder and Octavia quota APIs. Keep the canonical library requirement and validate through an external workspace. Short and race tests, vet, build and module verification pass; native database validation is blocked by unavailable Docker.

Signed-off-by: David Hulick <dave.hulick@gmail.com>
Extend the existing Cinder fixture with nullable overrides, default-class limits, signed accounting, deleted rows, typed resources and idle and usage-only projects. Check all sixteen quota families, exact labels and gauge values, inventory bytes and retired capacity names.

Preserve the existing service fixtures, Octavia quota assertions and Nova task-state check. Integration-tag vet passes; native MariaDB execution is blocked because Docker is unavailable.

Signed-off-by: David Hulick <dave.hulick@gmail.com>
The staged openstackdb Cinder quota rework removed the QuotaRepository
wrapper and renamed several query methods, leaving the exporter unable
to compile against the updated API.

Update the Cinder quota collector to use the generated Queries API
directly and adjust the associated test expectations.

Preserve existing quota accounting, default precedence, error handling,
and Prometheus metric behavior.

Verified against the combined staged Cinder and Octavia openstackdb
APIs with successful build, vet, and targeted unit tests.

Signed-off-by: David Hulick <dave.hulick@gmail.com>
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.

2 participants