This is an automated email from the ASF dual-hosted git repository.

dstandish pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new 70c74c1  Do not forward cluster-identifier to psycopg2 (#15360)
70c74c1 is described below

commit 70c74c1f6867a2f6cdd2f892a40f43aea858572b
Author: zhzhang <[email protected]>
AuthorDate: Tue Apr 13 22:16:04 2021 -0700

    Do not forward cluster-identifier to psycopg2 (#15360)
    
    `cluster-identifier` is only used by botocore to fetch Redshift 
credentials.   If passed to psycopg2, it will produce error 
`psycopg2.ProgrammingError: invalid dsn: invalid connection option 
"cluster-identifier"`.
    
    Co-authored-by: Jordan Zhang <[email protected]>
---
 airflow/providers/postgres/hooks/postgres.py    | 1 +
 tests/providers/postgres/hooks/test_postgres.py | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/airflow/providers/postgres/hooks/postgres.py 
b/airflow/providers/postgres/hooks/postgres.py
index cd80bd9..95729c5 100644
--- a/airflow/providers/postgres/hooks/postgres.py
+++ b/airflow/providers/postgres/hooks/postgres.py
@@ -102,6 +102,7 @@ class PostgresHook(DbApiHook):
                 'iam',
                 'redshift',
                 'cursor',
+                'cluster-identifier',
             ]:
                 conn_args[arg_name] = arg_val
 
diff --git a/tests/providers/postgres/hooks/test_postgres.py 
b/tests/providers/postgres/hooks/test_postgres.py
index 752bd8d..83843a4 100644
--- a/tests/providers/postgres/hooks/test_postgres.py
+++ b/tests/providers/postgres/hooks/test_postgres.py
@@ -115,7 +115,7 @@ class TestPostgresHookConn(unittest.TestCase):
     @mock.patch('airflow.providers.postgres.hooks.postgres.psycopg2.connect')
     
@mock.patch('airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook.get_client_type')
     def test_get_conn_rds_iam_redshift(self, mock_client, mock_connect):
-        self.connection.extra = '{"iam":true, "redshift":true}'
+        self.connection.extra = '{"iam":true, "redshift":true, 
"cluster-identifier": "different-identifier"}'
         self.connection.host = 
'cluster-identifier.ccdfre4hpd39h.us-east-1.redshift.amazonaws.com'
         login = f'IAM:{self.connection.login}'
         mock_client.return_value.get_cluster_credentials.return_value = {

Reply via email to