Search code examples
airflowwebserverdaemon

Error with Apache Airflow while running airflow webserver as daemon


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?


Solution

  • 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.