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

   Fix overwriting of location with default value, when a region is provided.
   
   ### **TL/DR**
   When the `DataflowTemplateOperator` is being migrated from Airflow 1 to 
Airflow 2, if `region` property is setup with no `location` passing - Fallback 
anyway throws a message:
   
   _**The mutually exclusive parameter `location` and `region` key in 
`variables` parameter are both present. Please remove one.**_
   
   New unit tests of operator might explain better - they are not going to pass 
without the fix.
   
   ### Details
   The `DataflowTemplatedJobStartOperator` has a parameter `location` with non 
empty default value. This operator is using the `DataflowHook` object. 
`DataflowHook` makes a check: if `location` and `region` are setup together at 
the same time, than throws the exception (like above). Since 
`DataflowTemplatedJobStartOperator`'s `location` has a default value, it will 
always pass non-zero value to the `DataflowHook`.
   
   At the same time `DataflowHook` has the same default value for its  
`location` parameter, so `DataflowTemplatedJobStartOperator` can safely pass 
None value (Special unit test is also added, to make sure `DataflowHook` will 
use default value when `location` and `region` are not provided at the same 
time).
   
   ### Notices
   
   The same fallback `_fallback_to_location_from_variables` is applied to 4 
methods (at the moment of writing):
   
   1. start_template_dataflow (fixed case)
   2. start_java_dataflow (found only definition and unit test references)
   3. start_python_dataflow (found only definition and unit test references)
   4. is_job_dataflow_running (referenced by `BeamRunJavaPipelineOperator`, 
`DataflowTemplatedJobStartOperator` and `DataflowCreateJavaJobOperator` with 
explicitly no passing `location` and `region` at the same time)
   
   So, since other places are not affected, the change can be pretty small and 
focused on `DataflowTemplatedJobStartOperator` only.
   
   P.S. Looks like some other people had the same problem, for example:  
https://stackoverflow.com/questions/70254851/dataflowtemplateoperator-job-failing-on-cloud-composer-after-upgrading-to-airflo
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   <!--
   **^ Add meaningful description above**
   
   Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)**
 for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party 
License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a 
newsfragment file, named `{pr_number}.significant.rst` or 
`{issue_number}.significant.rst`, in 
[newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   -->


-- 
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