danielwardega7777 opened a new pull request, #77695:
URL: https://github.com/apache/airflow/pull/77695

   **DRAFT because https://github.com/apache/airflow/pull/77690 needs to be 
merged first.**
   
   The Cloud Spanner delete handler in the Google system test resource cleanup 
CLI (`providers/google/tests/system/google/resources_cleanup`) had several 
gaps: it did not handle `BackupSchedule` resources, attempted to delete 
`InstanceConfig` before `Instance` and invoked `gcloud spanner instance-configs 
delete` on Google-managed configs (non-`custom-*`), omitted `--project` on all 
commands, and printed `Resource deleted!` even when commands exited with errors.
   
   This PR fixes `SpannerDeleteHandler` *(depends on the shared cleanup helpers 
PR)*:
   
   - **Cloud Spanner (`handlers/spanner.py`):**
     - Add `BackupSchedule` cleanup before backups, databases, partitions, and 
instances.
     - Order `InstanceConfig` deletion after `Instance` and skip Google-managed 
instance configs (non-`custom-*`).
     - Accept `*, project_id: str | None = None` across all deleters, resolve 
`--project` via `build_project_flag`, and call `run_command_async(..., 
check=True, ignore_not_found=True)`.
   - **Unit tests (`test_spanner_handler.py`):** Cover all six Spanner asset 
types, skipping managed instance configs, deletion order, and numeric project 
fallback to configured `project_id`.
   
   ### Verification
   - `uv run --project providers/google pytest 
providers/google/tests/unit/google/resources_cleanup/`: 94 passed.
   - `breeze run mypy providers/google/tests/system/google/resources_cleanup 
providers/google/tests/unit/google/resources_cleanup`: passed (`Success: no 
issues found in 44 source files`).
   - `ruff format --check` and `ruff check`: passed.
   - **Manual side-by-side verification on a test GCP project (`main` vs. this 
branch):**
     - Created two temporary Spanner instances, each with a database and a 
backup schedule, and ran `SpannerDeleteHandler` with reverse-ordered resource 
entries (including a Google-managed `InstanceConfig` and numeric project 
numbers).
     - **On `main`:** `BackupSchedule` was skipped, `InstanceConfig` ran before 
`Instance` and failed with `INVALID_ARGUMENT` (`Expected instance config ID is 
of the form {custom-[-a-z0-9]*[a-z0-9]}`) while still printing `Resource 
deleted!`, `--project` was omitted from every command, and repeat `NOT_FOUND` 
deletions still printed `Resource deleted!`.
     - **On this branch:** Deleted `BackupSchedule` → `Database` → `Instance` 
in dependency order with `--project` resolved from the configured `project_id`, 
skipped the Google-managed `InstanceConfig` without calling `gcloud`, logged 
`Resource no longer exists.` on repeat `NOT_FOUND` calls, and surfaced 
`CalledProcessError` (`Found an error in the handle deletion results:`) on an 
invalid project ID.
     - Verified zero temporary Spanner instances remained afterward.
   
   *(No newsfragment added—changes are limited to Google provider system-test 
cleanup tooling under `providers/google/tests/`.)*
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Jetski (Gemini) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to