[ 
https://issues.apache.org/jira/browse/AIRFLOW-4771?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16915089#comment-16915089
 ] 

ASF subversion and git services commented on AIRFLOW-4771:
----------------------------------------------------------

Commit ac652744adeec46b6264996fd904804209866f02 in airflow's branch 
refs/heads/master from Tomek
[ https://gitbox.apache.org/repos/asf?p=airflow.git;h=ac65274 ]

[AIRFLOW-4771] Improve initialization of hook in the GCP operators (#5893)

Hook should be initialized in execute method not in operator's constructor.

> Initialization of hook in the GCP operator constructors
> -------------------------------------------------------
>
>                 Key: AIRFLOW-4771
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-4771
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: gcp
>    Affects Versions: 1.10.3
>            Reporter: Kamil Bregula
>            Priority: Major
>             Fix For: 1.10.5
>
>
> Hello,
> This affects following operators:
>  * BigtableInstanceCreateOperator
>  * BigtableInstanceDeleteOperator
>  * BigtableTableCreateOperator
>  * BigtableTableDeleteOperator
>  * BigtableClusterUpdateOperator
>  * BigtableTableWaitForReplicationSensor
>  * GceBaseOperator
>  * GcfFunctionDeployOperator
>  * GcfFunctionDeleteOperator
>  * CloudSpannerInstanceDeployOperator
>  * CloudSpannerInstanceDeleteOperator
>  * CloudSpannerInstanceDatabaseQueryOperator
>  * CloudSpannerInstanceDatabaseDeployOperator
>  * CloudSpannerInstanceDatabaseUpdateOperator
>  * CloudSpannerInstanceDatabaseDeleteOperator
>  * CloudSqlBaseOperator
>  * CloudVisionProductSetCreateOperator
>  * and more...
> This is not good practice for two reasons:
>  * The gcp_conn_id parameter can not be a Jinja template. Templates are 
> resolved before calling the execute method, but after constrcutor.
>  * Hook initialization calls the database connection, because In the 
> GoogleCloudBaseHook class, we have a code snippet:
> {code:java}
> def __init__(self, gcp_conn_id='google_cloud_default', delegate_to=None):
>     self.gcp_conn_id = gcp_conn_id
>     self.delegate_to = delegate_to
>     self.extras = self.get_connection(self.gcp_conn_id).extra_dejson
> {code}
> self.get_connection triggers a database query.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to