Skip to content

fix: parse global_keyprefix setting when available

Keith Grootboom requested to merge keith/fix-redis-prefix into main

Description

Fixes the parsing of the global_keyprefix setting.

When running this on an appserver that's configured to use Celery's global_keyprefix setting for Redis, it will fail if an ACL is loaded, because the prefix isn't considered.

Testing instructions

I've provisioned an appserver https://manage.opencraft.com/instance/36800/edx-appserver/24664/.

To test log onto new relic and go to the events page. On that page you will see the most recent events. When an event is sent it will display here with a delay about 10 seconds or so.

Part 0: Reproduce the error

  • SSH into the Appserver
  • Install the main branch of this library (make sure the edxapp virtual environment is activated):
    • pip uninstall monitoring-extensions
    • pip install git+https://gitlab.com/opencraft/dev/monitoring-extensions.git@main#egg=monitoring_extensions
  • Run the management command python manage.py lms send_monitoring_events.
  • There will be a permission error.
  • Install the version from this PR:
    • pip uninstall monitoring-extensions
    • pip install git+https://gitlab.com/opencraft/dev/monitoring-extensions.git@keith/fix-redis-prefix#egg=monitoring_extensions

Part 1: Confirm the event sends

  • After installing the fixed version run the python manage.py lms send_monitoring_events command again.
  • It should run without errors and the event will appear in New Relic.

Part 2: Confirm the totals are updated

  • Stop the workers on the server with /edx/bin/supervisorctl stop edxapp_worker:*
  • Run the following code in a python shell on the server. It will create 30 events that will not be processed because the workers are stopped.
    import datetime
    from openedx.core.djangoapps.heartbeat.tasks import sample_task
    expires = datetime.datetime.now() + datetime.timedelta(seconds=65)
    for z in range(30):
       sample_task.apply_async(expires=expires)
  • Run the management command again: python manage.py lms send_monitoring_events
  • You should see a new event where the total tasks == 30
Edited by Keith Grootboom

Merge request reports