-
Notifications
You must be signed in to change notification settings - Fork 17
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
Fixes for permissions cache and localization issues #489
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,8 +69,9 @@ def get_env_variable(var_name: str, default: Optional[str] = None) -> str: | |
|
||
REDIS_HOST = get_env_variable("REDIS_HOST") | ||
REDIS_PORT = get_env_variable("REDIS_PORT") | ||
REDIS_CELERY_DB = get_env_variable("REDIS_CELERY_DB", "0") | ||
REDIS_RESULTS_DB = get_env_variable("REDIS_RESULTS_DB", "1") | ||
REDIS_CELERY_DB = get_env_variable("REDIS_CELERY_DB", "3") | ||
REDIS_RESULTS_DB = get_env_variable("REDIS_RESULTS_DB", "4") | ||
REDIS_CACHE_DB = get_env_variable("REDIS_CACHE_DB", "5") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving these to some other databases in redis so they are easier to identify. Previously they shared namespace with LMS which made debugging challenging and increased the possibility of name collisions.
Ian2012 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
REDIS_PASSWORD = get_env_variable("REDIS_PASSWORD", "") | ||
|
||
RESULTS_BACKEND = RedisCache(host=REDIS_HOST, port=REDIS_PORT, password=REDIS_PASSWORD, db=REDIS_RESULTS_DB, key_prefix='superset_results') | ||
|
@@ -88,9 +89,9 @@ def get_env_variable(var_name: str, default: Optional[str] = None) -> str: | |
|
||
# Cache for dashboard filter state | ||
FILTER_STATE_CACHE_CONFIG: CacheConfig = { | ||
"CACHE_DEFAULT_TIMEOUT": int(timedelta(days=90).total_seconds()), | ||
"CACHE_DEFAULT_TIMEOUT": 1200, | ||
# should the timeout be reset when retrieving a cached value | ||
"REFRESH_TIMEOUT_ON_RETRIEVAL": True, | ||
"REFRESH_TIMEOUT_ON_RETRIEVAL": False, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bumping down the time and forcing these to refresh now, there could be some confusing artifacts when the filters got cached but a user's permissions had changed. This cuts down the possible length of time for that state to 20 mins. Artifacts were things like problem and video names appearing selected in the filters when the user no longer had access to them, though the charts do the right thing and do not display the data. |
||
**CACHE_CONFIG, | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,10 +97,13 @@ | |
from openedx_jinja_filters import * | ||
|
||
def can_view_courses_wrapper(*args, **kwargs): | ||
""" | ||
Wraps the can_view_courses call in a cache for performance. | ||
""" | ||
from superset.utils.cache import memoized_func | ||
from superset.extensions import cache_manager | ||
|
||
return memoized_func(key="{username}", cache=cache_manager.cache)(can_view_courses)(*args, **kwargs) | ||
kwargs["cache_timeout"] = {{ SUPERSET_USER_PERMISSIONS_CACHE_TIMEOUT }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the actual bug in caching user permissions. Superset docstring says the memoized_func defaults to 300 secs, but it is actually 0 (indefinite). Passing in an explicit timeout fixes it. |
||
return memoized_func()(can_view_courses)(*args, **kwargs) | ||
|
||
|
||
JINJA_CONTEXT_ADDONS = { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
_file_name: Instructor_Dashboard.yaml | ||
_roles: | ||
- {{ SUPERSET_ROLES_MAPPING.instructor }} | ||
- "{{ SUPERSET_ROLES_MAPPING.instructor }}" | ||
css: '' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the localization process to work now we need to wrap all curly braces in double quotes. This still needs testing on the translations_pull side once the existing translations are updated, but I think it will work. |
||
dashboard_title: Instructor Dashboard | ||
description: null | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously we ignored errors here which limited logging things like the LMS 429 rate limit errors, this will now raise them for easier debugging.