Skip to content

Commit

Permalink
switch to follow_redirects on httpx.get call in CloudSQL provider (#2…
Browse files Browse the repository at this point in the history
…0239)

* switch to follow_redirects on httpx.get call in CloudSQL provider
* sense for parameter as suggested in review
  • Loading branch information
philipherrmann committed Dec 28, 2021
1 parent 2cd4ed0 commit bfd6d45
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions airflow/providers/google/cloud/hooks/cloud_sql.py
Expand Up @@ -31,6 +31,7 @@
import subprocess
import time
import uuid
from inspect import signature
from pathlib import Path
from subprocess import PIPE, Popen
from tempfile import gettempdir
Expand Down Expand Up @@ -499,7 +500,12 @@ def _download_sql_proxy_if_needed(self) -> None:
)
proxy_path_tmp = self.sql_proxy_path + ".tmp"
self.log.info("Downloading cloud_sql_proxy from %s to %s", download_url, proxy_path_tmp)
response = httpx.get(download_url, allow_redirects=True)
# httpx has a breaking API change (follow_redirects vs allow_redirects)
# and this should work with both versions (cf. issue #20088)
if "follow_redirects" in signature(httpx.get).parameters.keys():
response = httpx.get(download_url, follow_redirects=True)
else:
response = httpx.get(download_url, allow_redirects=True)
# Downloading to .tmp file first to avoid case where partially downloaded
# binary is used by parallel operator which uses the same fixed binary path
with open(proxy_path_tmp, 'wb') as file:
Expand Down Expand Up @@ -769,7 +775,7 @@ def __init__(

@staticmethod
def _get_bool(val: Any) -> bool:
if val == 'False':
if val == 'False' or val is False:
return False
return True

Expand Down

0 comments on commit bfd6d45

Please sign in to comment.