Airflow airflow.exceptions.AirflowException: не удалось создать удаленный временный файл SSHExecuteOperator - PullRequest
0 голосов
/ 28 мая 2018

Я пытаюсь запустить простой SSHExecutorOperator в Airflow.

Вот мой файл .py:

from airflow.contrib.hooks.ssh_hook import SSHHook
from datetime import timedelta

default_args = {
'owner': 'airflow',
'start_date':airflow.utils.dates.days_ago(2),
'retries': 3

}

dag = DAG('Nas_Hdfs', description='Simple tutorial DAG',
      schedule_interval=None,default_args=default_args,
      catchup=False)

sshHook = SSHHook(conn_id='101')
sshHook.no_host_key_check = True

t2 = SSHExecuteOperator(task_id="NAS_TO_HDFS_FILE_COPY",
bash_command="hostname ",
ssh_hook=sshHook,
    dag=dag
    )

t2

Идентификатор соединения 101 выглядит следующим образом: Connection configuration from UI

Я получаю ниже ошибка:

ERROR - Failed to create remote temp file

Вот полные журналы:

INFO - Subtask: --------------------------------------------------------------------------------
INFO - Subtask: Starting attempt 1 of 4
INFO - Subtask: --------------------------------------------------------------------------------
INFO - Subtask: 
INFO - Subtask: [2018-05-28 08:54:22,812] {models.py:1342} INFO - Executing <Task(SSHExecuteOperator): NAS_TO_HDFS_FILE_COPY> on 2018-05-28 08:54:12.876538
INFO - Subtask: [2018-05-28 08:54:23,303] {models.py:1417} ERROR - Failed to create remote temp file
INFO - Subtask: Traceback (most recent call last):
INFO - Subtask:   File "/opt/miniconda3/lib/python2.7/site-packages/airflow/models.py", line 1374, in run
INFO - Subtask:     result = task_copy.execute(context=context)
INFO - Subtask:   File "/opt/miniconda3/lib/python2.7/site-packages/airflow/contrib/operators/ssh_execute_operator.py", line 128, in execute
INFO - Subtask:     self.task_id) as remote_file_path:
INFO - Subtask:   File "/opt/miniconda3/lib/python2.7/site-packages/airflow/contrib/operators/ssh_execute_operator.py", line 64, in __enter__
INFO - Subtask:     raise AirflowException("Failed to create remote temp file")
INFO - Subtask: AirflowException: Failed to create remote temp file
INFO - Subtask: [2018-05-28 08:54:23,304] {models.py:1433} INFO - Marking task as UP_FOR_RETRY
INFO - Subtask: [2018-05-28 08:54:23,342] {models.py:1462} ERROR - Failed to create remote temp file
INFO - Subtask: Traceback (most recent call last):
INFO - Subtask:   File "/opt/miniconda3/bin/airflow", line 28, in <module>
INFO - Subtask:     args.func(args)
INFO - Subtask:   File "/opt/miniconda3/lib/python2.7/site-packages/airflow/bin/cli.py", line 422, in run
INFO - Subtask:     pool=args.pool,
INFO - Subtask:   File "/opt/miniconda3/lib/python2.7/site-packages/airflow/utils/db.py", line 53, in wrapper
INFO - Subtask:     result = func(*args, **kwargs)
INFO - Subtask:   File "/opt/miniconda3/lib/python2.7/site-packages/airflow/models.py", line 1374, in run
INFO - Subtask:     result = task_copy.execute(context=context)
INFO - Subtask:   File "/opt/miniconda3/lib/python2.7/site-packages/airflow/contrib/operators/ssh_execute_operator.py", line 128, in execute
INFO - Subtask:     self.task_id) as remote_file_path:
INFO - Subtask:   File "/opt/miniconda3/lib/python2.7/site-packages/airflow/contrib/operators/ssh_execute_operator.py", line 64, in __enter__
INFO - Subtask:     raise AirflowException("Failed to create remote temp file")
INFO - Subtask: airflow.exceptions.AirflowException: Failed to create remote temp file
INFO - Task exited with return code 1

Любая помощь высоко ценится!

РЕДАКТИРОВАТЬ: Я запустил это в моей оболочке Python пользователя воздушного потока, и это вывод:

from airflow.contrib.hooks.ssh_hook import SSHHook 
sshHook = SSHHook(conn_id='101') 
sshHook.no_host_key_check = True 
sshHook.Popen(["-q", "mktemp", "--tmpdir", "tmp_XXXXXX"])

Вывод: SshHookOutput

1 Ответ

0 голосов
/ 03 сентября 2018

убедитесь, что выполните 3 шага ниже:

  1. используйте ключ ssh вместо пароля
  2. "key_file" используйте файл id_rsa, а не id_rsa.pub
  3. airflowнужен владелец и права 0600, чтобы дотронуться до файла id_rsa и id_rsa.pub
...