[
https://issues.apache.org/jira/browse/AIRFLOW-3528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16724130#comment-16724130
]
ASF GitHub Bot commented on AIRFLOW-3528:
-----------------------------------------
eladkal closed pull request #4325: [AIRFLOW-3528] handle socket exception with
SFTPOperator
URL: https://github.com/apache/incubator-airflow/pull/4325
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/airflow/contrib/operators/sftp_operator.py
b/airflow/contrib/operators/sftp_operator.py
index 117bc55a8c..d364772c83 100644
--- a/airflow/contrib/operators/sftp_operator.py
+++ b/airflow/contrib/operators/sftp_operator.py
@@ -122,7 +122,11 @@ def execute(self, context):
self.ssh_hook.remote_host = self.remote_host
with self.ssh_hook.get_conn() as ssh_client:
- sftp_client = ssh_client.open_sftp()
+ try:
+ sftp_client = ssh_client.open_sftp()
+ except OSError as e:
+ raise AirflowException("Error while connecting client,
error: {0}"
+ .format(str(e)))
if self.operation.lower() == SFTPOperation.GET:
local_folder = os.path.dirname(self.local_filepath)
if self.create_intermediate_dirs:
----------------------------------------------------------------
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:
[email protected]
> handle socket exception with SFTPOperator
> -----------------------------------------
>
> Key: AIRFLOW-3528
> URL: https://issues.apache.org/jira/browse/AIRFLOW-3528
> Project: Apache Airflow
> Issue Type: Bug
> Affects Versions: 1.10.1
> Reporter: Elad
> Assignee: Elad
> Priority: Major
>
> Currently SFTPOperator executes:
>
> {code:java}
> sftp_client = ssh_client.open_sftp()
> {code}
> without handling socket errors.
> If error occurs with the connection the operator show the following message:
> {code:java}
> Subtask: airflow.exceptions.AirflowException: Error while transferring None,
> error: 'NoneType' object has no attribute 'open_sftp'{code}
> This error is misleading because it suggests that there is a problem with the
> file transfer yet the problem in fact can be with the connection.
>
> The issue reported by lot on Slack.
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)