Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Commit 39571ca

Browse files
authored
feat: add optional coursegraph service (#820)
Add a "coursegraph" service to devstack using the official Neo4j Docker image. The service is "extra"; that is, it will not start, be pulled, or be provisioned by default. Instead, provisioning can be done on-demand, which will dump data from LMS to Coursegraph: make dev.provision.coursegraph Commands like `dev.up.<service>`, `dev.attach.<service>`, etc are available for coursegraph, as they are for any other Devstack service. Further documentation will live in the edx-platform repo, in: ./openedx/core/djangoapps/coursegraph/README.rst Why add Coursegraph? It is a tool that is relied upon by many edX developers and support specialists, yet very few of us know how to operate it or fix it when it goes down. By making it part of devstack, it will be easier to debug issues and test out Neo4j upgrades. Furthermore, this enables developers to trial complex Cypher queries on custom data instead of simply trusting what they see returned by production Coursegraph. TNL-8386
1 parent ea67468 commit 39571ca

6 files changed

Lines changed: 56 additions & 3 deletions

File tree

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,21 +255,23 @@ impl-dev.provision.%: dev.check-memory ## Provision specified services.
255255
dev.provision.%: ## Provision specified services.
256256
@scripts/send_metrics.py wrap "dev.provision.$*"
257257

258-
dev.backup: dev.up.mysql+mysql57+mongo+elasticsearch+elasticsearch7+elasticsearch710 ## Write all data volumes to the host.
258+
dev.backup: dev.up.mysql+mysql57+mongo+elasticsearch+elasticsearch7+elasticsearch710+coursegraph ## Write all data volumes to the host.
259259
docker run --rm --volumes-from $$(make --silent --no-print-directory dev.print-container.mysql) -v $$(pwd)/.dev/backups:/backup debian:jessie tar zcvf /backup/mysql.tar.gz /var/lib/mysql
260260
docker run --rm --volumes-from $$(make --silent --no-print-directory dev.print-container.mysql57) -v $$(pwd)/.dev/backups:/backup debian:jessie tar zcvf /backup/mysql57.tar.gz /var/lib/mysql
261261
docker run --rm --volumes-from $$(make --silent --no-print-directory dev.print-container.mongo) -v $$(pwd)/.dev/backups:/backup debian:jessie tar zcvf /backup/mongo.tar.gz /data/db
262262
docker run --rm --volumes-from $$(make --silent --no-print-directory dev.print-container.elasticsearch) -v $$(pwd)/.dev/backups:/backup debian:jessie tar zcvf /backup/elasticsearch.tar.gz /usr/share/elasticsearch/data
263263
docker run --rm --volumes-from $$(make --silent --no-print-directory dev.print-container.elasticsearch7) -v $$(pwd)/.dev/backups:/backup debian:jessie tar zcvf /backup/elasticsearch7.tar.gz /usr/share/elasticsearch/data
264264
docker run --rm --volumes-from $$(make --silent --no-print-directory dev.print-container.elasticsearch710) -v $$(pwd)/.dev/backups:/backup debian:jessie tar zcvf /backup/elasticsearch710.tar.gz /usr/share/elasticsearch/data
265+
docker run --rm --volumes-from $$(make --silent --no-print-directory dev.print-container.coursegraph) -v $$(pwd)/.dev/backups:/backup debian:jessie tar zcvf /backup/coursegraph.tar.gz /data
265266

266-
dev.restore: dev.up.mysql+mysql57+mongo+elasticsearch+elasticsearch7+elasticsearch710 ## Restore all data volumes from the host. WILL OVERWRITE ALL EXISTING DATA!
267+
dev.restore: dev.up.mysql+mysql57+mongo+elasticsearch+elasticsearch7+elasticsearch710+coursegraph ## Restore all data volumes from the host. WILL OVERWRITE ALL EXISTING DATA!
267268
docker run --rm --volumes-from $$(make --silent --no-print-directory dev.print-container.mysql) -v $$(pwd)/.dev/backups:/backup debian:jessie tar zxvf /backup/mysql.tar.gz
268269
docker run --rm --volumes-from $$(make --silent --no-print-directory dev.print-container.mysql57) -v $$(pwd)/.dev/backups:/backup debian:jessie tar zxvf /backup/mysql57.tar.gz
269270
docker run --rm --volumes-from $$(make --silent --no-print-directory dev.print-container.mongo) -v $$(pwd)/.dev/backups:/backup debian:jessie tar zxvf /backup/mongo.tar.gz
270271
docker run --rm --volumes-from $$(make --silent --no-print-directory dev.print-container.elasticsearch) -v $$(pwd)/.dev/backups:/backup debian:jessie tar zxvf /backup/elasticsearch.tar.gz
271272
docker run --rm --volumes-from $$(make --silent --no-print-directory dev.print-container.elasticsearch7) -v $$(pwd)/.dev/backups:/backup debian:jessie tar zxvf /backup/elasticsearch7.tar.gz
272273
docker run --rm --volumes-from $$(make --silent --no-print-directory dev.print-container.elasticsearch710) -v $$(pwd)/.dev/backups:/backup debian:jessie tar zxvf /backup/elasticsearch710.tar.gz
274+
docker run --rm --volumes-from $$(make --silent --no-print-directory dev.print-container.coursegraph) -v $$(pwd)/.dev/backups:/backup debian:jessie tar zxvf /backup/coursegraph.tar.gz
273275

274276
# List of Makefile targets to run database migrations, in the form dev.migrate.$(service)
275277
# Services will only have their migrations added here
@@ -515,6 +517,9 @@ dev.static.%: ## Rebuild static assets for the specified service's container.
515517

516518
dev.reset: dev.down dev.reset-repos dev.prune dev.pull.large-and-slow dev.up.large-and-slow dev.static dev.migrate ## Attempt to reset the local devstack to the master working state without destroying data.
517519

520+
dev.destroy.coursegraph: dev.down.coursegraph ## Remove all coursegraph data.
521+
docker volume rm ${COMPOSE_PROJECT_NAME}_coursegraph_data
522+
518523
dev.destroy: ## Irreversibly remove all devstack-related containers, networks, and volumes.
519524
$(WINPTY) bash ./destroy.sh
520525

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ Instead of a service name or list, you can also run commands like ``make dev.pro
312312
+------------------------------------+-------------------------------------+----------------+--------------+
313313
| `xqueue`_ | http://localhost:18040/api/v1/ | Python/Django | Extra |
314314
+------------------------------------+-------------------------------------+----------------+--------------+
315+
| `coursegraph` | http://localhost:7474/browser | Tooling (Java) | Extra |
316+
+------------------------------------+-------------------------------------+----------------+--------------+
315317

316318
Some common service combinations include:
317319

@@ -336,6 +338,7 @@ Some common service combinations include:
336338
.. _frontend-app-library-authoring: https://github.com/edx/frontend-app-library-authoring
337339
.. _frontend-app-course-authoring: https://github.com/edx/frontend-app-course-authoring
338340
.. _xqueue: https://github.com/edx/xqueue
341+
.. _coursegraph: https://github.com/edx/edx-platform/tree/master/openedx/core/djangoapps/coursegraph
339342

340343

341344
Known Issues

docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ services:
3131
- ../edx-e2e-tests/upload_files:/edx/app/e2e/edx-e2e-tests/upload_files
3232
- ../edx-platform/common/test/data:/edx/app/edxapp/edx-platform/common/test/data
3333

34+
coursegraph:
35+
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.coursegraph"
36+
hostname: coursegraph.devstack.edx
37+
# Try to keep this in sync with the NEO4J_VERSION declared within
38+
# https://github.com/edx/configuration/blob/master/playbooks/roles/neo4j
39+
image: neo4j:3.2
40+
networks:
41+
default:
42+
aliases:
43+
- edx.devstack.coursegraph
44+
ports:
45+
- "7474:7474" # Expose Web interface at http://localhost:7474.
46+
- "7687:7687" # Expose Bolt interface at bolt://user:password@localhost:7687.
47+
volumes:
48+
- coursegraph_data:/data
49+
stdin_open: true
50+
tty: true
51+
environment:
52+
NEO4J_AUTH: "neo4j/edx" # Initial username/password for Neo4j Web interface.
53+
3454
devpi:
3555
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.devpi"
3656
hostname: devpi.devstack.edx
@@ -600,6 +620,7 @@ services:
600620
- lms
601621

602622
volumes:
623+
coursegraph_data:
603624
discovery_assets:
604625
devpi_data:
605626
edxapp_lms_assets:

options.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ credentials+discovery+ecommerce+lms+registrar+studio
9797
# All third-party services.
9898
# Separated by plus signs. Listed in alphabetical order for clarity.
9999
THIRD_PARTY_SERVICES ?= \
100-
chrome+devpi+elasticsearch+elasticsearch7+elasticsearch710+firefox+memcached+mongo+mysql+mysql57+redis+namenode+datanode+resourcemanager+nodemanager+sparkmaster+sparkworker+vertica
100+
chrome+coursegraph+devpi+elasticsearch+elasticsearch7+elasticsearch710+firefox+memcached+mongo+mysql+mysql57+redis+namenode+datanode+resourcemanager+nodemanager+sparkmaster+sparkworker+vertica

provision-coursegraph.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
set -eu -o pipefail
3+
4+
. scripts/colors.sh
5+
set -x
6+
7+
echo -e "${GREEN} Ensuring Coursegraph image is up to date...${NC}"
8+
9+
# Pulling the image will almost always be a no-op, but will be important
10+
# when we bump the version in docker-compose.yml or when Neo4j releases a patch.
11+
# Also, this gives us a chance to refresh the container in case it's gotten into
12+
# a weird state.
13+
docker-compose rm --force --stop coursegraph
14+
docker-compose pull coursegraph
15+
docker-compose up -d coursegraph
16+
17+
sleep 10 # Give Neo4j some time to boot up.
18+
19+
echo -e "${GREEN} Updating LMS courses in Coursegraph...${NC}"
20+
21+
docker-compose exec lms bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform/ && ./manage.py lms dump_to_neo4j --host coursegraph.devstack.edx --user neo4j --password edx'
22+
23+
echo -e "${GREEN} Coursegraph is now up-to-date with LMS!${NC}"

provision.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ forum \
4747
notes \
4848
registrar \
4949
xqueue \
50+
coursegraph \
5051
"
5152

5253
# What should we provision?

0 commit comments

Comments
 (0)