airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] potiuk commented on a change in pull request #4170: [AIRFLOW-3275] Implement Google Cloud SQL Query operator
Date Mon, 12 Nov 2018 10:15:42 GMT
potiuk commented on a change in pull request #4170: [AIRFLOW-3275] Implement Google Cloud SQL
Query operator
URL: https://github.com/apache/incubator-airflow/pull/4170#discussion_r232599428
 
 

 ##########
 File path: airflow/contrib/hooks/gcp_sql_hook.py
 ##########
 @@ -261,3 +280,559 @@ def _wait_for_operation_to_complete(self, project_id, operation_name):
                 # No meaningful info to return from the response in case of success
                 return True
             time.sleep(TIME_TO_SLEEP_IN_SECONDS)
+
+
+CLOUD_SQL_PROXY_DOWNLOAD_URL = "https://dl.google.com/cloudsql/cloud_sql_proxy.{}.{}"
+CLOUD_SQL_PROXY_VERSION_DOWNLOAD_URL = \
+    "https://storage.googleapis.com/cloudsql-proxy/{}/cloud_sql_proxy.{}.{}"
+
+GCP_CREDENTIALS_KEY_PATH = "extra__google_cloud_platform__key_path"
+GCP_CREDENTIALS_KEYFILE_DICT = "extra__google_cloud_platform__keyfile_dict"
+
+
+class CloudSqlProxyRunner(LoggingMixin):
+    """Downloads and runs cloud-sql-proxy as subprocess of the python process.
+
+    The cloud-sql-proxy needs to be downloaded and started before we can connect
+    to the Google Cloud SQL instance via database connection. It establishes
+    secure tunnel connection to the database - it authorizes using the
+    GCP credentials that are passed by the configuration.
+
+    More details about the proxy can be found here:
+    https://cloud.google.com/sql/docs/mysql/sql-proxy
+
+    """
+    def __init__(self,
+                 path_prefix,
+                 instance_specification,
+                 gcp_conn_id='google_cloud_default',
+                 project_id=None,
+                 sql_proxy_version=None,
+                 sql_proxy_binary_path=None):
+        """
+        Creates the proxy runner class.
+
+        :param path_prefix: unique path prefix where proxy will be downloaded and
+               directories created for unix sockets.
+        :type path_prefix: str
+        :param instance_specification: specification of the instance to connect the
+            proxy to. It should be specified in the form that is described in
+            https://cloud.google.com/sql/docs/mysql/sql-proxy#multiple-instances in
+            -instances parameter (typically in the form of <project>:<region>:<instance>
+            for UNIX socket connections and in the form of
+            <project>:<region>:<instance>=tcp:<port> for TCP connections.
+        :type instance_specification: str
+        :param gcp_conn_id: id of Google Cloud Platform connection to use for
+            authentication
+        :type: str
+        :param project_id: optional id of the GCP project to connect to - it overwrites
+              default project id taken from the GCP connection
+        :type project_id: str
+        :param sql_proxy_version: specific version of SQL proxy to download
+            (for example 'v1.13'). By default latest version is downloaded.
+        :type sql_proxy_version: str
+        :param sql_proxy_binary_path: If specified, then proxy will be
+              used from the path specified rather than dynamically generated. This means
 
 Review comment:
   Done!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message