This repository has been archived by the owner on Aug 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAL-2031] Add Redis support for Ocim provisioned instances (#822)
Add support for provisioning a redis acl for use by instances as an alternative to rabbitmq. Co-authored-by: Samuel Walladge <[email protected]>
- Loading branch information
1 parent
7f4e61c
commit e803858
Showing
24 changed files
with
661 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ DEFAULT_LOAD_BALANCING_SERVER='[email protected]' | |
LOAD_BALANCER_FRAGMENT_NAME_PREFIX='opencraft-' | ||
DEFAULT_RABBITMQ_API_URL='https://admin:[email protected]:15671' | ||
DEFAULT_INSTANCE_RABBITMQ_URL='amqps://rabbitmq.example.com:5671' | ||
DEFAULT_INSTANCE_REDIS_URL='rediss://admin:[email protected]:6397/0' | ||
CONSUL_ENABLED=false | ||
CONSUL_SERVERS=haproxy-integration.net.opencraft.hosting | ||
DISABLE_LOAD_BALANCER_CONFIGURATION=false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ DEFAULT_LOAD_BALANCING_SERVER='[email protected]' | |
LOAD_BALANCER_FRAGMENT_NAME_PREFIX='opencraft-' | ||
DEFAULT_RABBITMQ_API_URL='https://admin:[email protected]:15671' | ||
DEFAULT_INSTANCE_RABBITMQ_URL='amqps://rabbitmq.example.com:5671' | ||
DEFAULT_INSTANCE_REDIS_URL='rediss://admin:[email protected]:6397/0' | ||
CONSUL_ENABLED=false | ||
CONSUL_SERVERS=haproxy-integration.net.opencraft.hosting | ||
DISABLE_LOAD_BALANCER_CONFIGURATION=false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,6 +210,12 @@ Required settings: | |
* `DEFAULT_INSTANCE_RABBITMQ_URL`: The RabbitMQ AMQPS URI to be used by instances. E.g., | ||
`amqps://rabbitmq.example.com:5671` | ||
|
||
### Redis settings | ||
* `DEFAULT_INSTANCE_REDIS_URL` The Redis URI (including the protocol, port, db, and basic auth) | ||
to be used by instances. E.g., `rediss://admin:[email protected]:6397/0`. | ||
Similarly to `DEFAULT_RABBITMQ_API_URL` this setting is saved in the database for new instances | ||
using `RedisServerManager._create_default`, where the setting is not explicity overridden. | ||
|
||
### DNS settings | ||
|
||
* `DEFAULT_INSTANCE_BASE_DOMAIN`: Instances are created as subdomains of this domain, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
instance/migrations/0142_add_cache_db_to_openedxinstance.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 2.2.24 on 2021-08-13 08:24 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('instance', '0141_features_to_features_extras'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='openedxinstance', | ||
name='cache_db', | ||
field=models.CharField(choices=[('redis', 'redis'), ('rabbit_mq', 'rabbit_mq')], default='rabbit_mq', max_length=9), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Generated by Django 2.2.24 on 2021-08-13 08:53 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django_extensions.db.fields | ||
import instance.models.mixins.redis | ||
import instance.models.utils | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('instance', '0142_add_cache_db_to_openedxinstance'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='RedisServer', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')), | ||
('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')), | ||
('name', models.CharField(max_length=250)), | ||
('description', models.CharField(blank=True, max_length=250)), | ||
('admin_username', models.CharField(max_length=64)), | ||
('admin_password', models.CharField(max_length=128)), | ||
('instance_host', models.CharField(max_length=128)), | ||
('instance_port', models.PositiveIntegerField(default=5671)), | ||
('instance_db', models.PositiveIntegerField(default=0)), | ||
('use_ssl_connections', models.BooleanField(default=True)), | ||
('accepts_new_clients', models.BooleanField(default=False)), | ||
], | ||
options={ | ||
'verbose_name': 'Redis Server', | ||
}, | ||
bases=(instance.models.utils.ValidateModelMixin, models.Model), | ||
), | ||
migrations.AddField( | ||
model_name='openedxinstance', | ||
name='redis_password', | ||
field=models.CharField(max_length=64, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='openedxinstance', | ||
name='redis_provisioned', | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name='openedxinstance', | ||
name='redis_username', | ||
field=models.CharField(max_length=32, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='openedxinstance', | ||
name='redis_server', | ||
field=models.ForeignKey(blank=True, default=instance.models.mixins.redis.select_random_redis_server, null=True, on_delete=django.db.models.deletion.PROTECT, to='instance.RedisServer'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Generated by Django 2.2.24 on 2021-08-13 08:53 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django_extensions.db.fields | ||
import instance.models.mixins.redis | ||
import instance.models.utils | ||
|
||
|
||
def generate_credentials(apps, schema_editor): | ||
Model = apps.get_model('instance', 'OpenEdXInstance') | ||
for row in Model.objects.all(): | ||
row.redis_username = instance.models.mixins.redis.random_username() | ||
row.redis_password = instance.models.mixins.redis.random_password() | ||
row.save(update_fields=['redis_username', 'redis_password']) | ||
|
||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('instance', '0143_add_redis_server'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(generate_credentials, reverse_code=migrations.RunPython.noop), | ||
migrations.AlterField( | ||
model_name='openedxinstance', | ||
name='redis_password', | ||
field=models.CharField(default=instance.models.mixins.redis.random_password, max_length=64), | ||
), | ||
migrations.AlterField( | ||
model_name='openedxinstance', | ||
name='redis_username', | ||
field=models.CharField(default=instance.models.mixins.redis.random_username, max_length=32, unique=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.