Repository navigation
Add Cloud SQL Auth Proxy v2 support to CloudSqlProxyRunner - #73646
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
55f62be to
48bd721
Compare
fat-catTW
left a comment
There was a problem hiding this comment.
See no blocker to me.
Nice fix.
potiuk
left a comment
There was a problem hiding this comment.
Thanks, v2 support is overdue. The flag mapping, readiness detection, version parsing and download URL all look right. One behaviour difference inline between v1 and v2 that would break private-IP-only instances.
Drafted-by: Claude Code (Opus 5.5); reviewed by @potiuk before posting
99ff2cd to
fd35775
Compare
MaksYermak
left a comment
There was a problem hiding this comment.
@arno-fukuda thank you for the PR!
LGTM, could I ask you to run this system test cloudsql_query_proxy_iam for yours changes and provide the screenshot from Airflow UI that everything is green?
@shahar1 what do you think about this changes?
Cloud SQL Auth Proxy v1 connects to the public IP and falls back to the private IP, while v2 connects to the public IP only unless told otherwise. Instances with only a private IP therefore worked with v1 but failed after switching to v2, and only at query time, because v2 still reports that it is ready for new connections.
b0f2691 to
8f9298e
Compare
potiuk
left a comment
There was a problem hiding this comment.
Thanks for the --auto-ip fix — that keeps v1's public-then-private fallback for private-IP-only instances on v2, and the docs explain it. Looks good to me.
@arno-fukuda before this can be merged we need the screenshot @MaksYermak asked for: please run the cloudsql_query_proxy_iam system test with sql_proxy_major_version=2 and post a screenshot from the Airflow UI showing it green.
Drafted-by: Claude Code (Claude Opus 5); reviewed by @potiuk before posting
|
shahar1
left a comment
There was a problem hiding this comment.
The v2 flags, download URL, ready-line handling and version parsing all match the proxy's sources, and the code looks good to me. Three small documentation gaps about v1-to-v2 differences are inline; none of them blocks the merge.
Smaller observations
- The Testing section of the PR description still says this wasn't tested against a real Cloud SQL instance. Could you update it with the
cloudsql_query_proxy_iamrun? That test uses Postgres, so the MySQL 8.4 behaviour still rests on the reproduction in #72681, which is worth keeping in the description. - Three more are posted as inline comments on
providers/google/docs/connections/gcp_sql.rst.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. The findings
below are observations, not blockers; an Apache Airflow
maintainer — a real person — will take the next look at the
PR. If you think a finding is mis-applied, please reply on
the PR and a maintainer will weigh in.More on how Apache Airflow handles maintainer review:
Contributing guide.
Users switching to v2 need to know which releases work, why MySQL 8.4 needs v2, and that v2 picks up credentials and the quota project differently from v1, since those differences only show up as connection or permission failures at runtime.
|
Thanks for the review. All three inline points are addressed in 7913c42. The Testing section of the PR description now includes the Drafted-by: Claude Code (Opus 5.5); reviewed by @arno-fukuda before posting |
shahar1
left a comment
There was a problem hiding this comment.
Thanks for addressing all three points: the v2.2.0 minimum, the MySQL 8.4 note and the authentication differences are now documented and match the proxy's sources. The only code change since my last review is the log line, which looks fine.
One thing I missed last time: v2.2.0 is the minimum for the flags, but not for the fix this PR closes. caching_sha2_password support over Unix sockets only arrived in proxy v2.19.0, so the docs as written can point MySQL 8.4 users at a v2 release that still fails. Details are inline. Could you also say which v2 release you used for the reproduction in #72681?
This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. The findings
below are observations, not blockers; an Apache Airflow
maintainer — a real person — will take the next look at the
PR. If you think a finding is mis-applied, please reply on
the PR and a maintainer will weigh in.More on how Apache Airflow handles maintainer review:
Contributing guide.
Drafted-by: Claude Code (Opus 5.5); reviewed by shahar1 before posting
caching_sha2_password full authentication only works through the proxy from v2.19.0 and over Unix sockets, so the earlier wording could lead MySQL 8.4 users to a v2 setup that still fails. The examples now use a current release that also meets Google's latest minimum.
shahar1
left a comment
There was a problem hiding this comment.
Thanks, all three points from my last review are fixed and match the sources. The v2.19.0 minimum and the Unix socket requirement for MySQL 8.4 are documented, MySqlHook has no public key retrieval option in either client path, and v2.27.0 is the latest proxy release, with the download URL the runner builds listed in its release notes. Only docs, docstrings and one error message changed since my last review, and CI is green at this head.
Not blocking: the PR description leaves the undrained proxy output for a follow-up, and I didn't find an issue for it. Could you open one so it isn't lost?
This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.More on how Apache Airflow handles maintainer review:
Contributing guide.
Drafted-by: Claude Code (Opus 5.5); reviewed by shahar1 before posting
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
|
@arno-fukuda great work for a first PR :) |


CloudSqlProxyRunneronly knows how to run Cloud SQL Auth Proxy v1: the download URLs point at the v1 buckets and the command line uses v1-only flags (-dir,-instances,-credential_file,-enable_iam_login). As reported in #72681, v1 failscaching_sha2_passwordfull authentication on Cloud SQL for MySQL 8.4, so the first connection after a restart/failover fails with1045 Access denied. v1 is also no longer developed.This PR adds opt-in v2 support through a new
sql_proxy_major_versionrunner argument andCloudSQLDatabaseHookconnection extra. The default stays1, so existing behaviour does not change. Withsql_proxy_major_version=2:https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/<version>/cloud-sql-proxy.<os>.<arch>, which is where Google publishes v2. v2 has no "latest" download, sosql_proxy_version(e.g.v2.27.0) is required unlesssql_proxy_binary_pathpoints to an existing binary.--unix-socket <dir> <instance>,--credentials-file,--auto-iam-authn, and always--auto-ip. v2 connects only to the public IP by default, and--auto-ipkeeps v1's fallback to the private IP for private-IP-only instances. It needs v2.2.0 or newer. In TCP mode the hook builds<instance>?port=<port>instead of<instance>=tcp:<port>; v2 uses TCP for that instance even with--unix-socketset.The proxy has started successfully and is ready for new connections!) to stdout, not stderr. So in v2 modestart_proxymerges stderr into stdout and reads from there. The ready-line check is now case-insensitive so it matches both versions.get_proxy_versionparses v2's--versionoutput (cloud-sql-proxy version 2.14.0+linux.amd64).instance_specificationis empty, v2 mode raises an error, because v2 can't forward every instance in a project (no-projectsequivalent).sql_proxy_versionwhen the binary has to be downloaded, empty instance) are raised when the runner is created, so they aren't hidden by the operator'sstop_proxy()cleanup. Av2.xsql_proxy_versionwith the default major version 1 is rejected with a hint to setsql_proxy_major_version.The connection docs cover the new extra. They also now say that IAM login through the proxy is Postgres-only on v1 and that MySQL needs v2, per Google's Cloud SQL docs. The previous text said v1 supported both. The docs also cover the v1-to-v2 differences users can run into: the v2.2.0 minimum, MySQL 8.4 needing v2.19.0 or newer over the default Unix socket, v2 using only Application Default Credentials where v1 also tries the active
gcloudaccount, and v2 billing its Cloud SQL Admin API calls to the credentials' quota project.Known issue, not addressed here: the proxy's output pipe isn't drained after startup. v1 already has this with stderr, and v2 inherits it on stdout. Left for a follow-up.
Relation to #72785
This supersedes #72785, which had the same idea. Compared with that PR, this one:
cloud-sql-proxyGitHub releases have no binary assets, so the GitHub URL used in Add Cloud SQL Auth Proxy v2 mode to CloudSqlProxyRunner #72785 returns 404.ready to accept new connections, which v2 never prints, sostart_proxywould block.--credentials-file(v2 rejects-credential_file) whenkey_path/keyfile_dictis set.CloudSQLDatabaseHook/CloudSQLExecuteQueryOperator, including TCP mode.ValueErrorinstead of adding newAirflowExceptionusages (check-no-new-airflow-exceptions).airflow-core/newsfragmentsentry, since this is a provider-only change.Testing
start_proxyreading the ready line from stdout,get_proxy_versionparsing, early validation, and hook wiring (TCP mode and invalidsql_proxy_major_versionvalues).test_cloud_sql.pyfor both hooks and operators: 198 passed.prek run --stage pre-commiton the changed files passes. Onlycheck-provider-yaml-validwas skipped, because it needs breeze andprovider.yamlis unchanged.mypyon the hook module is clean.CloudSqlProxyRunner(darwin/arm64, ADC): download,get_proxy_version()→2.14.0+darwin.arm64,start_proxy()with--unix-socketplus?port=listens on TCP and returns on the ready line, and in unix-socket mode an invalid instance shows up as the existinggoogleapi: Errorfailure.cloudsql_query_proxy_iampassed against a real Cloud SQL instance withsql_proxy_major_version=2and proxy v2.26.0 (Postgres 15, IAM login through the proxy over TCP, Breeze on linux/arm64). The task log shows the v2 download location,--auto-ip --auto-iam-authnon the command line, andSELECT 1through the proxy. Screenshots: Add Cloud SQL Auth Proxy v2 support to CloudSqlProxyRunner #73646 (comment). The run used this PR's commits applied to the then-currentmain, because the branch's base could no longer build the CI image at the time (fixed in Install OS dependencies on hardened images after dhi.io renumbering #76200).caching_sha2_passwordbehaviour still relies on the reproduction in CloudSqlProxyRunner cannot authenticate against Cloud SQL for MySQL 8.4 (caching_sha2_password full auth fails on Auth Proxy v1) #72681.closes: #72681
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Claude Opus 5.5) following the guidelines
I reviewed the generated changes, checked the v2 behaviour described above against the
cloud-sql-proxyv2 source and the real binary, and ran the tests and static checks listed above.{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.🤖 Generated with Claude Code