Repository: incubator-airflow Updated Branches: refs/heads/v1-9-test 590d9fef7 -> 2a6c44196
[AIRFLOW-1712][AIRFLOW-756][AIRFLOW-751] Log SSHOperator output SSHOperator does now write stdout to log, just like SSHExecutorOperator did in the past Closes #2686 from OpringaoDoTurno/bring-ssh-logs- back (cherry picked from commit 0ba6ab6e5c5de0257dfc6f542c7396bda5c382b1) Signed-off-by: Bolke de Bruin <bo...@xs4all.nl> Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/2a6c4419 Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/2a6c4419 Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/2a6c4419 Branch: refs/heads/v1-9-test Commit: 2a6c441968fce339ccc9d9e23689a9c21beee724 Parents: 590d9fe Author: Ignasi Peiró <ignasi.pe...@gmail.com> Authored: Thu Nov 2 09:34:44 2017 +0100 Committer: Bolke de Bruin <bo...@xs4all.nl> Committed: Thu Nov 2 09:35:03 2017 +0100 ---------------------------------------------------------------------- airflow/contrib/operators/ssh_operator.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/2a6c4419/airflow/contrib/operators/ssh_operator.py ---------------------------------------------------------------------- diff --git a/airflow/contrib/operators/ssh_operator.py b/airflow/contrib/operators/ssh_operator.py index 897cd1a..bb72330 100644 --- a/airflow/contrib/operators/ssh_operator.py +++ b/airflow/contrib/operators/ssh_operator.py @@ -86,6 +86,12 @@ class SSHOperator(BaseOperator): get_pty=get_pty, timeout=self.timeout ) + stdin.close() + output=b'' + for line in stdout: + output+=line.encode('utf-8') + self.log.info(line.strip('\n')) + exit_status = stdout.channel.recv_exit_status() if exit_status is 0: # only returning on output if do_xcom_push is set @@ -94,9 +100,9 @@ class SSHOperator(BaseOperator): enable_pickling = configuration.getboolean('core', 'enable_xcom_pickling') if enable_pickling: - return stdout.read() + return output else: - return b64encode(stdout.read()).decode('utf-8') + return b64encode(output).decode('utf-8') else: error_msg = stderr.read()