Repository navigation
Add Manila quota accounting and logical-share inventory - #3
Conversation
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>
a0486d2 to
0c5c3f5
Compare
adamhackl
left a comment
There was a problem hiding this comment.
Thanks. Keeping project and share-type accounting separate, and saying clearly that usage is stale until Manila reconciles it, is exactly what consumers need. A few things:
-
ShareGetInventory query cost
The correlated subquery picks one instance per share, and its ORDER BY runs two EXISTS subqueries per candidate instance. For a deployment with many shares and replicas, that is a lot of work per call, and it will run on every scrape. Could you run EXPLAIN against a realistically sized dataset, and confirm share_instances.share_id is indexed in the real Manila schema? -
NULL usage values are silently treated as zero
QuotaUsageGetProjectTotals and QuotaUsageGetShareTypeTotals wrap in_use and reserved in COALESCE(…, 0), so malformed rows disappear into the totals. The Neutron PR (#4) returns an InvalidAmounts count so callers can spot bad aggregates. Something similar here, or a note that NULLs count as zero, would keep the libraries consistent. -
Usage for deleted share types disappears from type totals
QuotaUsageGetShareTypeTotals inner-joins on active share types. Any accounting left behind for a deleted type still shows up in the project totals but vanishes from the per-type totals, so the two won’t reconcile. Worth documenting, or using a LEFT JOIN so the orphaned rows stay visible. -
Status precedence is tied to Manila 2025.2
The hard-coded status ranking in ShareGetInventory mirrors Manila’s current Python logic. New upstream statuses fall into the ELSE 6 bucket, so which instance is chosen, and therefore the reported status and availability zone, can change silently after a Manila upgrade. A note on re-checking this against upstream when moving to a new Manila release would help. -
The Python SQL tests aren’t wired into CI
This PR adds tests/manila_quota_sql_test.py and tests/manila_inventory_sql_test.py but doesn’t change ci.yaml. They’ll only run if #1, #2 or #4 lands first with the discovery step.
0c5c3f5 to
e28d6a6
Compare
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
e28d6a6 to
b449e00
Compare
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 ShareGetInventory, which returns one row per nondeleted logical share, including shares without instances. It follows Manila's Share.instance rules (status precedence, active-replica preference and the replication-change exception) and takes status, availability zone and share type from one representative instance, chosen in a single pass with window functions. The transitional status ranking copies constants.TRANSITIONAL_STATUSES and must be re-checked on Manila upgrades. ShareGetAllWithInstances is unchanged. Add six read-only quota queries, named after the Manila DB API functions they follow, that read every project at once and return raw rows: - QuotaGetAllByProject, QuotaGetAllByProjectAndUser and QuotaGetAllByProjectAndShareType: project, user and share-type limit overrides from their separate tables. - QuotaClassGetDefault: limits of the persisted default quota class. - QuotaUsageGetAllByProject and QuotaUsageGetAllByProjectAndShareType: project and share-type usage rows from quota_usages, with nullable in_use and reserved returned as stored rather than summed. Rows with a NULL or empty project ID are excluded, and results are ordered by their identifying columns and row ID. The share-type queries left-join share_types, so limits and usage for deleted share types stay visible with a NULL name. Quota tables keep Manila's integer soft delete (deleted = 0 for active rows). Add the quota tables to the Manila schema fixture, unit tests, MariaDB integration tests in tests/ with inventory and quota fixtures, smoke calls in TestManilaQueries, and API.md documentation. Register the MySQL driver in the integration test helper. 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>
b449e00 to
4a58ace
Compare
Add Manila quota accounting and logical-share inventory
Summary
Add read-only Manila quota accounting and deterministic logical-share inventory queries.
Changes
ShareGetInventory, returning one row per logical share without duplication from multiple share instances.ShareGetAllWithInstancesAPI and behavior.Quota consumption is read from Manila's persisted accounting records. Logical-share inventory uses share and instance records. These remain separate sources of information.
Review considerations