Skip to content

fix(bigtable): delete backups before deleting stale test instances - #19261

Draft
ohmayr wants to merge 1 commit into
mainfrom
fix/bigtable-delete-stale-backups
Draft

ohmayr wants to merge 1 commit into
mainfrom
fix/bigtable-delete-stale-backups

Conversation

@ohmayr

@ohmayr ohmayr commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Context & Problem

clear_stale_instances() in Bigtable system tests calls delete_instance() directly, which fails whenever a leaked instance still holds backups.

Summary of Changes

  • Add _delete_instance_backups() in tests/system/utils.py to delete backups under clusters/- before deleting each stale instance, instantiating BigtableTableAdminClient lazily.
  • Add concise unit tests in tests/unit/test_system_cleanup.py covering backup-before-instance ordering, per-backup delete errors, and list_backups failures.

Why This Approach

Fixes the backup-blocking failure inside the shared stale-instance helper without modifying production client code.

Intentionally Out of Scope

  • Modifying production Bigtable client code
  • Wiring the sweeper into v2_client and data fixtures (tracked in a separate PR)

Verification

nox -s lint mypy unit-3.14 unit-3.10 cover and two independent Owl review passes

clear_stale_instances() in Bigtable system tests calls delete_instance() directly, which fails whenever a leaked instance still holds backups.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the stale instance cleanup process to delete all associated backups before deleting the instance itself. A new helper function _delete_instance_backups is added to packages/google-cloud-bigtable/tests/system/utils.py, and clear_stale_instances is updated to lazily initialize a BigtableTableAdminClient and call this helper. Additionally, a new unit test file packages/google-cloud-bigtable/tests/unit/test_system_cleanup.py is introduced to verify this behavior and ensure robustness when listing backups fails. There are no review comments, and I have no feedback to provide.

This branch has not been deployed

No deployments
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