- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3
add mitxonline networking directions #2594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to hold off for another, more experienced review, but these instructions are pretty much bang on what I ended up figuring out when I set it up on my own. Thanks for the writeup!
| The goal of this is to allow MITx Online and Learn to be set up so that MITx Online can have some data in it, and Learn can pull that data out for its needs, right? This seems OK for that purpose. | 
        
          
                README.md
              
                Outdated
          
        
      |  | ||
| ### Connecting with MITxOnline | ||
|  | ||
| Set up the [mitxonline](https://github.com/mitodl/mitxonline) as indicated there. _Note: A working OpenEdx installation is not necessary for integration with Learn._ | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe place this sentence after setting the env variables below in MIT-Learn and MITx Online, and starting up both.
Also, OPENEDX_API_CLIENT_ID and OPENEDX_API_CLIENT_SECRET require values for the mitxonline app to start successfully,  but they are not mentioned in that repo's README or included in the example  .env file.  They are mentioned in the "Using Tutor" instructions but I skipped that step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this PR should also enable mitxonline users to log in via mit-learn's apisix/keycloak instance, but if so I could not validate that because something seems off with my local setup and I was unable to log in that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this PR should also enable mitxonline users to log in via mit-learn's apisix/keycloak instance, but if so I could not validate that because something seems off with my local setup and I was unable to log in that way.
Do you mean click login via MITxOnline login button? I had forgotten that does a surprising infinite loop. I'm not sure what causes that, but logging in via MIT Learn works.
@jkachel Do you have any idea? IMO not critical though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was getting that endless loop initially, then started adjusting other env values with best guesses and got apisix or keycloak errors instead.
| KEYCLOAK_CLIENT_ID=apisix | ||
| KEYCLOAK_CLIENT_SECRET=HckCZXToXfaetbBx0Fo3xbjnC468oMi4 # pragma: allowlist-secret | ||
| KEYCLOAK_DISCOVERY_URL=http://kc.ol.local:8066/realms/ol-local/.well-known/openid-configuration | ||
| KEYCLOAK_REALM_NAME=ol-local | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not log in with these settings. But the backpopulate command works regardless.
If the goal of this PR is just to backpopulate from a local mitxonline instance, then these keycloak settings can be omitted.
If the goal is also to allow login via MIT-Learn's apisix/keycloak instance, then something is off, maybe I have a bad or missing environment value somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbertrand If:
- you could log into Learn via Learn frontend
- but once logged into Learn, you weren't authenticated with MITxOnline
I believe the issue was an incorrect value of MITOL_API_DOMAIN. I missed it because I had been overwriting it locally so i could use learn.odl.local, but I've removed all those overrides and I'm now back to using open.odl.local
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been testing this on Ubuntu Linux 24.04. I was able to eventually get the dashboard connected and see my programs / enrollments on the frontend, after changing some of the settings I noted below. However, I was unable to get the program page in Learn working. When I try and load the page for my test program, I get "Error fetching course page metadata for programv1%3Aprogam-v1-test-program" (Yes, that is the readable ID of my test program). The message says "connect ECONNREFUSED 127.0.0.1:8065." This indicates that the API in the watch server (since the metadata seems to be queried by the server and not the client) has mitxonline.odl.local as the MITx Online base url, which is going to evaluate to 127.0.0.1. I think in the docker configuration, if we somehow get the watch container itself to use host.docker.internal:8013 for that, then it should work?
        
          
                docker-compose.services.yml
              
                Outdated
          
        
      | - MITX_ONLINE_UPSTREAM=${MITX_ONLINE_UPSTREAM:-mitxonline.odl.local:8013} | ||
| - MITX_ONLINE_DOMAIN=${MITX_ONLINE_DOMAIN:-mitxonline.odl.local} | ||
| - MITX_ONLINE_UPSTREAM=${MITX_ONLINE_UPSTREAM:-host.docker.internal:8013} | ||
| - MITX_ONLINE_DOMAIN=${MITX_ONLINE_DOMAIN:-host.docker.internal} | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to set MITX_ONLINE_DOMAIN to mitxonline.odl.local. This allows you to access http://mitxonline.odl.local:8065/ in a browser and then, using your already logged in session in APISIX, you are automatically authenticated to use Django admin in MITx Online.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure what the issue was here, but I've changed so that docker.host.internal is not longer used and we just use mitxonline.odl.local everywhere.
f2b0fec    to
    c72bdeb      
    Compare
  
    | MAILGUN_KEY=fake | ||
| MAILGUN_SENDER_DOMAIN=open.odl.local | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These settings are new. They were in backend.env.example, are not secret, and some value is required for the app to work, so I think they should be in the defaults.
(I removed most of my local env vars to isolate what was actually necessary for mitxonline connection)
        
          
                env/backend.env
              
                Outdated
          
        
      | CORS_ALLOWED_ORIGINS='["http://open.odl.local:8062"]' | ||
| CSRF_TRUSTED_ORIGINS='["http://open.odl.local:8062", "http://api.open.odl.local:8063"]' | ||
| CSRF_COOKIE_DOMAIN=open.odl.local | ||
| CSRF_COOKIE_DOMAIN=.odl.local | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the default value of this env var.
c4ff3c8    to
    81b26ec      
    Compare
  
    | @mbertrand @gumaerc This is ready for another look. @mbertrand I tried to clarify the readme a bit, both in order and expected behavior of mitxonline. I also dropped  | 
| extra_hosts: | ||
| # Both the browser and NextJS server (containerized) make requests to | ||
| # api.open.odl.local, forward those to host | ||
| - "api.open.odl.local:host-gateway" | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gumaerc re
When I try and load the page for my test program, I get "Error fetching course page metadata for programv1%3Aprogam-v1-test-program" (Yes, that is the readable ID of my test program).
I suspect that was happening for all api-dependent metadata generation (though some of them may have fallbacks to static metadata w/o an api call), not just the mitxonline-specific ones.
This should fix it.
| FWIW, I took another look at this and ran through the tests. Still looks good (I like the new extra_hosts approach)! I'll note that I did hit 404s when attempting to hit  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can log in to mit-learn, then when I click the link to the mitxonline course, I am logged in to my local mitxonline as well - 👍
Login still doesn't work in the opposite direction - endless redirects when trying to log in to mitxonline first.
http://mitxonline.odl.local:8013/courses/course-v1:mycourse : works fine
327c70f    to
    6788e23      
    Compare
  
    |  | ||
| ```env | ||
| # MIT Learn, shared.local.env (ensure not overwritten in backend/frontend env) | ||
| MITX_ONLINE_BASE_URL=http://api.open.odl.local:8065/mitxonline | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbertrand I had this wrong previously, MITX_ONLINE_BASE_URL should be in shared (not backend) since it's used by the frontend, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works with the latest changes (and turning off the browser's adblocker to let posthog through).
6788e23    to
    0b19581      
    Compare
  
    
What are the relevant tickets?
All the PRs we make where we copy-and-paste the setup directions for mitxonline <> Learn.
Description (What does it do?)
This PR adds directions for running MITxOnline and MIT Learn locally in a way that they can communicate.
How can this be tested?
./manage.py create_courseware,./manage.py create_courseware_page; see--helpfor details. Note: program readable ids should start withprogram-v1:../manage.py backpopulate_mitxonline_data --delete, and./manage.py backpopulate_mitxonline_dataproduct-page-coursefeature flag is on in your personal posthog./manage.py backpopulate_mitxonline_data