Palm 2 ORA file upload failure

I’m running openedx palm 2 with tutor 16.1.1 in production. When uploading files in ORAs, I get django.core.cache.backends.base.InvalidCacheBackendError: The connection 'ora2-storage' doesn't exist. error. My full log is as follows:

Traceback (most recent call last):
  File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/openedx/venv/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/openedx/venv/lib/python3.8/site-packages/django/views/decorators/clickjacking.py", line 50, in wrapped_view
    resp = view_func(*args, **kwargs)
  File "/openedx/edx-platform/./lms/djangoapps/courseware/block_render.py", line 865, in handle_xblock_callback
    return _invoke_xblock_handler(request, course_id, usage_id, handler, suffix, course=course)
  File "/openedx/edx-platform/./lms/djangoapps/courseware/block_render.py", line 1014, in _invoke_xblock_handler
    resp = handler_instance.handle(handler, req, suffix)
  File "/openedx/venv/lib/python3.8/site-packages/xblock/mixins.py", line 84, in handle
    return self.runtime.handle(self, handler_name, request, suffix)
  File "/openedx/edx-platform/xmodule/x_module.py", line 1033, in handle
    return super().handle(block, handler_name, request, suffix=suffix)
  File "/openedx/venv/lib/python3.8/site-packages/xblock/runtime.py", line 1081, in handle
    results = handler(request, suffix)
  File "/openedx/venv/lib/python3.8/site-packages/xblock/mixins.py", line 63, in wrapper
    response = func(self, request_json, suffix)
  File "/openedx/venv/lib/python3.8/site-packages/openassessment/xblock/submission_mixin.py", line 504, in upload_url
    url = file_upload_api.get_upload_url(key, content_type)
  File "/openedx/venv/lib/python3.8/site-packages/openassessment/fileupload/api.py", line 29, in get_upload_url
    return backends.get_backend().get_upload_url(key, content_type)
  File "/openedx/venv/lib/python3.8/site-packages/openassessment/fileupload/backends/filesystem.py", line 42, in get_upload_url
    make_upload_url_available(self._get_key_name(key), self.UPLOAD_URL_TIMEOUT)
  File "/openedx/venv/lib/python3.8/site-packages/openassessment/fileupload/backends/filesystem.py", line 93, in make_upload_url_available
    get_cache().set(
  File "/openedx/venv/lib/python3.8/site-packages/openassessment/fileupload/backends/filesystem.py", line 82, in get_cache
    return django.core.cache.caches[cache_name]
  File "/openedx/venv/lib/python3.8/site-packages/django/utils/connection.py", line 61, in __getitem__
    raise self.exception_class(f"The connection '{alias}' doesn't exist.")
django.core.cache.backends.base.InvalidCacheBackendError: The connection 'ora2-storage' doesn't exist.
2023-10-01 14:30:17,920 ERROR 26 [django.request] [user 4] [ip 188.210.145.80] log.py:224 - Internal Server Error: /courses/course-v1:edX+DemoX+Demo_Course/xblock/block-v1:edX+DemoX+Demo_Course+type@openassessment+block@9aad69c276a945a39e11cf3bcb5958aa/handler/upload_url
Traceback (most recent call last):
  File "/openedx/venv/lib/python3.8/site-packages/django/utils/connection.py", line 58, in __getitem__
    return getattr(self._connections, alias)
  File "/openedx/venv/lib/python3.8/site-packages/asgiref/local.py", line 105, in __getattr__
    raise AttributeError(f"{self!r} object has no attribute {key!r}")
AttributeError: <asgiref.local.Local object at 0x7fabdb9e1160> object has no attribute 'ora2-storage'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/openedx/venv/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/openedx/venv/lib/python3.8/site-packages/django/views/decorators/clickjacking.py", line 50, in wrapped_view
    resp = view_func(*args, **kwargs)
  File "/openedx/edx-platform/./lms/djangoapps/courseware/block_render.py", line 865, in handle_xblock_callback
    return _invoke_xblock_handler(request, course_id, usage_id, handler, suffix, course=course)
  File "/openedx/edx-platform/./lms/djangoapps/courseware/block_render.py", line 1014, in _invoke_xblock_handler
    resp = handler_instance.handle(handler, req, suffix)
  File "/openedx/venv/lib/python3.8/site-packages/xblock/mixins.py", line 84, in handle
    return self.runtime.handle(self, handler_name, request, suffix)
  File "/openedx/edx-platform/xmodule/x_module.py", line 1033, in handle
    return super().handle(block, handler_name, request, suffix=suffix)
  File "/openedx/venv/lib/python3.8/site-packages/xblock/runtime.py", line 1081, in handle
    results = handler(request, suffix)
  File "/openedx/venv/lib/python3.8/site-packages/xblock/mixins.py", line 63, in wrapper
    response = func(self, request_json, suffix)
  File "/openedx/venv/lib/python3.8/site-packages/openassessment/xblock/submission_mixin.py", line 504, in upload_url
    url = file_upload_api.get_upload_url(key, content_type)
  File "/openedx/venv/lib/python3.8/site-packages/openassessment/fileupload/api.py", line 29, in get_upload_url
    return backends.get_backend().get_upload_url(key, content_type)
  File "/openedx/venv/lib/python3.8/site-packages/openassessment/fileupload/backends/filesystem.py", line 42, in get_upload_url
    make_upload_url_available(self._get_key_name(key), self.UPLOAD_URL_TIMEOUT)
  File "/openedx/venv/lib/python3.8/site-packages/openassessment/fileupload/backends/filesystem.py", line 93, in make_upload_url_available
    get_cache().set(
  File "/openedx/venv/lib/python3.8/site-packages/openassessment/fileupload/backends/filesystem.py", line 82, in get_cache
    return django.core.cache.caches[cache_name]
  File "/openedx/venv/lib/python3.8/site-packages/django/utils/connection.py", line 61, in __getitem__
    raise self.exception_class(f"The connection '{alias}' doesn't exist.")
django.core.cache.backends.base.InvalidCacheBackendError: The connection 'ora2-storage' doesn't exist.

I’m getting this error in a clean install, no customizations, no extra configs, etc. This feature worked fine in olive 4 by default.

Thanks for the report. I was able to reproduce the problem and can thus confirm it’s an actual bug. It is now tracked in this GitHub issue: ORA2 file upload triggers "InvalidCacheBackendError: The connection 'ora2-storage' doesn't exist" exceptions · Issue #907 · overhangio/tutor · GitHub

Thanks a lot for the followup and creating the github issue. Do you know how difficult this issue is and so how long this will take to get solved? Actually we are in the middle of something and need to fix this ASAP or downgrade to Olive :)))

Should be easy enough. Here’s the PR: fix: file upload in open response assessments (ora2) by regisb · Pull Request #908 · overhangio/tutor · GitHub

This is fantastic! Can’t thank you enough in words!
Just a little issue :)) It’s fixed on LMS and is working fine but the error still exists in studio.

Right. Would you like to open a PR to fix this issue?

Okay. But this is my first PR in tutor, so I’ll try to follow your steps. First I created the issue. Then I got a branch named FatemeKhodayari/fix-ora2-uploads-in-cms from v16.1.2 tag. Is it OK or should I get the branch from master?

Then I copied the CACHES["ora2-storage"] from common_lms.py to common_cms.py. Is it the right place, or is it better to add this settings to common_all.py and remove them from common_lms.py and common_cms.py? Or maybe I should set different KEY_PREFIX for each of them?

I also checked common_cms.py in v15.3.7 but found no ORA2 related settings there. After checking ORA2 file upload from studio, I can now confirm that it fails in studio even in Olive and only the LMS side was fine even in the previous versions.

I had the same problem so this is great, thank you very much. However, after creating a plugin to include the fix (ora2-storage in lms-common), I have the following problem when running createcachetable:

  File "/openedx/venv/lib/python3.8/site-packages/storages/utils.py", line 84, in check_location
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: S3BotoStorage.location cannot begin with a leading slash. Found '/openedx/media/'. Use 'openedx/media/' instead.

Should I modify this as well?

# Set uploaded media file path
MEDIA_ROOT = "/openedx/media/"

EDIT:

Installing tutor minio plugin fixed this problem: GitHub - overhangio/tutor-minio: This is a plugin for Tutor that provides S3-like object storage for Open edX platforms.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.