5genesis / Dispatcher

4 stars 2 forks source link

Unable to start auth container under Vagrant #15

Closed NaniteBased closed 3 years ago

NaniteBased commented 3 years ago

I tried to install the Dispatcher on a new machine, but the auth container restarts continuously with the following error:

[INFO] Mon, 12 Apr 2021 09:37:37         auth    msg="Auth REST-API"
Traceback (most recent call last):
  File "auth.py", line 24, in <module>
    from auth_logic import auth_logic
  File "/auth/auth_logic.py", line 10, in <module>
    from auth_utils import session, admin_auth, validate_token, preValidation, check_mail, randomPassword, \
  File "/auth/auth_utils.py", line 9, in <module>
    from DB_Model import User, Registry, Rol, db
  File "/auth/DB_Model.py", line 104, in <module>
    db.create_all()
  File "/usr/local/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 972, in create_all
    self._execute_for_all_tables(app, bind, 'create_all')
  File "/usr/local/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 964, in _execute_for_all_tables
    op(bind=self.get_engine(app, bind), **extra)
  File "/usr/local/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 910, in get_engine
    return connector.get_engine()
  File "/usr/local/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 542, in get_engine
    self._sa.apply_driver_hacks(self._app, info, options)
  File "/usr/local/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 877, in apply_driver_hacks
    info.database = os.path.join(app.root_path, info.database)
AttributeError: can't set attribute

The deployment is on a new Vagrant vm with the following configuration:

Vagrant.configure("2") do |config|
    config.vm.box = "ubuntu/xenial64"
    config.vm.network "forwarded_port", :guest => 8082, :host => 8082
    config.vm.network "forwarded_port", :guest => 5002, :host => 5002
end

And the following commands have been run after starting the instance:

git clone https://github.com/5genesis/Dispatcher.git
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
sudo curl -L "https://github.com/docker/compose/releases/download/1.17.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
ls
cd Dispatcher/
ls
nano dispatcher.conf
./install.sh
sudo ./install.sh
docker ps
sudo groupadd docker
sudo usermod -aG docker $USER
./start.sh
docker ps
docker logs auth

The other containers seem to start fine, except for the mano, which is not correctly configured (this is expected). Can you please check what is the issue?

jmelian commented 3 years ago

Hello,

I see you're not using the releaseB tagged version, please use this one for the testing: https://github.com/5genesis/Dispatcher/tree/release_B

The Auth container might be crashing due to a corrupted db. Deleting the auth.db file could solve the problem

NaniteBased commented 3 years ago

Hi,

True, I forgot to change and was on master. But still, that branch is currently even with release_B, so that should not be an issue... Nevertheless I have changed to the release B, removed auth.db and performed another install, but the error persists.

A bit more info on the issue:

jmelian commented 3 years ago

Hi Bruno,

I just tested the Dispatcher in a VM in the Malaga platform in a new installation from scratch and it works fine. I have no idea why would it fail in a different environment like Vagrant. I will try to find a solution to your problem but I cannot promise anything.

NaniteBased commented 3 years ago

Which OS version are you using? I can try with the same to rule that out.

jmelian commented 3 years ago

Ubuntu 18.04.3 LTS but it has been tested in Xenial as well

NaniteBased commented 3 years ago

Indeed, it does the same on a Bionic box. I will let you know if I find anything, thanks.

NaniteBased commented 3 years ago

Hi, it seems to be a problem with the latest versions of SQLAlchemy. I was able to make it work by adding SQLAlchemy<1.4.0 to the auth requirements, which gives you a version that is still compatible with Flask-SQLAlchemy, but maybe there is a better solution.

jmelian commented 3 years ago

SQLAlchemy v2.1 works fine in VM deployments but maybe for your case in Vagrant, downgrading the library version fixes your issues. I don't think doing so will raise extra issues so feel free to do it for your deployment.

NaniteBased commented 3 years ago

Yes, I can just do that, what I meant is that it may not be the best solution in the general case.

Maybe it could be enough to add a small remark in the documentation: I also saw the problem with a normal VM under VirtualBox (without Vagrant) so maybe more people will find the issue, but for me it is ok to close the issue.

jmelian commented 3 years ago

Alright, close the issue and I will add a note in the installation instructions for Vagrant and VBox