Setting up the solutions devstack - edx/edx-solutions-edx-platform GitHub Wiki
Initial machine provisioning
-
Install Vagrant (
brew cask install virtualbox && brew cask install vagranton MacOS orsudo apt-get install virtualbox vagranton Ubuntu) -
Make sure that Intel virtualization is enabled in your BIOS / UEFI firmware.
-
Install the nfs server package (
sudo apt-get install nfs-kernel-serverin Ubuntu). -
Create a folder for your solutions devstack. The following structure is recommended:
devstack/(optional upstream devstack - contains Vagrantfile, edx-platform, etc.)
devstack-solutions/(this will be the new devstack - will contain Vagrantfile, edx-platform, etc.)
src/(directory where XBlocks can be installed and shared by both devstacks) -
Download this Vagrantfile and save it into the
devstack-solutionsfolder. -
Open a terminal in the
devstack-solutionsfolder and run the commandvagrant up. It will fail. Some of the reasons for failures, and the fixes are listed below. You may need to runvagrant provisionmultiple times to resume the setup until it works. Below there are some actions which must be performed so that the setup work:- Update expired APT repositories GPG keys.
- run `vagrant ssh'
- run
for K in $(apt-key list | grep expired | cut -d'/' -f2 | cut -d' ' -f1); do sudo apt-key adv --recv-keys --keyserver keys.gnupg.net $K; done - run
curl -L https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey | sudo apt-key add -
- Delete APT repositories which do not exist anymore
- sudo
rm -f /etc/apt/sources.list.d/downloads_distro_mongodb_org_repo_ubuntu_upstart.list - sudo
rm -f /etc/apt/sources.list.d/google-chrome.list
- sudo
- Error:
Permission denied: '/edx/app/edx_ansible/venvs/edx_ansible/lib/python2.7/site-packages/bson/__init__.py. Solution: runvagrant ssh,sudo su,source /edx/app/edx_ansible/venvs/edx_ansible/bin/activate,pip uninstall pymongo - Error:
fatal: Not a git repository (or any parent up to mount point /edx/app/ecommerce). Solution: on host, rungit clone https://github.com/edx/ecommerce.gitin the same directory as theVagrantfile, then runvagrant provision. - If you use Arch Linux, make sure to enable v3 and UDP support for NFS (as described [here]
- Update expired APT repositories GPG keys.
When the script completes successfully, you will have a fully functional upstream devstack, running ginkgo.master release. You might want to spin it up and make sure LMS and Studio works as expected (see instructions on running devstack).
Switching to solutions fork
Next, checkout the solutions fork of edx-platform into your edx-platform repo. If you want to support multiple remotes, we recommend making origin point to edx-solutions/edx-platform and having upstream point to edx/edx-platform. To do so, on your host, change the directories to where devstack checked out edx/edx-platform.
cd ~/solutions/edx-platform # For example, in case your Devstack is built in ~/solutions; otherwise, change this path
git remote add solutions https://github.com/edx-solutions/edx-platform.git
git remote rename origin upstream
git remote rename solutions origin
git fetch origin
git checkout -b solutions_master origin/master
We also use a forked version of the cs_comment_client repo. To use that, in your host:
cd ~/solutions/cs_comments_service # For example, in case your Devstack is built in ~/solutions; otherwise, change this path
git remote add solutions https://github.com/edx-solutions/cs_comments_service.git
git remote rename origin upstream
git remote rename solutions origin
git fetch origin
git checkout origin/master -b solutions_master
Updating dependencies
Next, vagrant ssh into the Vagrant box, then we have to update the Python dependencies. As the vagrant user, run:
sudo su edxapp # Make sure prompt reads ~/edx-platform
unset NO_PREREQ_INSTALL
# Clean out all files which aren't tracked by git, like old precompiled python files and some generated CSS.
git clean -fx
paver install_prereqs
You might want to (and most certainly will at some point) install additional packages or different versions of existing packages into virtualenv. However, commands used to run LMS/Studio (paver devstack lms) check dependencies hash first thing and reinstall everything if hash does not match the one generated after last paver install_prereqs. To avoid that, make sure you're running it with NO_PREREQ_INSTALL=1; the easiest way to ensure that is to add it to ~/.bashrc:
export NO_PREREQ_INSTALL=1
Configuring environment
We also have to turn on some features in the /edx/app/edxapp/lms.env.json file before re-generating the database. Add these entries within the FEATURES section of lms.env.json:
"FEATURES": {
...
"EDX_SOLUTIONS_API": true,
"MARK_PROGRESS_ON_GRADING_EVENT": true,
"SIGNAL_ON_SCORE_CHANGED": true,
"ORGANIZATIONS_APP": true,
"ENABLE_XBLOCK_VIEW_ENDPOINT": true,
"ENABLE_NOTIFICATIONS": true
},
Next, update the MODULESTORE entry in /edx/app/edxapp/lms.auth.json and /edx/app/edxapp/cms.auth.json. It looks like this:
"MODULESTORE": {
"default": {
"ENGINE": "xmodule.modulestore.mixed.MixedModuleStore",
"OPTIONS": {
"mappings": {},
"stores": [
{
"DOC_STORE_CONFIG": {...settings...},
"ENGINE": "xmodule.modulestore.split_mongo.split_draft.DraftVersioningModuleStore",
"NAME": "split",
"OPTIONS": {...settings...}
},
{
"DOC_STORE_CONFIG": {...settings...},
"ENGINE": "xmodule.modulestore.mongo.DraftMongoModuleStore",
"NAME": "draft",
"OPTIONS": {...settings...}
}
]
}
}
},
Just swap the items in the stores list, so that the one with "NAME": "draft" is on top. Please make sure to do that both in lms.auth.json and cms.auth.json - omitting this change for cms.auth.json is a common mistake.
This is required because currently the solutions platform is not tested with Split and is known to have trouble with it.
Database migration
We will now need to update the DB to include these applications and the custom fields we've added to other apps. Unfortunately, the base VM box has some discrepancies in migrations actually applied to the DB and migrations registered with migration engine, so we'll have to fake them:
- Unapply student migrations
./manage.py lms migrate student zero --settings=devstack- solutions fork added a couple of fields as way back as migration 0001, but base VM box have those migration applied without those fields. (note for the next rebase: updating upstream migration code isn't a good idea). - Finally, migrate everything with
./manage.py lms migrate --settings=devstack
Verifying the setup
After all of these steps, you may want to return to the edxapp user and run all unit tests to verify the integrity of the runtime environment:
paver test_python
Try running LMS and/or Studio:
sudo su edxapp
paver devstack lms
Verify it actually works:
- Open http://localhost:8000/ in your favorite browser. If it crashes right away with
process() takes exactly 3 arguments (2 given)there's a problem withdjango-debug-toolbarversion used (at the time of writing 1.3.2). Upgrade to 1.5 withpip install django-debug-toolbar==1.5, then make sure we're still on Django 1.8 (pip freeze | grep Django) andNO_PREREQ_INSTALLis set to1when you run LMS/Studio. - Log in as staff.
- Navigate to dashboard. If it crashes with "column auth_userprofile.title not found" - please make sure you've reapplied
studentapp migrations from the beginning, as instructed in "Database migration" section, step 4.