fix: read Learn's Fastly service ID from MIT_LEARN_FASTLY_SERVICE_ID - #3794
Merged
Conversation
OpenAPI ChangesShow/hide changesUnexpected changes? Ensure your branch is up-to-date with |
The surrogate key purge targets MIT Learn's Fastly service, because MIT Learn is what tags its product page responses with the mitxonline:* surrogate keys. The setting holding that service ID was named MITX_ONLINE_FASTLY_SERVICE_ID and read from a bare FASTLY_SERVICE_ID env var, which reads as "MITxOnline's own service" and inverts this repo's convention -- elsewhere the app-prefixed name is the env var (EMAIL_BACKEND is read from MITX_ONLINE_EMAIL_BACKEND, and 16 others). That inversion is how the env vars came to be renamed to the setting names in mitodl/ol-infrastructure#5119, leaving both settings unset in production and the purge a silent no-op. Rename to MIT_LEARN_FASTLY_SERVICE_ID, matching the existing MIT_LEARN_* namespace, whose seven settings all use the env var name unchanged -- the prefix names the external system, so no app prefix applies. The token and API URL now follow the app-prefixed convention instead, reading MITX_ONLINE_FASTLY_AUTH_TOKEN and MITX_ONLINE_FASTLY_URL, which is what the deployment already sets. So the infra follow-up only has to add the service ID; nothing has to be reverted. Pass the service ID into queue_fastly_surrogate_key_purge explicitly rather than reading it from module state, so the target of a purge is visible at the call site instead of being an unqualified global in the MITxOnline repo. It defaults to None so messages enqueued by the previous release skip the purge rather than raising during a rolling deploy. Read the token and URL through django.conf.settings, removing the module-import-time coupling that made these values invisible to Django's settings fixture in tests. Adds cms/tasks_test.py and cms/signals_test.py; neither module had tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ChristopherChudzicki
force-pushed
the
fix/fastly-learn-service-id-env-var
branch
from
July 29, 2026 01:11
905c9a4 to
8a6457e
Compare
Merged
2 tasks
Ardiea
added a commit
to mitodl/ol-infrastructure
that referenced
this pull request
Jul 29, 2026
The mitxonline Fastly surrogate-key purge must target MIT Learn's Fastly
service (MIT Learn tags product-page responses with the mitxonline:*
surrogate keys), not MITxOnline's own service. Add a new
MIT_LEARN_FASTLY_SERVICE_ID env var, sourced per-environment from a new
fastly.mit_learn_service_id key in each mitxonline SOPS secrets file
(values copied from learn_service_id_{ci,qa,production} under
infrastructure/fastly in operations.production.yaml).
Supports mitodl/mitxonline#3794.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
marslanabdulrauf
requested changes
Jul 30, 2026
marslanabdulrauf
left a comment
Contributor
There was a problem hiding this comment.
Added a couple of findings:
- Rolling deploy is handled in one direction only
- Minor
cms/signals_test.pycallspurge_fastly_cache_on_publishdirectly rather than firingpage_published
Comment on lines
+118
to
+121
| service_id (str): The Fastly service ID whose cache should be purged. | ||
| Callers pass settings.MIT_LEARN_FASTLY_SERVICE_ID. Defaults to None | ||
| so that messages enqueued by an older release, before this argument | ||
| existed, skip the purge rather than raising during a rolling deploy. |
Contributor
There was a problem hiding this comment.
This fix is one sided and will always work if the celery is the one to be deployed first.
The other way is if we started passing two positional arguments and the function only accept one.
Contributor
Author
There was a problem hiding this comment.
Good point.
I do want to keep the service id passing explicit, since i think it's somewhat unexpected that mitxonline's queue_fastly_surrogate_key_purge purges a different service id. But I made the passing optional, and a follow PR, stacked on this one, makes it required.
ChristopherChudzicki
force-pushed
the
fix/fastly-learn-service-id-env-var
branch
2 times, most recently
from
July 30, 2026 14:53
6dea71e to
36fcddc
Compare
Keeps the enqueued Celery message a single positional argument so a rolling deploy is safe in both directions: an old webapp's one-arg message runs on a new worker and still purges via the fallback, and a new webapp's one-arg message runs on an old worker unchanged. Passing service_id explicitly from the call sites is #3804, once every worker accepts the argument. Also drives cms/signals_test.py through Wagtail's real publish rather than calling the receiver directly, so the page_published.connect() wiring is covered. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ChristopherChudzicki
force-pushed
the
fix/fastly-learn-service-id-env-var
branch
from
July 30, 2026 14:57
36fcddc to
221cae9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are the relevant tickets?
Refs https://github.com/mitodl/hq/issues/12381
Description (What does it do?)
MITX_ONLINE_FASTLY_*),MIT_LEARN_FASTLY_SERVICE_ID, replacingMITX_ONLINE_FASTLY_SERVICE_ID. The value is Learn's service ID — Learn is what tags its product pages with themitxonline:*surrogate keys, so purging MITxOnline's own service does nothing. The old name invited exactly that mistake.MITX_ONLINE_FASTLY_SERVICE_IDin a way that worked.service_idan explicit argument toqueue_fastly_surrogate_key_purge, so a purge's target is visible at the call site. Defaults toNoneso messages enqueued by the previous release skip rather than raise mid-deploy.Also reads these via
django.conf.settingsinstead of importing frommain.settingsat module import time, which is what hid them from Django'ssettingsfixture in tests.How can this be tested?
Tests should pass. Not easily testable locally otherwise.
Additional Context
Safe to deploy alone:
It starts working when the infra change below lands.
Soft → hard purge is deliberately excluded, so this infra change can be validated in RC while soft purge is still in place.
Checklist:
MIT_LEARN_FASTLY_SERVICE_IDtomitxonline/k8s_secrets.py, per environment. Values already exist aslearn_service_id_{ci,qa,production}underinfrastructure/fastlyinsrc/bridge/secrets/concourse/operations.production.yaml. Notsecret-mitxonline'sfastly.service_id— that's MITxOnline's own service, and using it is what made the original purge a no-op.FASTLY_SERVICE_ID; nothing reads it now.purge_selecton the target service, and this token comes from MITxOnline's Vault path.