AstroSucheta commented on code in PR #48628:
URL: https://github.com/apache/airflow/pull/48628#discussion_r2022840176
##########
providers/http/src/airflow/providers/http/hooks/http.py:
##########
@@ -172,15 +173,29 @@ def _set_base_url(self, connection: Connection) -> None:
host = connection.host or self.default_host
schema = connection.schema or "http"
# RFC 3986 (https://www.rfc-editor.org/rfc/rfc3986.html#page-16)
- if "://" in host:
- self.base_url = host
- else:
- self.base_url = f"{schema}://{host}" if host else f"{schema}://"
- if connection.port:
- self.base_url = f"{self.base_url}:{connection.port}"
- parsed = urlparse(self.base_url)
- if not parsed.scheme:
- raise ValueError(f"Invalid base URL: Missing scheme in
{self.base_url}")
+ srv=str(connection.extra_dejson.get("srv", "false")).lower()
+ if srv == "true":
+ try:
+ records = dns.resolver.resolve(host, 'SRV')
+ sorted_records = sorted(records, key=lambda r: (r.priority,
-r.weight))
+ best_record = sorted_records[0]
+ host = f"{best_record.target}:{best_record.port}"
Review Comment:
We probably need to iterate over the list of records if the best record is
not reachable
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]