Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest Version Container Crashing upon Startup #79

Open
samcro1967 opened this issue Feb 20, 2023 · 12 comments
Open

Latest Version Container Crashing upon Startup #79

samcro1967 opened this issue Feb 20, 2023 · 12 comments
Labels
bug Something isn't working

Comments

@samcro1967
Copy link

Describe the bug
Docker container with the latest version does not start.

To Reproduce
Steps to reproduce the behavior:

  1. Pull the latest image and run it.

Expected behavior
Container launches without error and stays running.

Logs

Creating directory /config/migrations ...  done
Creating directory /config/migrations/versions ...  done
Generating /config/migrations/script.py.mako ...  done
Generating /config/migrations/env.py ...  done
Generating /config/migrations/alembic.ini ...  done
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Generating /config/migrations/README ...  done
Please edit configuration/connection/logging settings in '/config/migrations/alembic.ini' before proceeding.
ERROR [flask_migrate] Error: Can't locate revision identified by 'e935a3b14ca8'
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
ERROR [flask_migrate] Error: Can't locate revision identified by 'e935a3b14ca8'
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
ERROR [flask_migrate] Error: Can't locate revision identified by 'e935a3b14ca8'

Server information

  • Installation method: Docker
  • Python version: Version in container
  • Operating System: Ubuntu 22.04

Additional context
Started about 2 hours ago when the new container was published.

@samcro1967
Copy link
Author

Commands seemed to have all failed finding rev id e935a3b14ca8.

docker run   -it   --entrypoint /bin/sh   --restart always   -v /downloads:/downloads:rw   -v /metatube:/database:rw   jvt038/metatube:latest

/config # flask -A metatube.py db revision --rev-id e935a3b14ca8
  Creating directory /config/migrations ...  done
  Creating directory /config/migrations/versions ...  done
  Generating /config/migrations/script.py.mako ...  done
  Generating /config/migrations/env.py ...  done
  Generating /config/migrations/alembic.ini ...  done
  Generating /config/migrations/README ...  done
  Please edit configuration/connection/logging settings in '/config/migrations/alembic.ini' before proceeding.
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
ERROR [flask_migrate] Error: Can't locate revision identified by 'e935a3b14ca8'

/config # flask -A metatube.py db migrate
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
ERROR [flask_migrate] Error: Can't locate revision identified by 'e935a3b14ca8'

/config # flask -A metatube.py db upgrade
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
ERROR [flask_migrate] Error: Can't locate revision identified by 'e935a3b14ca8'

@JVT038
Copy link
Owner

JVT038 commented Feb 20, 2023

I think I have fixed it.
Pull the new container that was just pushed automatically.
Make sure to set the new INIT_DB variable to False (or at least, not to 'True')
So, run the container interactively and override the entrypoint with a command like this:
(Also, add all the environment variables and volumes, such as DATABASE_URL if you have modified these variables.)

docker run \
  -it \
  --entrypoint /bin/sh \
  --restart always \
  -e INIT_DB=false \
  -v /downloads:/downloads:rw \
  -v /metatube/database:/database:rw \
  -v /metatube/migrations:/config/migrations \
  jvt038/metatube:latest

When you're in the CLI of the container, you run the following commands:

  1. cd /config
  2. flask -A metatube.py db init
  3. flask -A metatube.py db revision --rev-id <your revision id>

@JVT038
Copy link
Owner

JVT038 commented Feb 20, 2023

This fixed it for me.

Make sure to add this new volume to both the docker run command and your docker-compose.yml file (if you have that): /metatube/migrations:/config/migrations .

And in the docker run command, set the new environment variable INIT_DB to false.

@JVT038 JVT038 mentioned this issue Feb 20, 2023
@samcro1967
Copy link
Author

samcro1967 commented Feb 20, 2023

No luck with latest container either. Upgrade seems to work and container start and dies immediately so no container logs to view. I do have files in the migrations folder. I don;t really have anything I need "stored in the app". May be easier to just delete the DB and let it init a new one since the upgrade process is not working for me?

Could also be previous attempts at an upgrade corrupted the DB? I could restore it from yesterday if you want to continue to troubleshoot the upgrade process. If not, I can just start with a clean slate. I would just set INIT_DB=true and remove the migrations folder to do that?

Command I ran manually

cd /config
flask -A metatube.py db init
flask -A metatube.py db revision --rev-id e935a3b14ca8

Docker Run

 docker run -it --name metatube --entrypoint /bin/sh --restart always -v /home/username/Documents/Docker/metatube/downloads:/downloads:rw -v /home/username/Documents/Docker/metatube/database:/database:rw -v /home/username/Documents/Docker/metatube/migrations:/config/migrations -e PORT=8093 -e HOST=0.0.0.0 -e DATABASE_URL=sqlite:////database/app.db -e INIT_DB=False jvt038/metatube:latest

Docker Compose

  metatube:
    image: jvt038/metatube:latest
    container_name: metatube
    restart: always
    environment:
      - PORT=8093
      - HOST=0.0.0.0
      - DATABASE_URL=sqlite:////database/app.db
      - INIT_DB=FALSE
    volumes:
      - ${docker}/metatube/downloads:/downloads:rw
      - ${docker}/metatube/database:/database:rw
      - ${docker}/metatube/migrations:/config/migrations
    entrypoint: /bin/sh

@JVT038
Copy link
Owner

JVT038 commented Feb 20, 2023

Try this instead then.

Download & install DB Browser for SQLite
Open the database file with DB Browser and navigate to the 'browse data' tab.
Select the table alembic_version and then select the only row.
Delete the only row that is present. (see screenshot)
Save the database by going to File -> Write changes or by using CTRL + S shortcut.
Close the app and try to restart your docker-compose file.

image

@JVT038
Copy link
Owner

JVT038 commented Feb 20, 2023

What do you see in the CLI when you run this command?

flask -A metatube.py db revision --rev-id e935a3b14ca8

@samcro1967
Copy link
Author

I deleted the database entry and the files in the migrations folder. Performed the docker run and executed the 2 commands again. Exited the container and did docker compose up. Same results. Container starts and stops immediately. Results of the 2 commands are below.

/ # cd config
/config # flask -A metatube.py db init
  Creating directory /config/migrations/versions ...  done
  Generating /config/migrations/script.py.mako ...  done
  Generating /config/migrations/env.py ...  done
  Generating /config/migrations/alembic.ini ...  done
  Generating /config/migrations/README ...  done
  Please edit configuration/connection/logging settings in '/config/migrations/alembic.ini' before proceeding.

/config # flask -A metatube.py db revision --rev-id e935a3b14ca8
  Generating /config/migrations/versions/e935a3b14ca8_.py ...  done
/config #

@JVT038
Copy link
Owner

JVT038 commented Feb 20, 2023

Are you sure you have mounted the migrations folder like instructed?
You should mount /config/migrations in both your docker run command and your docker-compose.yml file.

@JVT038
Copy link
Owner

JVT038 commented Feb 20, 2023

After running those two commands, you exit and shut down the container and start your docker-compose file.
This works for me on my end.

@samcro1967
Copy link
Author

I believe so. My docker run command and compose are above for your validation. I am doing a docker rm -f metatube to kill the container and then a docker compose up -d.

@samcro1967
Copy link
Author

Today I renamed app.db to app.db_old and then removed INIT_DB=FALSE, the entrypoint override, and the volume mapping from the docker compose to spin up a fresh install. The container spins up as expected with a new database.

@JVT038
Copy link
Owner

JVT038 commented May 14, 2023

My apologies for the lack of maintenance and the vast amount of bugs.
I have been struggling to find sufficient motivation to fix these issues, and I can't promise anything.
I'll try to fix this and close these issues.

@JVT038 JVT038 added enhancement New feature or request bug Something isn't working and removed enhancement New feature or request labels May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants