import os
import logging
from flask.appbuilder.security.manager import AUTH_OAUTH
from airflow.www.security import AirflowSecurityManager
AUTH_TYPE = AUTH_OAUTH
AUTH_ROLES_SYNC_AT_LOGIN = True
AUTH_USER_REGISTRATION = True
log = logging.getLogger(__name__)
log.setLevel(os.getenv("AIRFLOW__LOGGING__FAB_LOGGING_LEVEL", "INFO"))
OAUTH_PROVIDERS = [
{
"name": "egast",
"icon": "fa-address-card",
"token_key": "access_token",
"remote_app": {
"client_id": "<id>",
"client_secret": "<secret>",
"client_kwargs": {
"scope": "<scope>",
"grant_type": "authorization_code",
},
"access_token_method": "POST",
"access_token_params": {
"client_id": "<id>",
},
"request_token_url": None,
"api_base_url": "<url>",
"access_token_url": "<url>/token.oauth2",
"authorize_url": "<url>/authorization.oauth2"
}
}
]
class CustomSecurityManager(AirflowSecurityManager):
def oauth_user_info(sm, provider, response=None):
if provider == "egast":
me = sm.oauth_remote[provider].get("userinfo")
log.debug(me.data)
logging.info(me.data)
logging.debug(me.data)
print(me.data)
else:
log.debug("Nothing!!")
logging.info("Nothing!!")
logging.debug("Nothing!!")
print("Nothing!!")
SECURITY_MANAGER_CLASS = CustomSecurityManager
AUTH_ROLES_MAPPING = {
"FAB_USERS": ['User'],
"FAB_ADMINS": ['Admin']
}
我尝试在Airflow中集成oauth,我有一个类CustomSecurityManager,我在其中打印或记录一些语句以进行调试。在/home/airflow/airflow/下生成了几个日志文件,如airflow.cfg、webserver.log、webserver.out、scheduler.log等。但它们都不包含这些webserver_config.py日志。因此,启动Airflow Web服务器和调度程序后,我可以在哪里找到这些日志?
1条答案
按热度按时间fkaflof61#
能否添加以下内容:
与其他日志语句相比,日志格式是关闭的,但我现在得到了以下内容:
缺省情况下,Web服务器的日志被写入stdout,因此在kubernetes中,可以通过
kubectl logs
命令获取这些日志(我使用的是Kubernetes executor设置,但我不希望这有什么影响,只需转到设置中stdout所在的位置即可)