mobuchowski commented on code in PR #31360:
URL: https://github.com/apache/airflow/pull/31360#discussion_r1228405037
##########
airflow/providers/sftp/operators/sftp.py:
##########
@@ -188,3 +191,85 @@ def execute(self, context: Any) -> str | list[str] | None:
raise AirflowException(f"Error while transferring {file_msg},
error: {str(e)}")
return self.local_filepath
+
+ def get_openlineage_facets_on_start(self):
+ try:
+ from openlineage.client.run import Dataset
+
+ from airflow.providers.openlineage.extractors import
OperatorLineage
+ except ImportError:
+ return None
+
+ scheme = "file"
+ local_host = socket.gethostname()
+ try:
+ local_host = socket.gethostbyname(local_host)
+ except Exception as e:
+ self.log.warning(
+ f"Failed to resolve local hostname. Using the hostname got by
socket.gethostbyname() without resolution. {e}", # noqa: E501
+ exc_info=True,
+ )
+
+ if self.sftp_hook is not None:
+ hook = self.sftp_hook
+ elif self.ssh_hook is not None:
+ hook = self.ssh_hook
+ else:
+ hook = SFTPHook(ssh_conn_id=self.ssh_conn_id)
+
+ if self.remote_host is not None:
+ remote_host = self.remote_host
+ else:
+ remote_host = hook.get_connection(hook.ssh_conn_id).host
+ try:
+ remote_host = socket.gethostbyname(remote_host)
+ except Exception as e:
Review Comment:
Yes. There are several possible socket exceptions here, but all are
subclassing `OSError` with which I replaced `Exception`.
--
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]