feat(backup): a backup holds settings and keys only, for recovery (#5822)
#5822 "Backup contents: settings and keys only". The operator's ruling (System 180, 2026-10-15) overturns 2026-10-12's "Config + audit + alerts": a backup is for system recovery and carries what would otherwise have to be set up again, with no logs or history. - contents.py: audit_events, alert_events, alert_states, metric_anomalies, metric_anomaly_spans and user_invites move to EXCLUDED. - Alert state is no longer restored, and evaluation skips a rule with no state row. ensure_rule_states (alerts/service.py) gives every single-resource rule lacking one an inactive row; alert_reconcile runs it each minute. - Docs, the Backups page and the CLI help say what a backup holds now. CI's image check also finds the audit log empty after a restore. - tests/integration/test_backup_restore_fixes.py is removed: its case (an alert event naming a left-out Ansible run) no longer arises. The SET NULL fix-up is covered by a unit test on synthetic tables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,11 +31,25 @@ def test_no_table_is_both_and_none_is_named_for_nothing():
|
||||
assert stale == set(), "contents.py names tables that no longer exist"
|
||||
|
||||
|
||||
def test_an_alert_event_keeps_its_row_when_its_ansible_run_is_left_out():
|
||||
fixes = dangling_fixes(all_metadata())
|
||||
assert ('UPDATE "alert_events" SET "ansible_run_id" = NULL WHERE "ansible_run_id" IS NOT NULL '
|
||||
'AND NOT EXISTS (SELECT 1 FROM "ansible_runs" p WHERE p."id" = "alert_events"."ansible_run_id")'
|
||||
) in fixes
|
||||
def test_a_set_null_reference_is_cleared_and_the_row_kept():
|
||||
md = MetaData()
|
||||
Table("ansible_runs", md, Column("id", Integer, primary_key=True))
|
||||
Table("plans", md, Column("id", Integer, primary_key=True),
|
||||
Column("run_id", Integer, ForeignKey("ansible_runs.id", ondelete="SET NULL")))
|
||||
assert dangling_fixes(md) == [
|
||||
'UPDATE "plans" SET "run_id" = NULL WHERE "run_id" IS NOT NULL AND NOT EXISTS '
|
||||
'(SELECT 1 FROM "ansible_runs" p WHERE p."id" = "plans"."run_id")'
|
||||
]
|
||||
|
||||
|
||||
def test_logs_history_and_state_are_left_out():
|
||||
"""The 2026-10-15 ruling: a backup is settings and keys, for recovery."""
|
||||
for table in ("audit_events", "alert_events", "alert_states", "metric_anomalies",
|
||||
"metric_anomaly_spans", "user_invites"):
|
||||
assert table in contents.EXCLUDED, table
|
||||
for table in ("app_settings", "users", "api_tokens", "hosts", "host_agent_registrations",
|
||||
"monitors", "alert_rules"):
|
||||
assert table in contents.KEPT, table
|
||||
|
||||
|
||||
def test_a_cascading_reference_removes_the_row():
|
||||
@@ -55,7 +69,8 @@ def test_dump_leaves_out_each_excluded_tables_rows(tmp_path):
|
||||
args = dump.dump_command(tmp_path / "x.dump")
|
||||
assert "--format=custom" in args
|
||||
assert "--exclude-table-data=plugin_metrics" in args
|
||||
assert "--exclude-table-data=audit_events" not in args
|
||||
assert "--exclude-table-data=audit_events" in args
|
||||
assert "--exclude-table-data=app_settings" not in args
|
||||
|
||||
|
||||
def test_password_goes_in_the_environment_not_the_command_line():
|
||||
|
||||
Reference in New Issue
Block a user