Skip to content
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

feat: create aspects-consumer deployment #610

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .ci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@ SUPERSET_XAPI_DASHBOARD_SLUG: openedx-xapi
ASPECTS_VERSION: 0.91.0
DOCKER_IMAGE_OPENEDX: edunext/openedx-aspects:{{ASPECTS_VERSION}}
DOCKER_IMAGE_OPENEDX_DEV: edunext/openedx-aspects-dev:{{ASPECTS_VERSION}}
ASPECTS_ENABLE_EVENT_BUS_CONSUMER: true
ASPECTS_ENABLE_EVENT_BUS_PRODUCER: true
8 changes: 4 additions & 4 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ jobs:
runs-on: ubuntu-latest
if: "!startsWith(github.head_ref, 'dependabot/')"
steps:
- name: Checkout
run:
echo ${{github.head_ref}}
- name: Log in to Docker Hub
continue-on-error: true
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20
Expand All @@ -31,10 +28,13 @@ jobs:
password: ${{ secrets.EDUNEXT_DOCKER_PASSWORD }}
- name: Checkout
uses: actions/checkout@v4
- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Update ASPECTS_VERSION
if: github.event.action == 'opened' || github.event.action == 'synchronize'
run: |
ASPECTS_VERSION=pr-${{ github.event.pull_request.number }}
ASPECTS_VERSION=pr-${{ github.event.pull_request.number }}-${{ steps.vars.outputs.sha_short }}
sed -i "s/ASPECTS_VERSION: .*/ASPECTS_VERSION: $ASPECTS_VERSION/" .ci/config.yml
- name: setup python
uses: actions/setup-python@v5
Expand Down
59 changes: 59 additions & 0 deletions tutoraspects/patches/k8s-deployments
Original file line number Diff line number Diff line change
Expand Up @@ -538,3 +538,62 @@ spec:
hostPath:
path: /var/log/
{% endif %}

{% if ASPECTS_ENABLE_EVENT_BUS_CONSUMER %}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: aspects-consumer
labels:
app.kubernetes.io/name: aspects-consumer
spec:
selector:
matchLabels:
app.kubernetes.io/name: aspects-consumer
template:
metadata:
labels:
app.kubernetes.io/name: aspects-consumer
spec:
securityContext:
runAsUser: 1000
runAsGroup: 1000
containers:
- name: aspects-consumer
image: {{ DOCKER_IMAGE_OPENEDX }}
env:
- name: SERVICE_VARIANT
value: lms
- name: DJANGO_SETTINGS_MODULE
value: lms.envs.tutor.production
volumeMounts:
- mountPath: /openedx/edx-platform/lms/envs/tutor/
name: settings-lms
- mountPath: /openedx/edx-platform/cms/envs/tutor/
name: settings-cms
- mountPath: /openedx/config
name: config
securityContext:
allowPrivilegeEscalation: false
command:
- "./manage.py"
- "lms"
- "consume_events"
- "-t"
- "analytics"
- "-g"
- "event_routing_backends"
- "--extra"
- '{"consumer_name": "aspects"}'
volumes:
- name: settings-lms
configMap:
name: openedx-settings-lms
- name: settings-cms
configMap:
name: openedx-settings-cms
- name: config
configMap:
name: openedx-config
{% endif %}
9 changes: 9 additions & 0 deletions tutoraspects/patches/local-docker-compose-dev-services
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,12 @@ clickhouse:
- ../../env/plugins/aspects/apps/clickhouse/dev_config:/etc/clickhouse-server/config.d/
- ../../env/plugins/aspects/apps/clickhouse/users:/etc/clickhouse-server/users.d/
{% endif %}

{% if ASPECTS_ENABLE_EVENT_BUS_CONSUMER %}
aspects-consumer:
<<: *openedx-service
environment:
DJANGO_SETTINGS_MODULE: lms.envs.tutor.development
command: |
./manage.py lms consume_events -t analytics -g event_routing_backends --extra '{"consumer_name": "aspects"}'
{% endif %}
28 changes: 28 additions & 0 deletions tutoraspects/patches/local-docker-compose-services
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,31 @@ vector:
- VECTOR_LOG=warn
restart: unless-stopped
{% endif %}

{% if ASPECTS_ENABLE_EVENT_BUS_CONSUMER %}
aspects-consumer:
image: {{ DOCKER_IMAGE_OPENEDX }}
stdin_open: true
tty: true
volumes:
# Settings & config
- ../apps/openedx/settings/lms:/openedx/edx-platform/lms/envs/tutor:ro
- ../apps/openedx/settings/cms:/openedx/edx-platform/cms/envs/tutor:ro
- ../apps/openedx/config:/openedx/config:ro
{%- for mount in iter_mounts(MOUNTS, "openedx", "lms") %}
- {{ mount }}
{%- endfor %}
environment:
SERVICE_VARIANT: lms
DJANGO_SETTINGS_MODULE: lms.envs.tutor.production
restart: unless-stopped
command: |
./manage.py lms consume_events -t analytics -g event_routing_backends --extra '{"consumer_name": "aspects"}'
deploy:
mode: replicated
replicas: {{ ASPECTS_EVENT_BUS_CONSUMER_REPLICAS }}
depends_on:
{% if RUN_MYSQL %}- mysql{% endif %}
{% if RUN_MONGODB %}- mongodb{% endif %}
{% if RUN_REDIS %}- redis{% endif %}
{% endif %}
22 changes: 22 additions & 0 deletions tutoraspects/patches/openedx-common-settings
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,25 @@ if not OPEN_EDX_FILTERS_CONFIG.get("org.openedx.learning.instructor.dashboard.re
}
OPEN_EDX_FILTERS_CONFIG["org.openedx.learning.instructor.dashboard.render.started.v1"]["pipeline"].append("platform_plugin_aspects.extensions.filters.AddSupersetTab")
{% endif %}

{% if ASPECTS_ENABLE_EVENT_BUS_PRODUCER %}
# Update the backends to use the event bus
EVENT_TRACKING_BACKENDS["event_transformer"]["ENGINE"] = "eventtracking.backends.event_bus.EventBusRoutingBackend"
# Update backend to send events in sync mode
EVENT_TRACKING_BACKENDS["event_transformer"]["OPTIONS"]["backends"]["xapi"]["ENGINE"] = "event_routing_backends.backends.sync_events_router.SyncEventsRouter"
EVENT_TRACKING_BACKENDS["event_transformer"]["OPTIONS"]["backends"]["caliper"]["ENGINE"] = "event_routing_backends.backends.sync_events_router.SyncEventsRouter"
# Enable the event bus producer
SEND_TRACKING_EVENT_EMITTED_SIGNAL = True
# Update the event bus producer config
EVENT_BUS_PRODUCER_CONFIG.update(
{
"org.openedx.analytics.tracking.event.emitted.v1": {
"analytics": {
"event_key_field": "tracking_log.name", "enabled": True
}
}
}
)

INSTALLED_APPS.append("openedx_events")
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
pip install "platform-plugin-aspects==v0.5.0"
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
pip install "edx-event-routing-backends==v9.0.0"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
pip install "platform-plugin-aspects==v0.5.0"
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
pip install "edx-event-routing-backends==v8.3.1"
pip install "edx-event-routing-backends==v9.0.0"
3 changes: 3 additions & 0 deletions tutoraspects/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
# in the ClickHouse database. Make sure that you understand the legal
# consequences of data storage and privacy before turning this on!
("ASPECTS_ENABLE_PII", False),
("ASPECTS_ENABLE_EVENT_BUS_CONSUMER", False),
("ASPECTS_ENABLE_EVENT_BUS_PRODUCER", False),
("ASPECTS_EVENT_BUS_CONSUMER_REPLICAS", 1),
# User PII is cached in an in-memory dictionary for this many seconds.
("ASPECTS_PII_CACHE_LIFETIME", 900),
# Markdown comprising the Help tab for the Operator and Instructor dashboards.
Expand Down