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

Prevent certain configuration settings from unexpectedly reverting to defaults #3862

Merged
merged 3 commits into from
Jun 16, 2022

Conversation

bufke
Copy link
Contributor

@bufke bufke commented Jun 13, 2022

Description

Work around django-constance issue where values are undesirably reset to their default.

Add redis cache for constance database backend.

Introduces a new environment variable CACHE_URL to define the default Django cache. This is only used for constance right now, but could be used elsewhere.

Internal notes

This requires updating kobo-install. Do not release this change until kobo-install is updated to support CACHE_URL with the existing redis instance.

Add workaround for constance to not reset values to default when unable
to connect to a database object.
@bufke bufke requested a review from noliveleger June 13, 2022 19:09
dependencies/pip/dev_requirements.txt Outdated Show resolved Hide resolved
dependencies/pip/external_services.txt Outdated Show resolved Hide resolved
dependencies/pip/requirements.txt Outdated Show resolved Hide resolved
kobo/apps/constance_backends/database.py Outdated Show resolved Hide resolved
@@ -844,6 +845,11 @@ def __init__(self, *args, **kwargs):
'socket_timeout': env.int('REDIS_SESSION_SOCKET_TIMEOUT', 1),
}

CACHES = {
# Set CACHE_URL to override
'default': env.cache(default=env.str("REDIS_SESSION_URL", default='redis://redis_cache:6380/2')),
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather use another variable name REDIS_CONSTANCE_BACKEND_URL (in single-quote :P). I know it's another one, but I would leave the session database alone and use a different index.
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems reasonable. That means adding to kobo-install right? I suppose kobo-install doesn't need to ask anything extra, but needs to set this new env var.

For future local dev environments, it could use the passwordless default redis_cache with a different index.

Copy link
Contributor

Choose a reason for hiding this comment

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

@noliveleger
Copy link
Contributor

LGTM, tests are passing locally.
I'll wait for kobo-install PR to be merged before merging this one.

@noliveleger noliveleger merged commit eb098cd into beta Jun 16, 2022
@noliveleger noliveleger deleted the django-constance-cache-db-reliability branch June 16, 2022 18:16
@jnm jnm changed the title Django constance cache and reliability Prevent certain configuration settings from unexpectedly reverting to defaults Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants