nbentoumi / ansibledb

AnsibleDB is Flask API Web server uses MongoDB as Database to store Ansible reports and ansible facts, this tool can be used to query hosts and facters managed Ansible as well search ansible logs.
https://nbentoumi.github.io/ansibledb/
Apache License 2.0
19 stars 0 forks source link

flask:3.0.0 incompatible with flask-restx:1.1.0 seems to break the ansibledb server #2

Closed bmorris53 closed 11 months ago

bmorris53 commented 12 months ago

My docker container during an automated build updated flask from 2.3.3 to 3.0.0 and am now getting the following traceback when attempting to redeploy the ansibledb pod with the latest container running flask 3.0.0. Looks like flask-restx is trying to use something that is no longer included in the base flask package: https://github.com/python-restx/flask-restx/issues/567

I'll be forcing the requirements.txt to use v2.3.3 for now. Just wanted to let you know of the issue.

Maybe update requirements.txt to the following in order to ensure compatability between flask and flask-restx until restx is updated to 1.1.1.

pymongo
Flask==2.3.3
python-dotenv
gunicorn
flask_swagger_ui
flask_restx==1.1.0
ldap3

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/flask_restx/api.py", line 18, in <module>
    from flask.helpers import _endpoint_from_view_func
ImportError: cannot import name '_endpoint_from_view_func' from 'flask.helpers' (/usr/local/lib/python3.9/site-packages/flask/helpers.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/gthread.py", line 95, in init_process
    super().init_process()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python3.9/site-packages/gunicorn/util.py", line 371, in import_app
    mod = importlib.import_module(module)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/app/ansibledb.py", line 15, in <module>
    from models import AnsibleDB
  File "/app/models.py", line 5, in <module>
    from main import app, servers
  File "/app/main/__init__.py", line 3, in <module>
    from flask_restx import Api, apidoc
  File "/usr/local/lib/python3.9/site-packages/flask_restx/__init__.py", line 2, in <module>
    from .api import Api  # noqa
  File "/usr/local/lib/python3.9/site-packages/flask_restx/api.py", line 20, in <module>
    from flask.scaffold import _endpoint_from_view_func
ModuleNotFoundError: No module named 'flask.scaffold'
[2023-10-10 14:59:17 +0000] [11] [INFO] Worker exiting (pid: 11)
[2023-10-10 14:59:17 +0000] [12] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/flask_restx/api.py", line 18, in <module>
    from flask.helpers import _endpoint_from_view_func
ImportError: cannot import name '_endpoint_from_view_func' from 'flask.helpers' (/usr/local/lib/python3.9/site-packages/flask/helpers.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/gthread.py", line 95, in init_process
    super().init_process()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python3.9/site-packages/gunicorn/util.py", line 371, in import_app
    mod = importlib.import_module(module)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/app/ansibledb.py", line 15, in <module>
    from models import AnsibleDB
  File "/app/models.py", line 5, in <module>
    from main import app, servers
  File "/app/main/__init__.py", line 3, in <module>
    from flask_restx import Api, apidoc
  File "/usr/local/lib/python3.9/site-packages/flask_restx/__init__.py", line 2, in <module>
    from .api import Api  # noqa
  File "/usr/local/lib/python3.9/site-packages/flask_restx/api.py", line 20, in <module>
    from flask.scaffold import _endpoint_from_view_func
ModuleNotFoundError: No module named 'flask.scaffold'
[2023-10-10 14:59:17 +0000] [12] [INFO] Worker exiting (pid: 12)
[2023-10-10 14:59:17 +0000] [7] [ERROR] Worker (pid:11) exited with code 3
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 209, in run
    self.sleep()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 360, in sleep
    ready = select.select([self.PIPE[0]], [], [], 1.0)
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
    self.reap_workers()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 530, in reap_workers
    raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/gunicorn", line 8, in <module>
    sys.exit(run())
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 67, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 236, in run
    super().run()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 72, in run
    Arbiter(self).run()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 229, in run
    self.halt(reason=inst.reason, exit_status=inst.exit_status)
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 342, in halt
    self.stop()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 396, in stop
    time.sleep(0.1)
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
    self.reap_workers()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 530, in reap_workers
    raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
nbentoumi commented 11 months ago

Hi @bmorris53 ,

Thanks for your feedback, I will check and get back to you to fix this issue.

Regards

nbentoumi commented 11 months ago

Hi @bmorris53 ,

Thanks for your feedback, I've updated the requirement.

Regards

nbentoumi commented 11 months ago

Closing this issue

nbentoumi commented 11 months ago

@bmorris53 ,

Can we close this issue ?

bmorris53 commented 11 months ago

Yes, I apologize for the late response. Thank you for the support!Sent from my iPhoneOn Oct 27, 2023, at 7:49 PM, Nasredine Bentoumi @.***> wrote: @bmorris53 , Can we close this issue ?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>