Skip to content

[BD-14] Install the blockstore app into edx-platform, behind a waffle switch#29779

Merged
bszabo merged 6 commits intoopenedx:masterfrom
open-craft:jill/TNL-8746
Apr 21, 2022
Merged

[BD-14] Install the blockstore app into edx-platform, behind a waffle switch#29779
bszabo merged 6 commits intoopenedx:masterfrom
open-craft:jill/TNL-8746

Conversation

@pomegranited
Copy link
Contributor

@pomegranited pomegranited commented Jan 18, 2022

Description

Installs blockstore as an app inside of edx-platform.

  • Provides a waffle switch (blockstore.use_blockstore_app_api) to toggle between using the installed blockstore app's Python API directly, instead of the external blockstore IDA service's REST API (default), so that the app can be tested and its usage rolled back without having to deploy any code changes.
  • Provides a database router which will use the blockstore IDA's database when configured (supports TNL-8745).
  • Provides django storage configuration setting for blockstore bundle asset files.
  • Also fixes a bug introduced by [BD-13] Deprecate ModuleSystem.render_template (fixed) #29354 and removes the template workaround added by [LX-2365] allows XBlock API users to optionally use LabXchange block types #29517 (see Author Notes & Concerns on that PR).

This change should not impact the edX user experience.

Supporting information

ADR: Blockstore Deployment as an App, Not Service

TNL-8746, subtask of TNL-8351

OpenCraft internal ticket: FAL-2800

Depends on openedx-unsupported/blockstore#149 <-- this has been merged and tagged for use here

Testing instructions

Sandbox

Sandbox was provisioned with the Settings and Manual steps noted below.

Devstack setup

  1. Run blockstore IDA service (see README).

  2. Add user/password to the blockstore DB from the mysql57-shell:

    # mysql -u root
    GRANT ALL ON `blockstore_db`.* TO 'blockstore001'@'%' IDENTIFIED BY 'password';
  3. Checkout the branch from [BD-14] Updates Blockstore Python API [TNL-8746] [FAL-2702] openedx-unsupported/blockstore#149 into ${DEVSTACK_WORKSPACE}/src/blockstore, and install in the LMS and Studio shells:

    # make lms-shell and studio-shell
    pip install -e /edx/src/blockstore
  4. To share to the Blockstore database and file storage between edxapp and the IDA, add the following to lms/envs/private.py and
    cms/envs/private.py:

    BLOCKSTORE_API_URL = "http://edx.devstack.blockstore:18250/api/v1/"
    BLOCKSTORE_API_AUTH_TOKEN = 'edxapp-insecure-devstack-key'
    LX_PATHWAY_PLUGIN_AUTHORIZED_USERNAMES = ['staff']  # added by LX provisioning
    
    MEDIA_ROOT = '/edx/src/blockstore/blockstore/media'
    MEDIA_URL = '/media/'
    BUNDLE_ASSET_STORAGE_SETTINGS = dict(
        STORAGE_CLASS='django.core.files.storage.FileSystemStorage',
        STORAGE_KWARGS=dict(
            location=MEDIA_ROOT,
            base_url=MEDIA_URL,
        ),
    )
    def add_blockstore_service_db():
        from .devstack import DATABASES
        DATABASES['blockstore'] = dict(
            CONN_MAX_AGE=0,
            ENGINE='django.db.backends.mysql',
            HOST='edx.devstack.mysql57',
            NAME='blockstore_db',
            PASSWORD='password',
            PORT='3306',
            USER='blockstore001',
        )
        return DATABASES
    
    DATABASES = add_blockstore_service_db()
  5. Run content-library-authoring MFE (see README), OR provision the LabXchange devstack.

Testing instructions

These tests should work on either the sandbox or your devstack.

Test blockstore as service (default, no switch created):

  • Create some new blockstore content.
    If you're using content libraries, create a new library with some blocks in it.
    (If you're using LabXchange, the devstack provisioning did this for you.)
  • Check that you can view the created content OK.
  • Visit Django Admin > Blockstore Bundles, and ensure you can see your collections and bundles.

Test blockstore as app (enable switch):

  • Create and enable the waffle switch: blockstore.use_blockstore_app_api
  • Clear the blockstore cache.
    In devstack, you can restart LMS+Studio; in the sandbox, you can run blockstore_cache.cache.clear().
  • Stop the blockstore service, or watch the blockstore service logs to ensure that it's not being used for the steps below.
  • Ensure that can still see the content created in above steps.
  • Ensure that you can create new content, and edit existing OLX.
  • Visit Django Admin > Blockstore Bundles, and ensure you can see your new and old collections and bundles.

Test blockstore as service (disable switch):

  • Disable the waffle switch.
  • Clear the blockstore cache, as above.
  • Start the blockstore service, and watch the logs to ensure that requests start coming in for the steps below.
  • Ensure that you can still see content and changes made above.
  • Ensure that you can create new content, and edit existing OLX.
  • Visit Django Admin > Blockstore Bundles, and ensure you can see your new and old collections and bundles.

Integration tests

Integration tests for the blockstore service aren't run as part of the CI, but can be run manually in the devstack, (see blockstore README):

  1. In a blockstore-shell run make testserver.
  2. In a studio-shell, run:
    EDXAPP_RUN_BLOCKSTORE_TESTS=1 python -Wd -m pytest --ds=cms.envs.test \
    openedx/core/lib/blockstore_api/ openedx/core/djangolib/tests/test_blockstore_cache.py openedx/core/djangoapps/content_libraries/tests/
    EDXAPP_RUN_BLOCKSTORE_TESTS=1 python -Wd -m pytest --ds=lms.envs.test \
    openedx/core/lib/blockstore_api/ openedx/core/djangolib/tests/test_blockstore_cache.py openedx/core/djangoapps/content_libraries/tests/

Deadline

None

Other information

Author Notes

  1. Switching between using the blockstore standalone service and the blockstore installed app causes an issue in the devstack with the blockstore cache for the bundle file URLs.
    This should not be an issue in production, as these URLs are absolute S3 URLs, not routed through the app or service.

Deployment configuration changes

Anyone who is running blockstore as a service and wants to preserve the service's content when switching to the blockstore app will need to:

  1. Add a blockstore stanza to edxapp_databases ansible configuration.
  2. Add settings to edxapp for the blockstore file storage
    BUNDLE_ASSET_URL_STORAGE_KEY:  ...
    BUNDLE_ASSET_URL_STORAGE_SECRET: ...
    BUNDLE_ASSET_STORAGE_SETTINGS: 
      STORAGE_CLASS: ... # if different from DEFAULT_FILE_STORAGE
      STORAGE_KWARGS:
         location: ... # within bucket path
         bucket_name: ... # bucket name
         # + anything else that differs from the global storage settings
  3. When switching between the blockstore app and blockstore IDA service, leave the blockstore service running to handle cached copies of the bundle version file URLs.
    Alternatively, these caches can be cleared when the service URLs are no longer desired.

Settings

Ansible settings to deploy the blockstore service + MFEs
SANDBOX_ENABLE_BLOCKSTORE: true
BLOCKSTORE_DATABASE_HOST: "{{ DISCOVERY_MYSQL }}"
BLOCKSTORE_DATABASE_PASSWORD: "{{ DISCOVERY_MYSQL_PASSWORD }}"
BLOCKSTORE_DATABASE_USER: "{{ DISCOVERY_MYSQL_USER }}"
BLOCKSTORE_DEFAULT_DB_NAME: "{{ DISCOVERY_DEFAULT_DB_NAME }}"
BLOCKSTORE_GIT_PATH: "open-craft"
BLOCKSTORE_VERSION:  "jill/symbolist/blockstore-as-app"
BLOCKSTORE_NGINX_HOSTNAME: discovery.*
BLOCKSTORE_NGINX_PORT: 80
BLOCKSTORE_SSL_NGINX_PORT: 443
BLOCKSTORE_SECRET_KEY:  "{{ DISCOVERY_SECRET_KEY }}"
BLOCKSTORE_SERVICE_CONFIG_OVERRIDES:
   # Only need to set these if you're using different access keys for generating signed URLs
   #BUNDLE_ASSET_URL_STORAGE_KEY:  "{{ EDXAPP_AWS_ACCESS_KEY_ID  }}"
   #BUNDLE_ASSET_URL_STORAGE_SECRET:  "{{ EDXAPP_AWS_SECRET_ACCESS_KEY }}"
   AWS_ACCESS_KEY_ID: "{{ EDXAPP_AWS_ACCESS_KEY_ID  }}"
   AWS_SECRET_ACCESS_KEY: "{{ EDXAPP_AWS_SECRET_ACCESS_KEY }}"
   AWS_STORAGE_BUCKET_NAME: "{{ EDXAPP_AWS_STORAGE_BUCKET_NAME  }}"
   AWS_LOCATION: "blockstore/"
   DEFAULT_FILE_STORAGE: storages.backends.s3boto3.S3Boto3Storage

EDXAPP_BLOCKSTORE_API_URL: http://localhost:8250/api/v1/
# Add a blockstore database to edxapp's databases list, so the blockstore app can share the blockstore service's database.
edxapp_databases:
# edxapp's edxapp-migrate scripts and the edxapp_migrate play
# will ensure that any DB not named read_replica will be migrated
# for both the lms and cms.
  read_replica:
    ENGINE: 'django.db.backends.mysql'
    NAME: "{{ EDXAPP_MYSQL_REPLICA_DB_NAME }}"
    USER: "{{ EDXAPP_MYSQL_REPLICA_USER }}"
    PASSWORD: "{{ EDXAPP_MYSQL_REPLICA_PASSWORD }}"
    HOST: "{{ EDXAPP_MYSQL_REPLICA_HOST }}"
    PORT: "{{ EDXAPP_MYSQL_REPLICA_PORT }}"
    CONN_MAX_AGE: "{{ EDXAPP_MYSQL_CONN_MAX_AGE }}"
    OPTIONS: "{{ EDXAPP_MYSQL_REPLICA_OPTIONS }}"
  default:
    ENGINE: 'django.db.backends.mysql'
    NAME: "{{ EDXAPP_MYSQL_DB_NAME }}"
    USER: "{{ EDXAPP_MYSQL_USER }}"
    PASSWORD: "{{ EDXAPP_MYSQL_PASSWORD }}"
    HOST: "{{ EDXAPP_MYSQL_HOST }}"
    PORT: "{{ EDXAPP_MYSQL_PORT }}"
    ATOMIC_REQUESTS: "{{ EDXAPP_MYSQL_ATOMIC_REQUESTS }}"
    CONN_MAX_AGE: "{{ EDXAPP_MYSQL_CONN_MAX_AGE }}"
    OPTIONS: "{{ EDXAPP_MYSQL_OPTIONS }}"
  student_module_history:
    ENGINE: 'django.db.backends.mysql'
    NAME: "{{ EDXAPP_MYSQL_CSMH_DB_NAME }}"
    USER: "{{ EDXAPP_MYSQL_CSMH_USER }}"
    PASSWORD: "{{ EDXAPP_MYSQL_CSMH_PASSWORD }}"
    HOST: "{{ EDXAPP_MYSQL_CSMH_HOST }}"
    PORT: "{{ EDXAPP_MYSQL_CSMH_PORT }}"
    CONN_MAX_AGE: "{{ EDXAPP_MYSQL_CONN_MAX_AGE }}"
    OPTIONS: "{{ EDXAPP_MYSQL_CSMH_OPTIONS }}"
  blockstore:
    ENGINE: 'django.db.backends.mysql'
    NAME: "{{ BLOCKSTORE_DEFAULT_DB_NAME }}"
    USER: "{{ BLOCKSTORE_DATABASE_USER }}"
    PASSWORD: "{{ BLOCKSTORE_DATABASE_PASSWORD }}"
    HOST: "{{ BLOCKSTORE_DATABASE_HOST }}"
    PORT: "{{ BLOCKSTORE_DATABASE_PORT }}"
    CONN_MAX_AGE: "{{ BLOCKSTORE_DATABASE_CONN_MAX_AGE }}"
    OPTIONS: "{{ EDXAPP_MYSQL_OPTIONS  }}"

## Blockstore and library authoring
EDXAPP_CMS_ENV_EXTRA:
  LIBRARY_AUTHORING_MICROFRONTEND_URL : 'https://library-authoring.{{ EDXAPP_LMS_BASE }}/'
  # Only need to set these if you're using different access keys for generating signed URLs
  #BUNDLE_ASSET_URL_STORAGE_KEY:  "{{ EDXAPP_AWS_ACCESS_KEY_ID  }}"
  #BUNDLE_ASSET_URL_STORAGE_SECRET:  "{{ EDXAPP_AWS_SECRET_ACCESS_KEY }}"
  BUNDLE_ASSET_STORAGE_SETTINGS: 
    STORAGE_CLASS: "{{ EDXAPP_DEFAULT_FILE_STORAGE }}"
    STORAGE_KWARGS:
        location: "blockstore/"
        bucket_name: "{{ EDXAPP_AWS_STORAGE_BUCKET_NAME  }}"
        access_key: "{{ EDXAPP_AWS_ACCESS_KEY_ID  }}"
        secret_key: "{{ EDXAPP_AWS_SECRET_ACCESS_KEY }}"
        location: "blockstore/"
        object_parameters:
            CacheControl: "max-age=60"
        querystring_auth: true
        querystring_expire: 60
        custom_domain: !!null
  BLOCKSTORE_API_AUTH_TOKEN: "ky8yxqegTh"
  BLOCKSTORE_BUNDLE_CACHE_TIMEOUT: 60
  # HACK -- i was unable to get requests from the library authoring MFE to be accepted by Studio.
  CORS_ORIGIN_ALLOW_ALL: true

EDXAPP_LMS_ENV_EXTRA:
  # Only need to set these if you're using different access keys for generating signed URLs
  #BUNDLE_ASSET_URL_STORAGE_KEY:  "{{ EDXAPP_AWS_ACCESS_KEY_ID  }}"
  #BUNDLE_ASSET_URL_STORAGE_SECRET:  "{{ EDXAPP_AWS_SECRET_ACCESS_KEY }}"
  BUNDLE_ASSET_STORAGE_SETTINGS: 
    STORAGE_CLASS: "{{ EDXAPP_DEFAULT_FILE_STORAGE }}"
    STORAGE_KWARGS:
        location: "blockstore/"
        bucket_name: "{{ EDXAPP_AWS_STORAGE_BUCKET_NAME  }}"
        access_key: "{{ EDXAPP_AWS_ACCESS_KEY_ID  }}"
        secret_key: "{{ EDXAPP_AWS_SECRET_ACCESS_KEY }}"
        location: "blockstore/"
        object_parameters:
            CacheControl: "max-age=60"
        querystring_auth: true
        querystring_expire: 60
        custom_domain: !!null
  BLOCKSTORE_API_AUTH_TOKEN: "ky8yxqegTh"
  BLOCKSTORE_BUNDLE_CACHE_TIMEOUT: 60
  AUTHN_MICROFRONTEND_URL: "https://authn.{{ EDXAPP_LMS_BASE }}"

## MFEs
# Deploy MFEs to own subdomain
MFE_DEPLOY_STANDALONE_NGINX: true
MFES:
  - name: profile
    repo: frontend-app-profile
  - name: gradebook
    repo: frontend-app-gradebook
  - name: account
    repo: frontend-app-account
  - name: learning
    repo: frontend-app-learning
  - name: authn
    repo: frontend-app-authn
  - name: library-authoring
    repo: frontend-app-library-authoring
MFE_ENVIRONMENT_EXTRA:
  LMS_BASE_URL:  "https://{{ EDXAPP_LMS_BASE }}"
  STUDIO_BASE_URL: "https://{{ EDXAPP_CMS_BASE }}"
  BLOCKSTORE_COLLECTION_UUID: "11111111-2111-4111-8111-111111111111"
  # does setting this here break all the other MFEs??
  BASE_URL: "https://library-authoring.pr29779.sandbox.opencraft.hosting"
  # FFS really??
  SECURE_ORIGIN_XBLOCK_BOOTSTRAP_HTML_URL: "//d26i2lpnkzmddn.cloudfront.net/xblock-bootstrap-v8.html"

## edxapp Configurations
EDXAPP_SESSION_COOKIE_DOMAIN: ".{{ EDXAPP_LMS_BASE }}"
EDXAPP_CSRF_COOKIE_SECURE: true
EDXAPP_SESSION_COOKIE_SECURE: true
EDXAPP_ENABLE_CORS_HEADERS: true
EDXAPP_ENABLE_CROSS_DOMAIN_CSRF_COOKIE: true
EDXAPP_CROSS_DOMAIN_CSRF_COOKIE_DOMAIN: ".{{ EDXAPP_LMS_BASE }}"
EDXAPP_CROSS_DOMAIN_CSRF_COOKIE_NAME: "cross-domain-cookie-mfe"
EDXAPP_CORS_ORIGIN_WHITELIST:
  - "https://{{ EDXAPP_CMS_BASE }}"
  - "https://profile.{{ EDXAPP_LMS_BASE }}"
  - "https://gradebook.{{ EDXAPP_LMS_BASE }}"
  - "https://accounts.{{ EDXAPP_LMS_BASE }}"
  - "https://learning.{{ EDXAPP_LMS_BASE }}"
  - "https://library-authoring.{{ EDXAPP_LMS_BASE }}"
  - "https://authn.{{ EDXAPP_LMS_BASE }}"
EDXAPP_CSRF_TRUSTED_ORIGINS:
  - "{{ EDXAPP_CMS_BASE }}"
  - "profile.{{ EDXAPP_LMS_BASE }}"
  - "gradebook.{{ EDXAPP_LMS_BASE }}"
  - "accounts.{{ EDXAPP_LMS_BASE }}"
  - "learning.{{ EDXAPP_LMS_BASE }}"
  - "library-authoring.{{ EDXAPP_LMS_BASE }}"
  - "authn.{{ EDXAPP_LMS_BASE }}"
EDXAPP_LOGIN_REDIRECT_WHITELIST:
  - "{{ EDXAPP_CMS_BASE }}"
  - "profile.{{ EDXAPP_LMS_BASE }}"
  - "gradebook.{{ EDXAPP_LMS_BASE }}"
  - "accounts.{{ EDXAPP_LMS_BASE }}"
  - "learning.{{ EDXAPP_LMS_BASE }}"
  - "library-authoring.{{ EDXAPP_LMS_BASE }}"
  - "authn.{{ EDXAPP_LMS_BASE }}"
EDXAPP_SITE_CONFIGURATION:
  - values:
      ENABLE_ORDER_HISTORY_MICROFRONTEND: "{{ SANDBOX_ENABLE_ECOMMERCE }}"
## MFE Links
EDXAPP_LMS_WRITABLE_GRADEBOOK_URL: 'https://gradebook.{{ EDXAPP_LMS_BASE }}/'
EDXAPP_LEARNING_MICROFRONTEND_URL: 'https://learning.{{ EDXAPP_LMS_BASE }}/'
EDXAPP_PROFILE_MICROFRONTEND_URL: 'https://profile.{{ EDXAPP_LMS_BASE }}/u/'
EDXAPP_ACCOUNT_MICROFRONTEND_URL: 'https://accounts.{{ EDXAPP_LMS_BASE }}/'
EDXAPP_FEATURES_EXTRA:
  ENABLE_CONTENT_LIBRARIES: true
  ENABLE_LIBRARY_AUTHORING_MICROFRONTEND: true
Manual steps run to provision the sandbox
  1. Create auth token in Blockstore, with value matching ansible BLOCKSTORE_API_AUTH_TOKEN (ref blockstore/README):

    # As the blockstore user, with the blockstore envs and venv enabled, run ./manage.py shell
    from django.contrib.auth import get_user_model
    from rest_framework.authtoken.models import Token
    edxapp, _ = get_user_model().objects.get_or_create(username='edxapp', is_active=True)
    Token.objects.create(key='ky8yxqegTh', user=edxapp)
  2. Create a "Collection" that new content libraries / xblocks can be created within. The collection UUID must match the BLOCKSTORE_COLLECTION_UUID configured on the MFE:

    # Create from the blockstore shell or the LMS shell; doesn't matter where, because they share the same database now!
    from blockstore.apps.bundles.models import Collection
    Collection.objects.get_or_create(title='Library Content Collection', uuid='11111111-2111-4111-8111-111111111111')
  3. Create an an Organization in the LMS:

    # Run /edx/bin/edxapp-shell-lms
    from organizations.models import Organization
    Organization.objects.get_or_create(short_name='DeveloperInc', defaults={'name': 'DeveloperInc', 'active': True})
  4. In Studio Django Admin, create an enable a waffle flag named studio.library_authoring_mfe.

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Jan 18, 2022
@openedx-webhooks
Copy link

openedx-webhooks commented Jan 18, 2022

Thanks for the pull request, @pomegranited! I've created BLENDED-1067 to keep track of it in Jira. More details are on the BD-14 project page.

When this pull request is ready, tag your edX technical lead.

@pomegranited pomegranited changed the title [TNL-8746] Install the blockstore app into edx-platform, behind a waffle switch [BD-14] Install the blockstore app into edx-platform, behind a waffle switch Jan 18, 2022
@openedx-webhooks openedx-webhooks added blended PR is managed through 2U's blended developmnt program and removed open-source-contribution PR author is not from Axim or 2U labels Jan 18, 2022
@pomegranited pomegranited force-pushed the jill/TNL-8746 branch 2 times, most recently from 744179f to e1339d4 Compare January 25, 2022 06:59
@pomegranited pomegranited marked this pull request as ready for review January 25, 2022 07:12
@openedx-webhooks openedx-webhooks added needs triage and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Jan 25, 2022
@pomegranited pomegranited marked this pull request as draft January 25, 2022 11:42
@pomegranited pomegranited marked this pull request as ready for review January 25, 2022 12:26
@pomegranited pomegranited force-pushed the jill/TNL-8746 branch 2 times, most recently from e378239 to a7e0f10 Compare January 27, 2022 09:03
@pomegranited pomegranited force-pushed the jill/TNL-8746 branch 3 times, most recently from af9eaad to b100781 Compare February 8, 2022 06:57
@pdpinch
Copy link
Contributor

pdpinch commented Feb 8, 2022

Hi @pomegranited thanks for working on this. @blarghmatey and I would really like to use this for our (first) deployment of Libraries v2 at MIT, so we're trying out your branch.

Is there a way to verify that app is running successfully? Do we need the Library MFE just to test it?

@pomegranited
Copy link
Contributor Author

Hi @pdpinch ! That would be fantastic if you and @blarghmatey could help test this change.

Is there a way to verify that app is running successfully?

If the app is installed and running, you'll see Blockstore in your Django Admin, with Collections and Bundles (though they'll be empty).

Do we need the Library MFE just to test it?

You'll need the Library Authoring MFE to add collections and bundles (aka Libraries), and so yes, you'll need that MFE running to fully test this branch.

You'll also need to make sure you have the blockstore app configured, see:

@blarghmatey
Copy link
Contributor

Thanks for that input. For the MFE it's unclear beyond the feature flag how we can configure the expected domain or path to load for pointing at the deployed assets. Is that something that is managed via a Django setting or is it a value in a waffle flag or... ?

We are deploying this greenfield with no prior usage of the Blockstore IDA so it seems that we can just leave the storage and database settings to the default to have it use the S3 and database connection details from edx-platform. Is that correct?

@pomegranited
Copy link
Contributor Author

pomegranited commented Feb 9, 2022

@blarghmatey

For the MFE it's unclear beyond the feature flag how we can configure the expected domain or path to load for pointing at the deployed assets. Is that something that is managed via a Django setting or is it a value in a waffle flag or... ?

I'm also working out the MFE deployment requirements for library-authoring. Most of the other MFEs will run successfully under a single subdomain (or docker container/port), but this MFE seems to need its own, so I'm trying this on my sandbox deployment now. See the "Ansible settings to deploy the blockstore service + MFEs" yaml underneath "MFE" for what I'm attempting with the full list of MFEs.

You'll also need to set a waffle flag: studio.library_authoring_mfe, see library-authoring README#devstack-installation, and the waffle switch added by this PR: blockstore.use_blockstore_app_api

We are deploying this greenfield with no prior usage of the Blockstore IDA so it seems that we can just leave the storage and database settings to the default to have it use the S3 and database connection details from edx-platform. Is that correct?

You can skip the database settings noted above, and everything under BLOCKSTORE_*, but you'll still need to specify the Django Storage settings for the Blockstore app, by setting BUNDLE_ASSET_* under EDXAPP_ENV_EXTRA (or both EDXAPP_LMS_ENV_EXTRA and EDXAPP_CMS_ENV_EXTRA, depending on your setup).

Here's the settings I think you'll need:

## MFEs
# Deploy MFEs to own subdomain
MFE_DEPLOY_STANDALONE_NGINX: true
MFES:
  - name: library-authoring
    repo: frontend-app-library-authoring
MFE_ENVIRONMENT_EXTRA:
  LMS_BASE_URL:  "https://{{ EDXAPP_LMS_BASE }}"
  STUDIO_BASE_URL: "https://{{ EDXAPP_CMS_BASE }}"
  BLOCKSTORE_COLLECTION_UUID: "11111111-2111-4111-8111-111111111111"
  BASE_URL: "https://library-authoring.{{ EDXAPP_LMS_BASE }}"
  # I have no idea why this is necessary for this MFE.
  SECURE_ORIGIN_XBLOCK_BOOTSTRAP_HTML_URL: "//d26i2lpnkzmddn.cloudfront.net/xblock-bootstrap-v8.html"

# edxapp MFE Configurations
EDXAPP_SESSION_COOKIE_DOMAIN: ".{{ EDXAPP_LMS_BASE }}"
EDXAPP_CSRF_COOKIE_SECURE: true
EDXAPP_SESSION_COOKIE_SECURE: true
EDXAPP_ENABLE_CORS_HEADERS: true
EDXAPP_ENABLE_CROSS_DOMAIN_CSRF_COOKIE: true
EDXAPP_CROSS_DOMAIN_CSRF_COOKIE_DOMAIN: ".{{ EDXAPP_LMS_BASE }}"
EDXAPP_CROSS_DOMAIN_CSRF_COOKIE_NAME: "cross-domain-cookie-mfe"
EDXAPP_CORS_ORIGIN_WHITELIST:
  - "https://{{ EDXAPP_CMS_BASE }}"
  - "https://library-authoring.{{ EDXAPP_LMS_BASE }}"  # you have to use this subdomain. I don't know why.
EDXAPP_CSRF_TRUSTED_ORIGINS:
  - "{{ EDXAPP_CMS_BASE }}"
  - "library-authoring.{{ EDXAPP_LMS_BASE }}"
EDXAPP_LOGIN_REDIRECT_WHITELIST:
  - "{{ EDXAPP_CMS_BASE }}"
  - "library-authoring.{{ EDXAPP_LMS_BASE }}"
EDXAPP_FEATURES_EXTRA:
  ENABLE_CONTENT_LIBRARIES: true
  ENABLE_LIBRARY_AUTHORING_MICROFRONTEND: true

## Blockstore and library authoring
EDXAPP_ENV_EXTRA:
  LIBRARY_AUTHORING_MICROFRONTEND_URL : 'https://library-authoring.{{ EDXAPP_LMS_BASE }}/'
  # Only need to set these if you're using different access keys for generating signed URLs
  # See https://github.com/openedx/blockstore/pull/101
  #BUNDLE_ASSET_URL_STORAGE_KEY:  "{{ EDXAPP_AWS_ACCESS_KEY_ID  }}"
  #BUNDLE_ASSET_URL_STORAGE_SECRET:  "{{ EDXAPP_AWS_SECRET_ACCESS_KEY }}"
  BUNDLE_ASSET_STORAGE_SETTINGS: 
    STORAGE_KWARGS:
        location: "blockstore/"
        bucket_name: "{{ EDXAPP_AWS_STORAGE_BUCKET_NAME  }}"
        access_key:  "{{ EDXAPP_AWS_ACCESS_KEY_ID  }}"
        secret_key:  "{{ EDXAPP_AWS_SECRET_ACCESS_KEY }}"
  BLOCKSTORE_API_AUTH_TOKEN: SET-ME-PLEASE
  BLOCKSTORE_BUNDLE_CACHE_TIMEOUT: 60

And you'll need to run the steps in this PR description, described under Settings > Manual steps run to provision the sandbox.

@blarghmatey
Copy link
Contributor

I'm trying to test this on a Maple build of edx-platform. Do you know if that release has code in place to process the waffle flag for the library-authoring MFE? It doesn't seem to be trying to load the route that is specified in the edX configuration for LIBRARY_AUTHORING_MICROFRONTEND_URL.

@pomegranited
Copy link
Contributor Author

Sorry @blarghmatey , I've only ever run Library Authoring on master, so am not sure about what it takes to run on Maple.

@pomegranited
Copy link
Contributor Author

pomegranited commented Feb 10, 2022

FYI @blarghmatey -- I'm still wrestling with my sandbox, but I've made a bunch of updates to the config in my previous post, see the diff for details.

Copy link
Contributor

@symbolist symbolist left a comment

Choose a reason for hiding this comment

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

@pomegranited I did some more testing with creating, editing, and viewing XBlocks and everything seems to be working. I have also tested the waffle flag. There are a few tests that are failing (noted in a comment below).

The only thing that I is left for me to test is switching back and forth between the Python API and the REST API and testing that everything continues to work. Do you have the changes required for it handy? I think we will at least need to:

  1. Configure edxapp to use the blockstore devstack db.
  2. Create a shared volume for the media files

@pomegranited
Copy link
Contributor Author

@symbolist

The only thing that I is left for me to test is switching back and forth between the Python API and the REST API and testing > that everything continues to work. Do you have the changes required for it handy? I think we will at least need to:

  1. Configure edxapp to use the blockstore devstack db.
  2. Create a shared volume for the media files

Yep! Those changes can be made to the lms/envs/private.py and cms/envs/private.py, and are noted in the PR description, under Devstack setup.

…ring MFE

When the XBlock runtime is used in Studio/authoring mode, it needs to
use the template path prefix "lms." in order to locate the block
templates. (In LMS view, no prefix is required.)

Fixes bug introduced by openedx#29354
and removes template workaround added by
openedx#29517 (see Author Notes & Concerns)
Rendering asset URLs requires HTML blocks to be associated with a course key.
This change allows HTML blocks to be associated with libraries and still
render without error.
@bszabo bszabo merged commit d2e82b7 into openedx:master Apr 21, 2022
@openedx-webhooks
Copy link

@pomegranited 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@pomegranited pomegranited deleted the jill/TNL-8746 branch April 21, 2022 13:04
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

pomegranited pushed a commit to open-craft/openedx-platform that referenced this pull request Apr 27, 2022
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
kdmccormick pushed a commit that referenced this pull request May 11, 2022
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
dmitry-viskov pushed a commit to weaveeducation/edx-platform that referenced this pull request May 27, 2022
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
sambapete pushed a commit to EDUlib/edx-platform that referenced this pull request Oct 12, 2022
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
sambapete pushed a commit to EDUlib/edx-platform that referenced this pull request Dec 13, 2022
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
jcohen28 pushed a commit to Medality-Health/edx-platform that referenced this pull request Dec 18, 2022
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
sambapete pushed a commit to EDUlib/edx-platform that referenced this pull request Feb 9, 2023
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
sambapete pushed a commit to EDUlib/edx-platform that referenced this pull request Apr 11, 2023
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
sambapete pushed a commit to EDUlib/edx-platform that referenced this pull request Apr 11, 2023
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
sambapete pushed a commit to EDUlib/edx-platform that referenced this pull request May 22, 2023
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
sambapete pushed a commit to EDUlib/edx-platform that referenced this pull request Jun 14, 2023
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
ataylor05 pushed a commit to Medality-Health/edx-platform that referenced this pull request Jun 16, 2023
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
sambapete pushed a commit to EDUlib/edx-platform that referenced this pull request Aug 9, 2023
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
sambapete pushed a commit to EDUlib/edx-platform that referenced this pull request Oct 11, 2023
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
sambapete pushed a commit to EDUlib/edx-platform that referenced this pull request Oct 13, 2023
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
sambapete pushed a commit to EDUlib/edx-platform that referenced this pull request Nov 17, 2023
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
sambapete pushed a commit to EDUlib/edx-platform that referenced this pull request Dec 11, 2023
[BD-14] Install the blockstore app into edx-platform, behind a waffle switch

(cherry picked from commit d2e82b7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blended PR is managed through 2U's blended developmnt program merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants