Skip to content

fix(bigtable): wire stale sweeper and safe teardown into v2_client tests - #19262

Closed
ohmayr wants to merge 2 commits into
mainfrom
fix/bigtable-v2-client-cleanup
Closed

ohmayr wants to merge 2 commits into
mainfrom
fix/bigtable-v2-client-cleanup

Conversation

@ohmayr

@ohmayr ohmayr commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Context & Problem

Bigtable v2_client system tests never invoke clear_stale_instances(), data system tests pass only a single prefix instead of all default test prefixes, and v2_client session fixtures do not wrap creation waits in try/finally.

Summary of Changes

  • Add a session-scoped autouse cleanup_old_instances fixture in tests/system/v2_client/conftest.py.
  • Wrap admin_instance_populated and data_instance_populated creation waits in try/finally with NotFound handling and without masking creation errors.
  • Let tests/system/data/init.py use the full default prefix tuple in clear_stale_instances().

Why This Approach

Wires the existing stale-instance sweeper into all remaining system test suites and prevents timed-out instance creations from leaking clusters.

Intentionally Out of Scope

  • Modifying production Bigtable client code
  • Deleting backups before stale instance deletion in utils.py (tracked in a separate PR)

Verification

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

Bigtable v2_client system tests never invoke clear_stale_instances(), data system tests pass only a single prefix instead of all default test prefixes, and v2_client session fixtures do not wrap creation waits in try/finally.

@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 refactors the system test setup for Google Cloud Bigtable. It updates the stale instance cleanup logic and improves robustness in the admin_instance_populated and data_instance_populated fixtures by wrapping creation and deletion in try-finally blocks to handle timeouts and NotFound exceptions. Feedback was provided to explicitly pass older_than_days=1 to clear_stale_instances in the new cleanup fixture to maintain consistency with its docstring and other test configurations.

return
from tests.system.utils import clear_stale_instances

clear_stale_instances(admin_client.project)

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.

medium

To ensure consistency with the docstring ("Automatically deletes stale test instances older than 1 day") and the implementation in tests/system/data/__init__.py, please explicitly pass older_than_days=1 to clear_stale_instances.

Suggested change
clear_stale_instances(admin_client.project)
clear_stale_instances(admin_client.project, older_than_days=1)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated to pass older_than_days=1 explicitly so it matches the docstring and the other cleanup fixtures. (commit 2afa3d75)

@ohmayr

ohmayr commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Closing speculative hardening PR without live leaked-resource evidence

@ohmayr ohmayr closed this Nov 29, 2026
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