Repository navigation
[Python] Don't override the Dataflow endpoint by default - #40568
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #40568 +/- ##
=============================================
+ Coverage 56.16% 79.90% +23.73%
=============================================
Files 1124 488 -636
Lines 178336 82382 -95954
Branches 1489 0 -1489
=============================================
- Hits 100170 65827 -34343
+ Misses 75645 16555 -59090
+ Partials 2521 0 -2521
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Assigning reviewers: R: @tvalentyn for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
jrmccluskey
left a comment
There was a problem hiding this comment.
LGTM, I would suggest cloning the PR internally and running TAP against it just as a sanity check before merging if you haven't already
| ' at dataflow service endpoint %s', | ||
| e.code, | ||
| self.google_cloud_options.dataflow_endpoint) | ||
| self.google_cloud_options.dataflow_endpoint or |
There was a problem hiding this comment.
can we print the actual attempted endpoint here? is it resolved by now?
There was a problem hiding this comment.
Sure, that's a good idea. Changed in the latest code.
| 'The URL for the Dataflow API. If not set, the default public URL ' | ||
| 'will be used.')) | ||
| 'The URL for the Dataflow API. If not set, the endpoint is ' | ||
| 'resolved by the Google Cloud client library, which honors ' |
There was a problem hiding this comment.
the Google Cloud client library
For my education:
- Where in the control flow this resolution happens?
- Which library is responsible for this resolution?
There was a problem hiding this comment.
The control flow happens in Dataflow Client Library. Particularly, it is when we initialize JobsV1Beta3Client, MessagesV1Beta3Client and MetricsV1Beta3Client:
For example, you can find the logic in __init__ of JobsV1Beta3Client below.
https://github.com/googleapis/google-cloud-python/blob/8e640e06da613caa23bb4cc193e839e7ddbb67c7/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/client.py#L410
| if dataflow_endpoint is None: | ||
| return False | ||
| else: | ||
| # An unset endpoint means the default Dataflow service endpoint (resolved |
There was a problem hiding this comment.
nit: we don't have to repeat these comment, seems like a distraction here.
There was a problem hiding this comment.
I reworded it slightly to make it less distracting, but I'd prefer to keep it. I think having the context right next to the logic makes it much easier for future readers to follow.
| errors.extend( | ||
| self._validate_error(self.ERR_MISSING_OPTION, dataflow_endpoint)) | ||
| else: | ||
| # dataflow_endpoint is optional. When unset, the client library resolves |
Just verified that TAP is green with the change in this PR. |
The default --dataflow_endpoint (GDU URL) was always passed as an api_endpoint override, ignoring GOOGLE_CLOUD_UNIVERSE_DOMAIN (e.g. TPC). Default it to '' so the client library resolves the endpoint, and drop the legacy TaskRunner worker settings that hard-coded the GDU URL.
| `jakarta.jms.*`. The module now requires Java 17 at runtime ([#38729](https://github.com/apache/beam/issues/38729)). | ||
| * (Python) `Regex.find_all` with `group=Regex.ALL` now returns every group, as `(match, group1, group2, ...)`, instead of only group 1, and with `outputEmpty=False` it drops a match only when the whole match is empty, matching the `group=0` behavior ([#40399](https://github.com/apache/beam/pull/40399)). | ||
| * (Python) `Regex.all_matches` now returns every group of the regex, instead of failing with a `TypeError` when the regex has no groups and dropping nested or unmatched trailing groups ([#40562](https://github.com/apache/beam/issues/40562)). | ||
| * (Python) `--dataflow_endpoint` now defaults to `''` instead of `https://dataflow.googleapis.com`. When unset, the Google Cloud client library resolves the Dataflow endpoint and honors `GOOGLE_CLOUD_UNIVERSE_DOMAIN`, so Dataflow jobs can be submitted in non-default universes. Code that reads `GoogleCloudOptions.dataflow_endpoint` should handle an empty value ([#40569](https://github.com/apache/beam/issues/40569)). |
There was a problem hiding this comment.
| * (Python) `--dataflow_endpoint` now defaults to `''` instead of `https://dataflow.googleapis.com`. When unset, the Google Cloud client library resolves the Dataflow endpoint and honors `GOOGLE_CLOUD_UNIVERSE_DOMAIN`, so Dataflow jobs can be submitted in non-default universes. Code that reads `GoogleCloudOptions.dataflow_endpoint` should handle an empty value ([#40569](https://github.com/apache/beam/issues/40569)). | |
| * (Python) `--dataflow_endpoint` now defaults to `''` instead of `https://dataflow.googleapis.com`. When unset, the Google Cloud Dataflow client library resolves the Dataflow endpoint and honors `GOOGLE_CLOUD_UNIVERSE_DOMAIN`, so Dataflow jobs can be submitted in non-default universes. Code that reads `GoogleCloudOptions.dataflow_endpoint` should handle an empty value ([#40569](https://github.com/apache/beam/issues/40569)). |
There was a problem hiding this comment.
I think Google Cloud client library is the official term of that.
https://docs.cloud.google.com/apis/docs/cloud-client-libraries
| 'The URL for the Dataflow API. If not set, the default public URL ' | ||
| 'will be used.')) | ||
| 'The URL for the Dataflow API. If not set, the endpoint is ' | ||
| 'resolved by the Google Cloud client library, which honors ' |
There was a problem hiding this comment.
| 'resolved by the Google Cloud client library, which honors ' | |
| 'resolved by the Python Client for Dataflow, which honors ' |
seems to be the official name from https://docs.cloud.google.com/python/docs/reference/dataflow/latest
Problem
GoogleCloudOptions.dataflow_endpointdefaulted tohttps://dataflow.googleapis.com, andDataflowApplicationClientalways passed it to the Dataflow GAPIC clients asClientOptions(api_endpoint=...). In the GCP client libraries, an explicitapi_endpointtakes precedence overGOOGLE_CLOUD_UNIVERSE_DOMAIN, so the default Google universe (GDU) URL was always used. This breaks job submission in non-GDU universes such as TPC.Changes
--dataflow_endpointdefaults to''(same as the Go SDK). When unset, noapi_endpointoverride is passed, so the client library resolves the endpoint (honoringGOOGLE_CLOUD_UNIVERSE_DOMAIN, otherwisedataflow.googleapis.com). An explicit value still overrides as before.dataflow_endpointis now optional; the URL is only validated when provided.taskrunner_settingsfrom the worker pool. They only applied to the legacy (Runner v1) worker, which Python no longer supports, and hard-coded the GDU URL asbase_url. The Go and Java SDKs never set them, and the Dataflow service doesn't echo them back.Compatibility
Code that reads
options.view_as(GoogleCloudOptions).dataflow_endpointand expects the GDU URL will now get''when the flag isn't set.Part of #40569