Skip to content

Fix ComputeEngineInsertInstanceOperator doesn't respect jinja-templated instance name when given in body argument#34171

Merged
potiuk merged 12 commits intoapache:mainfrom
aryehgigi:fix-34170
Sep 11, 2023
Merged

Fix ComputeEngineInsertInstanceOperator doesn't respect jinja-templated instance name when given in body argument#34171
potiuk merged 12 commits intoapache:mainfrom
aryehgigi:fix-34170

Conversation

@aryehgigi
Copy link
Contributor

@aryehgigi aryehgigi commented Sep 7, 2023

Fixes #34170


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
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.

@boring-cyborg boring-cyborg bot added area:providers provider:google Google (including GCP) related issues labels Sep 7, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Sep 7, 2023

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 Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@aryehgigi aryehgigi changed the title fix Fix for issue: ComputeEngineInsertInstanceOperator doesn't respect jinja-templated instance name when given in body argument Sep 7, 2023
@potiuk
Copy link
Member

potiuk commented Sep 7, 2023

You need to fix tests, I am afraid.

@aryehgigi
Copy link
Contributor Author

hey @potiuk ,
i dont mind trying to fix the tests, but i wondered what do you think of the code changes, looks right?
we can alternatively add the resource_id to the jinja-template list - this will resolve the problem with no other changes required - but would it cause other problems that im not aware of?
wdyt?

@eladkal eladkal changed the title Fix for issue: ComputeEngineInsertInstanceOperator doesn't respect jinja-templated instance name when given in body argument Fix ComputeEngineInsertInstanceOperator doesn't respect jinja-templated instance name when given in body argument Sep 8, 2023
@eladkal
Copy link
Contributor

eladkal commented Sep 9, 2023

Can you add unit test to cover this change?

@aryehgigi
Copy link
Contributor Author

aryehgigi commented Sep 10, 2023

@eladkal , @potiuk
i have added tests, and covered also other machine instantiations

@potiuk
Copy link
Member

potiuk commented Sep 11, 2023

Hmm. We usually use @cached_property for similar cases - which is much cleaner and more straightforward. Maybe you should also consider it ?

@aryehgigi
Copy link
Contributor Author

@potiuk
mmm I dont see how would that solve anything?
to which method do you think we should add it? init? execute?

if you are looking for simpler alternatives, i suggested above that adding resource_id to the template_fields filed would solve the issue with no other change required. i was just not sure if it would have other unintended/unwanted side-effects..

wdyt?

@potiuk
Copy link
Member

potiuk commented Sep 11, 2023

That works as well and is way better. No there should be no negative side effects.

@aryehgigi
Copy link
Contributor Author

aryehgigi commented Sep 11, 2023

can i merge?
@potiuk / @eladkal

@potiuk potiuk merged commit 0110b22 into apache:main Sep 11, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Sep 11, 2023

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ComputeEngineInsertInstanceOperator doesn't respect jinja-templated instance name when given in body argument

3 participants