Repository navigation
Add Designate zone and recordset query - #9
Conversation
Signed-off-by: Tadas Sutkaitis <tadas.sutkaitis@vexxhost.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae9e7560fd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
| LEFT JOIN recordsets rs ON rs.zone_id = z.id | ||
| LEFT JOIN records r ON r.recordset_id = rs.id |
There was a problem hiding this comment.
Exclude soft-deleted recordsets and records
When an active zone has child rows that Designate has soft-deleted, the recordsets and records tables retain them with a nonzero deleted marker, but these unconditional joins still include them. This causes deleted recordsets to remain in the result and lets historical records affect the MAX-based status, so exporter metrics become stale after ordinary recordset updates or deletions; add deleted = '0' predicates to both LEFT JOIN conditions (rather than WHERE, so empty zones remain visible) and model those columns in the fixture.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I verified the schema against a live Designate database. zones has deleted and deleted_at, but recordsets and records have neither column. Adding rs.deleted = '0' or r.deleted = '0' would make the query fail with an unknown-column error. Designate schema
Designate's storage helper issues a physical delete for tables without a deleted column. Deleting a recordset cascades to its records, and updating a recordset physically deletes records removed from it. The API also includes DELETED as a valid child status when computing recordset status, so the SQL preserves that precedence. Delete helper · Recordset update · Status calculation
The existing z.deleted = '0' predicate covers soft-deleted zones, and the LEFT JOINs preserve zones with zero recordsets.
Mohammed Naser (mnaser)
left a comment
There was a problem hiding this comment.
The status precedence is right, but two things need to change before this merges: the ID format doesn't match what the API returns, and the single query makes it impossible to cheaply turn off the per-recordset metric.
Must fix
IDs come back in the wrong format. Designate stores every UUID column (zones.id, recordsets.id, recordsets.zone_id) as 32 hex characters without dashes and adds the dashes back when reading (types.py). This query returns the raw column, so the exporter's id and zone_id labels would read 3f2a… where upstream openstack-exporter has 3f2a…-…-…. ENG-423 needs the labels to match upstream so existing dashboards keep working. #117 on the exporter hit the same thing and added a formatUUID helper. I'd rather fix it here so every caller gets the API format, for example INSERT(INSERT(INSERT(INSERT(id,21,0,'-'),17,0,'-'),13,0,'-'),9,0,'-'), which works on both MySQL and MariaDB, or a small Go helper. The test fixture uses IDs like zone-1, which hides this; please use real 32-character hex IDs and assert the dashed output.
Split the query. ENG-423 asks for separate queries for zone details, recordset counts per zone, and recordsets with status. Doing it all in one join means the exporter pays for grouping every recordset with its records on every scrape, even if we put openstack_designate_recordsets_status behind a flag. Something like:
ZoneGetAllforzonesandzone_status- a
COUNT(*) ... GROUP BY zone_idover recordsets forrecordsets - the records join only for
recordsets_status
That also saves the exporter from deriving zone counts by skipping NULL recordset rows. In the status query, consider aggregating records by recordset_id in a derived table before joining, so MySQL isn't grouping on the wide name columns.
Looks good
- The
CASE/MAXprecedence (ERROR, PENDING, ACTIVE, DELETED, and ACTIVE for no records) matchesRecordSet.statusin recordset.py. - Your reply to the Codex comment is correct:
recordsetsandrecordshave nodeletedcolumn (tables.py), soz.deleted = '0'is the same filter the API applies. - The
LEFT JOINs keep empty zones, which the per-zone count needs.
Minor
- The fixture makes
recordsets.zone_idnullable, but it'sNOT NULLin Designate, which gives the generated model an unnecessarysql.NullString. - API.md has no Designate entry in the mapping table or the upstream references.
Signed-off-by: Tadas Sutkaitis <tadas.sutkaitis@vexxhost.com>
|
Follow-up to the changes-requested review. The fixes are in
|
Mohammed Naser (mnaser)
left a comment
There was a problem hiding this comment.
Both requested changes are in 6baf0c3: the queries are split, and IDs come back as dashed UUIDs with tests covering them. The NULL zone_id coverage for the 2025.1 schema is a good addition. Merging as a squash with the title updated to match the three queries.
Summary
Add a typed, read-only Designate query for the database exporter. It returns zones and their recordsets in one query, retains zones with no recordsets, and excludes soft-deleted zones.
Recordset status follows Designate's API precedence (
ERROR,PENDING,ACTIVE,DELETED) and defaults toACTIVEwhen a recordset has no records. The PR includes the generated sqlc bindings, an embedded schema fixture, and integration coverage intests/queries_test.go.The exporter can use this query to produce its Designate metrics after updating its
openstackdbdependency.Verification
go test -count=1 -race ./...go vet -tags integration ./...go test -count=1 -tags integration -run '^$' ./...sqlc diffwith v1.30.0 andgofmt -l .