fix: programs discovery

In Discovery, programs and courses are always associated to a site and partner.
However, sites differ in development and in production, because their urls are
different. And when we run the `cache_programs` in the LMS, we must be careful
to hit the url that corresponds to the right site in dev and prod. This url is
no longer defined by the COURSE_API_URL setting, or the internal_api_url
attribute. Instead, they are loaded from the corresponding site configuration.
To resolve this mess, we make sure that the right site configurations are
properly defined in dev and local.

It is the responsibility of end users to properly associate courses and
programs to the right site (dev or local) on their running platform...

How to reproduce the issue:

- Run the `create_catalog_integrations` command indicated in the readme.
- Create a program in discovery, and add a few courses to it. Make sure it is associated to the "Open edX" partner, and not "Open edX - dev".
- Run the `cache_programs` command from the readme
- Authenticate and open /dashboard/programs. The program you created should appear.
This commit is contained in:
Régis Behmo 2021-10-07 16:52:11 +02:00 committed by Régis Behmo
parent 552add319f
commit e7bc9eaaa3
5 changed files with 14 additions and 3 deletions

View File

@ -70,13 +70,15 @@ Caching programs
In order to cache programs in the LMS, you will need to manually create a catalog integration. This step should be performed just once::
tutor local run lms ./manage.py lms create_catalog_integrations --enabled \
--internal_api_url=http://discovery:8000/api/v1 \
--internal_api_url="" \
--service_username=lms_catalog_service_user
Then::
tutor local run lms ./manage.py lms cache_programs
This last step should be performed every time you create new or make changes to existing programs.
Debugging
---------

View File

@ -7,4 +7,4 @@ discovery:
networks:
default:
aliases:
- "{{ DISCOVERY_HOST }}"
- "{{ DISCOVERY_HOST }}"

View File

@ -1,2 +1 @@
FEATURES["ENABLE_COURSE_DISCOVERY"] = True
COURSE_CATALOG_API_URL = "http://discovery:8000/api/v1"

View File

@ -13,4 +13,7 @@ SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT = SOCIAL_AUTH_EDX_OAUTH2_ISSUER
SOCIAL_AUTH_EDX_OAUTH2_PUBLIC_URL_ROOT = SOCIAL_AUTH_EDX_OAUTH2_ISSUER
SOCIAL_AUTH_EDX_OAUTH2_LOGOUT_URL = SOCIAL_AUTH_EDX_OAUTH2_ISSUER + "/logout"
# Disable API caching, which makes it a pain to troubleshoot issues
USE_API_CACHING = False
{{ patch("discovery-development-settings") }}

View File

@ -52,3 +52,10 @@
--update \
discovery-sso \
discovery
# The COURSE_CATALOG_API_URL used to be stored in a setting, but is now a site
# configuration -- which means that it takes different values for different
# sites. This is important because the programs and courses returned for each
# site will differ.
site-configuration set -d {{ LMS_HOST }} COURSE_CATALOG_API_URL {% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ DISCOVERY_HOST }}/api/v1
site-configuration set -d {{ LMS_HOST }}:8000 COURSE_CATALOG_API_URL http://{{ DISCOVERY_HOST }}:8381/api/v1