contentdb icon indicating copy to clipboard operation
contentdb copied to clipboard

Unable to get a "fresh" database though docker image, or to delete current db

Open Lazerbeak12345 opened this issue 1 year ago • 6 comments

Summary

I wanted to make a quick and easy change to the "test databse" - but couldn't because it was a postgresql database. All attempts to delete the db failed.

Steps to reproduce
  1. Install docker (sudo dnf docker-ce docker-compose after enabling the official COPR from the official docker website on Fedora 39)
  2. set secret_key and wtf... yada yada key to gibberish values like asdfasdfasfd
  3. set USER_ENABLE_EMAIL to False (an attempt to fix the SMTPS errors- still get them with or without it)
  4. created config.env verbatim as in the getting_started.md
  5. docker-compose up --build
  6. ./utils/run_migrations.sh
  7. ./utils/bash.sh
  8. (from inside docker) python utils/setup.py -t
  9. At this point I had realized that I needed to ensure that at least one of the mods had multiple releases
  10. Log into the local webservice using the creds in the getting_started.md
  11. Attempt and fail to
    • Add a new release to an existing package
      • Using Git (failed because package didn't match, then next PermissionError: [Errno 13] Permission denied: '/var/cdb/uploads/45b0153bb2.zip')
      • Using zip (same permission error)
    • Add a new package (same permission error)
      • Using git (same permission error)
      • Using zip (same permission error)
  12. (from inside docker) python utils/setup.py -d - an attempt to delete the database, after looking at the code for that file.

The database remained, even after (attempting) to delete it. I couldn't figure out how to delete the database using docker.

The sheer number of error messages I saw the whole time are so vast, I can't post all of them - partially due to the terminal trimming them out. I can attempt to recreate them upon request.

The truncated error message when I do anything with utils/setup.py:

sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) dup
licate key value violates unique constraint "license_name_key"
DETAIL:  Key (name)=(GPLv2.1) already exists.

Lazerbeak12345 avatar Dec 14 '23 02:12 Lazerbeak12345

~~Workaround: sudo git clean -fd (this is the nuclear option - never use this command unless you know what it does)~~

FAILED - during test package creation, sql "duplicate key" errors were my only reply due to the database not being empty

Also:

  • psql isn't present in the docker image, so I couldn't manually delete the database
  • When the service is running, on the host ps -s | grep postg returns a few items, but when it isn't, nothing.

Lazerbeak12345 avatar Dec 14 '23 03:12 Lazerbeak12345

Workaround: (DANGEROUS) use sudo to recursively remove the contents of the data folder

EDIT: this might not be working either - but I'm emotionally exhausted from this project for today.

Lazerbeak12345 avatar Dec 14 '23 03:12 Lazerbeak12345

proposed solution: document this somewhere for the next guy?

Lazerbeak12345 avatar Dec 14 '23 03:12 Lazerbeak12345

The way I delete the db is by shutting the container down, doing sudo rm -rf data/db, and then restarting the container. The -d arg is left over from when I used sqlite

As for uploads, you need to do sudo chown $(whoami):5123 -R data/uploads

rubenwardy avatar Dec 15 '23 15:12 rubenwardy

https://github.com/minetest/contentdb/commit/b919cd087a12c01d007ac91b8a8839f3a71237d3

https://github.com/minetest/contentdb/commit/2711dbd23fd26dd93f47cf85ca3c1c974530aeb9

rubenwardy avatar Dec 15 '23 15:12 rubenwardy

As for uploads, you need to do sudo chown $(whoami):5123 -R data/uploads

You may also need to do chmod g+w data/uploads, I haven't checked. Should be documented if so

rubenwardy avatar Dec 15 '23 15:12 rubenwardy