Add CloudSQLNoOperationInProgressSensor for parallel admin ops#68151
Open
Vamsi-klu wants to merge 4 commits into
Open
Add CloudSQLNoOperationInProgressSensor for parallel admin ops#68151Vamsi-klu wants to merge 4 commits into
Vamsi-klu wants to merge 4 commits into
Conversation
added 3 commits
June 6, 2026 18:05
The sensor must be referenced by an example DAG to satisfy the Google provider project-structure test (test_missing_examples). It gates the import task on the instance having no admin operation in progress, which is the documented usage pattern.
- Raise a dedicated CloudSQLOperationError (a subclass of AirflowException) instead of the base AirflowException, so the new sensor passes the check-no-new-airflow-exceptions static check. - Add the new cloud_sql sensor to the generated get_provider_info.py. - Restore the correct generated/provider_dependencies.json.sha256sum (the .json itself is unchanged from main).
The provider.yaml change triggers provider-dependencies regeneration, which produces this checksum on top of current main; commit it with a trailing newline so update-providers-build-files and end-of-file-fixer both pass.
Member
|
@Vamsi-klu A few things need addressing before review — see our Pull Request quality criteria.
No rush. Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you. |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a new operation-agnostic, deferrable
CloudSQLNoOperationInProgressSensorto the Google provider that waits until a Cloud SQL instance has no administrative operation in flight before downstream tasks submit a new one. Supporting changes:list_operationshook method onCloudSQLHook(callssqladmin.operations.list, filtered to the instance viatargetId).CLOUD_SQL_NON_TERMINAL_STATUSESfrozenset (PENDING/RUNNING) used to decide whether an operation is still in progress.CloudSQLNoOperationInProgressTriggerfor deferrable mode.provider.yamland a howto section in the Cloud SQL docs.Why
Cloud SQL serializes administrative operations per instance, so two parallel
CloudSQLImportInstanceOperator/CloudSQLExportInstanceOperatortasks against the same instance race and the second fails immediately with HTTP 409operationInProgress(#68040). The provider does not retry and had no sensor to wait for the instance to become idle, leaving users to reimplement a customPythonOperatorpoll or coarse workarounds (per-instance pools, blind retries).Impact
sqladmin.operations.listand succeeds once no operation is in a non-terminal (PENDING/RUNNING) state. Keying off an explicit status set (rather thanstatus != DONE) avoids treating anUNKNOWN/unexpected status as in-progress and poking forever.deferrable=True, or theoperators.default_deferrableconfig default).AirflowExceptionon HTTP 403/404 (instance missing or access denied) instead of poking until timeout; other HTTP errors are re-raised.Testing
New/updated unit tests (no live GCP calls;
get_conn/the hook are mocked):tests/unit/google/cloud/hooks/test_cloud_sql.py::test_list_operations— assertsoperations.listis invoked for the right project/instance and that results are filtered to operations whosetargetIdmatches the instance.tests/unit/google/cloud/sensors/test_cloud_sql.py(new) —pokereturnsTruewhen only terminal ops exist andFalsewhen aRUNNING/PENDINGop exists (test_poke_returns_true_when_no_in_progress_operations,test_poke_returns_false_when_operation_in_progress); fast-fails on 403/404 and re-raises other HTTP errors (test_poke_fails_fast_on_403_404,test_poke_reraises_other_http_errors);executedefers with the trigger when deferrable and not idle, does not defer when already idle, and delegates toBaseSensorOperator.executewhen non-deferrable (test_execute_defers_when_deferrable_and_not_idle,test_execute_does_not_defer_when_idle,test_execute_non_deferrable_delegates_to_super);execute_completeis a no-op on success and raises onfailed/errorevents.tests/unit/google/cloud/triggers/test_cloud_sql.py::TestCloudSQLNoOperationInProgressTrigger— serialization round-trip;runyields a successTriggerEventwhen no/only-terminal ops are present, keeps sleeping while an op is in progress, fails fast on 403/404, and emits a failure event on a generic exception.closes: #68040
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.8) following the guidelines