Apache气流在运行气流Web服务器作为守护程序时的错误

发布于 2025-02-11 12:24:26 字数 1790 浏览 1 评论 0 原文

我正在Oracle Linux计算机上运行Apache AirFlow 2.3.0,当我在2个不同的终端上运行命令时(命令 AirFlow Scheduler airflow Weberver ),一切正常。但是,当我尝试以守护程序运行服务(命令 airflow Scheduler -d airflow Weberver -d )时,只有调度程序命令。 WebServer命令生成以下错误。

我配置了气流(因此 weberver_conf.py 文件)通过OAuth身份验证,添加了我自己的提供商,并扩展了 airflowsecuritymanager class,所以它可以验证新提供商。正如我之前提到的,如果我运行服务通常一切正常(甚至可以登录到应用程序的身份验证)。我配置了 weberver_conf.py apache documentation ,这是我对 weberver_conf.py file的配置。

from airflow.www.security import AirflowSecurityManager

class BaseSecurityManagerTQ(AirflowSecurityManager):
    def get_oauth_user_info(self, provider, resp):
        if provider == "TQ":
            me = self.appbuilder.sm.oauth_remotes[provider].get('/connect/userinfo')
            data = me.json()
            ans = {
                "username": "tq_" + data.get('name', ""),
                "email": data.get("email", ""),
            }
            return ans
        else:
            return {}

FAB_SECURITY_MANAGER_CLASS = "webserver_config.BaseSecurityManagerTQ"

我尝试使用 ementlib 库导入新的安全模块,但它不起作用。我还尝试了这些解决方案 1 2 ,而且它们也没有起作用。

关于如何解决问题的任何建议?

I am running Apache Airflow 2.3.0 on an Oracle Linux machine, when I run the commands on 2 different terminals (commands airflow scheduler and airflow webserver), everything works fine. But, when I try to run the services as daemons (commands airflow scheduler -D and airflow webserver -D), only the scheduler command works. The webserver command generates the following error.

enter image description here

I configured airflow (and therefore the webserver_conf.py file) to work via OAuth authentication, added my own provider and extended the AirflowSecurityManager class so it can validate the new provider. As I mentioned before if I run the services normally everything works fine (even the authentication to login into the app). I configured the webserver_conf.py file following the Apache documentation, here is the configuration I made to the webserver_conf.py file.

from airflow.www.security import AirflowSecurityManager

class BaseSecurityManagerTQ(AirflowSecurityManager):
    def get_oauth_user_info(self, provider, resp):
        if provider == "TQ":
            me = self.appbuilder.sm.oauth_remotes[provider].get('/connect/userinfo')
            data = me.json()
            ans = {
                "username": "tq_" + data.get('name', ""),
                "email": data.get("email", ""),
            }
            return ans
        else:
            return {}

FAB_SECURITY_MANAGER_CLASS = "webserver_config.BaseSecurityManagerTQ"

I tried importing the new security module using the importlib library, but it didn't work. I also tried these solutions 1,2 and they didn't work either.

Any advice on how to solve the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小…楫夜泊 2025-02-18 12:24:26

我已经设法解决了。我必须添加文件夹其中 weberver_config.py 文件位于python_path。另外,添加 __ INIT __。py 文件以能够导入模块。

I already managed to solve.I had to add the folder where webserver_config.py file is located to the PYTHON_PATH. Also, add a __init__.py file to be able to import the module.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文