Airflow - Experimental API returning 405s for some endpoints

给你一囗甜甜゛ 提交于 2019-12-24 01:57:15

问题


I'm trying to set up my application to use Airflow's Experimental API. I'm using apache-airflow==1.10.2.

Using the config straight out of the box (no authentication enabled), I'm able to create DAG runs using the POST /api/experimental/dags/<DAG_ID>/dag_runs endpoint. However, when I try to use GET /api/experimental/dags/<DAG_ID>/dag_runs I get 405s.

I tried enabling authentication when I noticed that that GET endpoint is part of the www_rbac folder, but not part of the www file. To verify I was able to successfully setup authentication, I configured it for both the api and webserver.

[api]
authenticate = True
auth_backend = airflow.contrib.auth.backends.password_auth

and for the webserver:

[webserver]
# additional config omitted for brevity
authenticate = True
auth_backend = airflow.contrib.auth.backends.password_auth

I created a user using the airflow cli. Then, I was able to log into the webserver using those credentials. Problem is when I try to use that same credentials authenticating on the API, I'm still getting 405s.

Sample curl I'm using is:

curl -X GET \
  http://api_admin:password666@fakeHostName.com/api/experimental/dags/example_bash_operator/dag_runs \
  -H 'Cache-Control: no-cache'

(Real curl has actual username, password, and hostname.)

Response body is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The method is not allowed for the requested URL.</p>

Curl for POST request that does work:

curl -X POST \
  http://api_admin:password666@fakeHostName.com/api/experimental/dags/example_bash_operator/dag_runs \
  -H 'Cache-Control: no-cache' \
  -d '{}'

Good news is that when I have authentication enabled and omit the username and password from the request, I get 401 - Unauthorized.

Has anybody been able to use the GET dag_run endpoint to work?


回答1:


That is a bug in 1.10.2 and has been fixed for 1.10.3 which will be released this week.

Till then you can use the rbac UI:

Enable the RBAC UI by modifying airflow.cfg file.

Under [webserver] section, change rbac = False to rbac = True

Note you will have to create a user as per https://airflow.apache.org/security.html?highlight=rbac#password



来源:https://stackoverflow.com/questions/54834097/airflow-experimental-api-returning-405s-for-some-endpoints

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!