Skip to content
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.

[FAL-2031] Add Redis support for Ocim provisioned instances #822

Merged
merged 25 commits into from
Sep 3, 2021

Conversation

gabor-boros
Copy link
Member

@gabor-boros gabor-boros commented Jul 1, 2021

This Pull Request adds Redis cache support to Ocim. The changes won't take effect on already provisioned servers, but new ones or those that explicitly set to use Redis over RabbitMQ. This way we can slowly roll out changes for every server while we are not generating more work when new instances are created.

Dependencies Related PRs:

Screenshots:

Admin site integration of RedisServer

Screenshot 2021-07-01 at 16 10 00

Instance admin configuration

Screenshot 2021-07-01 at 14 49 00

Redis cluster showing the Ocim created user and its ACL

Screenshot 2021-07-01 at 15 35 27

Sandbox URL: Upon request, I can create an ngrok URL for my local Ocim

Merge deadline: None

Testing instructions:

  1. Checkout the changes on Ocim stage
  2. Create a Redis user and ACL for Ocim if no user was created (or use the default user) and double-check the connection to the Redis server
  3. Set the necessary environment variables in the .env file (ie. DEFAULT_INSTANCE_REDIS_URL )
  4. Restart Ocim
  5. Provision a new app server
  6. Login with edX user
  7. Go to instructor/download data tab
  8. Download a grades report (as that uses celery, that would use Redis now)
  9. Validate the instructor task is finished successfully

A note about staging env: The instance creation nowadays is hectic -- it seems for some instances the LB URL registration did not work.

Author notes and concerns:

N/A

Reviewers

@gabor-boros gabor-boros self-assigned this Jul 1, 2021
@samuelallan72
Copy link

@gabor-boros somewhere we will need to set the acl policy for the key prefix for an instance. I'm not sure if it's been done already? I couldn't find it.

@gabor-boros
Copy link
Member Author

@swalladge

We are setting the key prefix based on the Redis username, and creating the ACL using the prefix. When the key prefix exists (we have a Redis username) and an ACL is created for that, the only thing left to do is setting the global_keyprefix in the Redis transport options, which is done here.

@samuelallan72
Copy link

@gabor-boros ah got it, thanks 👍

@gabor-boros gabor-boros marked this pull request as ready for review August 23, 2021 22:10
The current version does not support other usernames than default and
cannot set ACLs.
Add more information about how the setting is used and stored.
In case the instance configuration explicitly states to use redis or the
instance has no prior app servers, let's use redis over rabbit.
Remove the `RedisUser` model and refactor the related provisioning
function where necessary.
In case we provisioned a redis server over rabbit mq, ensure we use
redis server over rabbit mq for the next time as well.
Copy link

@samuelallan72 samuelallan72 left a comment

Choose a reason for hiding this comment

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

@gabor-boros 👍

  • I tested this: tested async tasks on stage appserver
  • I read through the code
  • [NA] I checked for accessibility issues
  • Includes documentation
  • I made sure any change in configuration variables is reflected in the corresponding
    client's configuration-secure repository.

@pomegranited
Copy link
Member

Fantastic work here @gabor-boros and @swalladge !

I'm happy with what's running on stage and the recent fixes, so this is ready to go live :)

Samuel Walladge added 2 commits September 3, 2021 12:38
Remove the heuristics that switches to a redis cache_db automatically for new instances.
We only want instances to provision and use redis if explicitly configured to.
The tests in this file duplicate those in instance/tests/models/test_openedx_theme_mixins.py
Looks like a copy/paste error.
@samuelallan72 samuelallan72 merged commit e803858 into master Sep 3, 2021
@samuelallan72 samuelallan72 deleted the gabor/add-redis-support branch September 3, 2021 05:12
@samuelallan72 samuelallan72 restored the gabor/add-redis-support branch September 3, 2021 05:12
@samuelallan72 samuelallan72 deleted the gabor/add-redis-support branch September 3, 2021 05:12
@samuelallan72 samuelallan72 restored the gabor/add-redis-support branch September 3, 2021 05:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants