Skip to content

feat(cloud-backups): support rotating a non-audit table (metrics_audit)#9

Open
logicflakes wants to merge 1 commit into
mainfrom
2026-07-audit-rotate-metrics-audit
Open

feat(cloud-backups): support rotating a non-audit table (metrics_audit)#9
logicflakes wants to merge 1 commit into
mainfrom
2026-07-audit-rotate-metrics-audit

Conversation

@logicflakes

Copy link
Copy Markdown
Collaborator

What

Lets pg audit-rotate rotate a table without an entity_name column (e.g. metrics_audit), by making the entity_name='instances' preflight conditional on that column existing (columnExistsSQL).

Why

The instances guard is specific to the generic audit table's frozen-instances semantics (rows still read by InstanceService). Run unconditionally, its SELECT count(*) … WHERE entity_name='instances' errors on any table lacking the column — blocking rotation of metrics_audit. Now: column present → the guard runs + refuses exactly as before; column absent → skipped (there are no such rows to protect).

Safety

  • audit-table behavior is byte-for-byte unchanged (column exists → original count-and-refuse block runs).
  • A misconfigured AUDIT_TABLE is still caught — the upstream ownership/sequence preflights query the table via ::regclass and hard-error first.
  • No new SQL-injection surface (same interpolation style as the sibling helpers; column is a hardcoded literal).

Test

  • Unit: TestColumnExistsSQL; full suite green, gofmt clean.
  • Live (PG17 + MinIO): a metrics_audit-shaped table (uuid PK, no entity_name) rotates + backs up without --drop-instance-rows and with no instances error.
  • In-cluster (sandbox, k8s Job): pushed this image, ran the helm metrics cronjob against a real metrics_audit table → rotate → backup → verify-restore → complete.

Pairs with the helm side (rearm-saas: cover metrics_audit with a 2nd cronjob key). Rollout: merge this + build the image before the helm knob is useful.

🤖 Generated with Claude Code

Make the entity_name='instances' preflight conditional on the table actually having
an entity_name column (columnExistsSQL). It's specific to the generic audit table's
frozen-instances semantics; another rotated table -- metrics_audit -- has no such column,
so the guard is skipped there instead of erroring on the missing column. audit-table
behavior is unchanged (the column exists -> the guard runs as before).

Live-verified: rotate+backup of a metrics_audit-shaped table (uuid PK, no entity_name)
now passes preflight without --drop-instance-rows.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ReARM-Agent: 1420896f-adf5-4843-896f-d863cfcc6528
ReARM-Agentic-Session: 7fa98c2d-b192-4b4a-b1a8-ac64349a89b2
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.

1 participant