diff --git a/instance/models/mixins/openedx_storage.py b/instance/models/mixins/openedx_storage.py index 2f98375fe..2e25d3da6 100644 --- a/instance/models/mixins/openedx_storage.py +++ b/instance/models/mixins/openedx_storage.py @@ -57,11 +57,12 @@ def swift_container_names(self): def get_storage_settings(self): """ Get configuration_storage_settings to pass to a new AppServer - - Only needed when not using ephemeral databases """ if self.use_ephemeral_databases: - return '' + # Workaround for broken CMS course export/import + # caused by https://github.com/edx/edx-platform/pull/14552 + template = loader.get_template('instance/ansible/ephemeral.yml') + return template.render() new_settings = '' if self.s3_access_key and self.s3_secret_access_key and self.s3_bucket_name: diff --git a/instance/templates/instance/ansible/ephemeral.yml b/instance/templates/instance/ansible/ephemeral.yml new file mode 100644 index 000000000..9ae885c8d --- /dev/null +++ b/instance/templates/instance/ansible/ephemeral.yml @@ -0,0 +1 @@ +EDXAPP_IMPORT_EXPORT_BUCKET: "" diff --git a/instance/tests/models/test_openedx_instance.py b/instance/tests/models/test_openedx_instance.py index f5416b042..0fea7e22e 100644 --- a/instance/tests/models/test_openedx_instance.py +++ b/instance/tests/models/test_openedx_instance.py @@ -242,7 +242,8 @@ def test_spawn_appserver(self, mocks, mock_provision): getattr(appserver, field_name), ) self.assertEqual(appserver.configuration_database_settings, "") - self.assertEqual(appserver.configuration_storage_settings, "") + ephemeral_settings = 'EDXAPP_IMPORT_EXPORT_BUCKET: ""\n' + self.assertEqual(appserver.configuration_storage_settings, ephemeral_settings) configuration_vars = yaml.load(appserver.configuration_settings) self.assertEqual(configuration_vars['COMMON_HOSTNAME'], instance.domain) self.assertEqual(configuration_vars['EDXAPP_PLATFORM_NAME'], instance.name) diff --git a/instance/tests/models/test_openedx_storage_mixins.py b/instance/tests/models/test_openedx_storage_mixins.py index e354bc1e9..860fa1b47 100644 --- a/instance/tests/models/test_openedx_storage_mixins.py +++ b/instance/tests/models/test_openedx_storage_mixins.py @@ -85,7 +85,19 @@ def test_ansible_s3_settings_ephemeral(self): s3_bucket_name='test-s3-bucket-name', use_ephemeral_databases=True, ) - self.assertEqual(instance.get_storage_settings(), '') + ephemeral_settings = 'EDXAPP_IMPORT_EXPORT_BUCKET: ""\n' + self.assertEqual(instance.get_storage_settings(), ephemeral_settings) + + def test_import_export_bucket_setting_ephemeral(self): + """ + Test that get_storage_settings() sets EDXAPP_IMPORT_EXPORT_BUCKET to an empty string + when in ephemeral mode + """ + instance = OpenEdXInstanceFactory( + use_ephemeral_databases=True, + ) + ephemeral_settings = 'EDXAPP_IMPORT_EXPORT_BUCKET: ""\n' + self.assertEqual(instance.get_storage_settings(), ephemeral_settings) class SwiftContainerInstanceTestCase(TestCase):