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

Fix SQLite permission issue #1984

Merged
merged 3 commits into from
May 22, 2023
Merged

Conversation

vstpme
Copy link
Member

@vstpme vstpme commented May 22, 2023

What this PR does

Fixes #1960.

Checklist

  • Unit, integration, and e2e (if applicable) tests updated
  • Documentation added (or pr:no public docs PR label added if not required)
  • CHANGELOG.md updated (or pr:no changelog PR label added if not required)

@vstpme vstpme added the pr:no public docs Added to a PR that does not require public documentation updates label May 22, 2023
@@ -1,11 +1,8 @@
from rest_framework.response import Response
from rest_framework.views import APIView

from apps.telegram.tasks import register_telegram_webhook
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving this to on_worker_ready so it doesn't fail with RabbitMQ connectivity error when building the docker image.

@@ -19,9 +19,12 @@ RUN pip install -r requirements.txt
# https://stackoverflow.com/questions/34398632/docker-how-to-run-pip-requirements-txt-only-if-there-was-a-change/34399661#34399661
COPY ./ ./

# Collect static files and create an SQLite database
RUN mkdir -p /var/lib/oncall
# Collect static files
RUN DJANGO_SETTINGS_MODULE=settings.prod_without_db DATABASE_TYPE=sqlite3 DATABASE_NAME=/var/lib/oncall/oncall.db SECRET_KEY="ThEmUsTSecretKEYforBUILDstage123" SILK_PROFILER_ENABLED="True" python manage.py collectstatic --no-input
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before removing this line, running python manage.py collectstatic was creating a DB file and everything worked as expected. After removing this line, the DB file is now created by a Celery worker which runs on a different user than uWSGI, which leads to a permission issue.


# Create SQLite database and set permissions
RUN mkdir -p /var/lib/oncall
RUN DATABASE_TYPE=sqlite3 DATABASE_NAME=/var/lib/oncall/oncall.db python manage.py create_sqlite_db
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a new manage.py command that specifically creates a DB file so it's present in the docker image before setting permissions

@vstpme vstpme marked this pull request as ready for review May 22, 2023 18:58
@vstpme vstpme requested a review from a team May 22, 2023 18:58
@vstpme vstpme added this pull request to the merge queue May 22, 2023
Merged via the queue into dev with commit 53d3416 May 22, 2023
@vstpme vstpme deleted the vadimkerr/sqlite-fix-permission-issue branch May 22, 2023 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:no public docs Added to a PR that does not require public documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQLite: attempt to write a readonly database
2 participants