我喜欢从composer重新运行或运行DAG,下面是我使用的命令,但是我遇到了类似这样的异常
kubeconfig entry generated for europe-west1-leo-stage-bi-db7ea92f-gke.
Executing within the following Kubernetes cluster namespace: composer-1-7-7-airflow-1-10-1-db7ea92f
command terminated with exit code 2
[2020-07-14 12:44:34,472] {settings.py:176} INFO - setting.configure_orm(): Using pool settings. pool_size=5, pool_recycle=1800
[2020-07-14 12:44:35,624] {default_celery.py:80} WARNING - You have configured a result_backend of redis://airflow-redis-service.default.svc.cluster.local:6379/0, it is highly recommended to use an alternative result_backend (i.e. a database).
[2020-07-14 12:44:35,628] {__init__.py:51} INFO - Using executor CeleryExecutor
[2020-07-14 12:44:35,860] {app.py:51} WARNING - Using default Composer Environment Variables. Overrides have not been applied.
[2020-07-14 12:44:35,867] {configuration.py:516} INFO - Reading the config from /etc/airflow/airflow.cfg
[2020-07-14 12:44:35,895] {configuration.py:516} INFO - Reading the config from /etc/airflow/airflow.cfg
usage: airflow [-h]
{backfill,list_tasks,clear,pause,unpause,trigger_dag,delete_dag,pool,variables,kerberos,render,run,initdb,list_dags,dag_state,task_failed_deps,task_state,serve_logs,test,webserver,resetdb,upgradedb,scheduler,worker,flower,version,connections,create_user}
...
airflow: error: unrecognized arguments: --yes
ERROR: (gcloud.composer.environments.run) kubectl returned non-zero status code.
这是我的命令,第二行已指定参数,任何人都可以帮忙吗? 谢谢
gcloud composer environments run leo-stage-bi --location=europe-west1 backfill -- regulatory_spain_monthly -s 20190701 -e 20190702 -t "regulatory_spain_rud_monthly_materialization" --reset_dagruns
gcloud composer environments run project-name --location=europe-west1 backfill -- DAG name -s start date -e end date -t task in the DAG --reset_dagruns
答案 0 :(得分:1)
我已经从backfill
工具集中检查了gcloud
实用程序中的Airflow Google Cloud SDK 300.0.0
子命令功能,并且已经完成了使用backfill
操作执行测试的尝试相同的错误:
气流:错误:无法识别的参数:-是
深入研究此问题并为--verbosity=debug
命令启动gcloud composer environments run
,我已经意识到造成延迟的原因:
gcloud composer environments run <ENVIRONMENT> --location=<LOCATION> --verbosity=debug backfill -- <DAG> -s <start_date> -e <end_date> -t "task_id" --reset_dagruns
调试:执行命令:['/ usr / bin / kubectl','--namespace', '',``exec'',``airflow-worker-*'',``--stdin'',``--tty'', '-容器','气流工人','-','气流','回填','', '-s','
','-e',' ','-t','task_id', '--reset_dagruns','-是']
以上输出反映了gcloud
如何解耦命令行参数,并将其分配给kubectl
命令继承者的方式。这样说,我假设-是 argument出于未知原因被传播,甚至错误地将其余参数放置在了该位置。
寻找解决方法时,我正在对特定的Airflow Worker Pod编写相关的kubectl
命令调用,并手动调度Airflow命令行参数:
kubectl -it exec $(kubectl get po -l run=airflow-worker -o jsonpath='{.items[0].metadata.name}' \
-n $(kubectl get ns| grep composer*| awk '{print $1}')) -n $(kubectl get ns| grep composer*| awk '{print $1}') \
-c airflow-worker -- airflow backfill <DAG> -s <start_date> -e <end_date> -t "task_id" --reset_dagruns
现在,airflow backfill
命令成功执行,而不会引发任何错误。
答案 1 :(得分:0)
要触发手动运行,可以使用trigger_dag参数:
gcloud composer environments run <COMPOSER_INSTANCE_NAME> --location <LOCATION> trigger_dag -- <DAG_NAME>