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

   **DRAFT because https://github.com/apache/airflow/pull/77690 needs to be 
merged first.**
   
   The Cloud DLP delete handler in the Google system test resource cleanup CLI 
(`providers/google/tests/system/google/resources_cleanup`) failed to delete 
regional and non-job/trigger resources: it invoked `gcloud alpha dlp` with only 
the short resource ID (dropping regional locations and looking in the global 
scope instead), only handled `DlpJob` and `JobTrigger` (skipping templates, 
discovery configs, and stored info types), and still printed `Resource 
deleted!` when deletion failed.
   
   This PR fixes `DLPDeleteHandler` *(depends on the shared cleanup helpers 
PR)*:
   
   - **Cloud DLP (`handlers/dlp.py`):**
     - Switch from `gcloud alpha dlp` to the DLP v2 REST API covering 
`JobTrigger`, `DiscoveryConfig`, `DlpJob`, `InspectTemplate`, 
`DeidentifyTemplate`, and `StoredInfoType`, preserving full regional and global 
resource paths.
     - Accept `*, project_id: str | None = None`, replace numeric Cloud Asset 
Inventory project numbers via `resolve_resource_path`, and call `curl(..., 
check=True, ignore_not_found=True)`.
   - **Unit tests (`test_dlp_handler.py`):** Cover all six DLP asset types, 
numeric project number replacement with configured `project_id`, and deletion 
order.
   
   ### Verification
   - `uv run --project providers/google pytest 
providers/google/tests/unit/google/resources_cleanup/`: 93 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 three temporary DLP resources (a regional `JobTrigger`, a 
regional `InspectTemplate`, and a global `DeidentifyTemplate`) and verified 
Cloud Asset Inventory returned numeric project numbers for all three.
     - **On `main`:** `gcloud alpha dlp job-triggers delete` dropped the 
regional location and failed with `NOT_FOUND` (exit code `1`) while still 
printing `Resource deleted!`; `InspectTemplate` and `DeidentifyTemplate` were 
skipped entirely. All three resources remained present (`HTTP 200`).
     - **On this branch:** Running `DLPDeleteHandler` on the same CAI entries 
resolved the numeric project numbers to the configured `project_id` and deleted 
all three resources via the DLP v2 REST API (verified `HTTP 404` afterward).
     - **Idempotency & error handling:** Re-running deletion on the 
already-deleted resources logged `Resource no longer exists.` for all three 
without printing `Resource deleted!`; a malformed request returning HTTP 400 
raised `CalledProcessError` and logged `Found an error in the handle deletion 
results:`.
   
   *(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