Skip to content

feat(mitxonline): add MIT_LEARN_FASTLY_SERVICE_ID to k8s secrets - #5158

Merged
Ardiea merged 1 commit into
mainfrom
md/202607_mitxonline_pr_3794
Jul 29, 2026
Merged

feat(mitxonline): add MIT_LEARN_FASTLY_SERVICE_ID to k8s secrets#5158
Ardiea merged 1 commit into
mainfrom
md/202607_mitxonline_pr_3794

Conversation

@Ardiea

@Ardiea Ardiea commented Jul 29, 2026

Copy link
Copy Markdown
Member

What are the relevant tickets?

Supports mitodl/mitxonline#3794

Description (What does it do?)

Supplies the mitxonline deployment with a new MIT_LEARN_FASTLY_SERVICE_ID environment variable, per environment.

mitxonline PR mitodl/mitxonline#3794 fixes a Fastly surrogate-key purge that was a no-op. The purge must target MIT Learn's Fastly service — MIT Learn is what tags product-page responses with the mitxonline:* surrogate keys — but the code had been using MITxOnline's own service ID. The app now reads MIT_LEARN_FASTLY_SERVICE_ID and passes it explicitly into queue_fastly_surrogate_key_purge.

Changes:

  • src/ol_infrastructure/applications/mitxonline/k8s_secrets.py: adds MIT_LEARN_FASTLY_SERVICE_ID to the collected static-secret templates (rendered by the Vault agent from the secret-mitxonline mount, path collected-static-secrets), sourcing fastly.mit_learn_service_id. It rides the existing mitxonline-collected-static-secret K8s Secret, already consumed by the deployment via envFrom, so no __main__.py change is needed.
  • src/bridge/secrets/mitxonline/secrets.{ci,qa,production}.yaml: adds a new fastly.mit_learn_service_id key to each env's SOPS file, alongside the existing api_key/service_id.

Why copy the values instead of reading them in place: the correct MIT Learn service IDs already exist as learn_service_id_{ci,qa,production} under infrastructure/fastly in src/bridge/secrets/concourse/operations.production.yaml, but those are loaded to secret-concourse/infrastructure/fastly only by the production Concourse stack — so they live only in the production Vault. mitxonline ci/qa/production each deploy against separate Vaults and read from the secret-mitxonline mount, so the value has to live in each env's own mitxonline SOPS file to work per-environment. operations.production.yaml is the source of truth the values were copied from.

The existing MITX_ONLINE_FASTLY_SERVICE_ID / fastly.service_id (MITxOnline's own service) is left untouched. FASTLY_SERVICE_ID is intentionally not restored — nothing reads it.

How can this be tested?

  • pre-commit run --files <changed files> passes (ruff, mypy, detect-secrets, yaml/sops checks).
  • SOPS round-trip: sops --decrypt src/bridge/secrets/mitxonline/secrets.<env>.yaml | grep -A3 '^fastly:' shows mit_learn_service_id with the correct per-env value for ci/qa/production.
  • pulumi preview per stack (CI first) from src/ol_infrastructure/applications/mitxonline: expect the mitxonline-collected-static-secret to add the MIT_LEARN_FASTLY_SERVICE_ID template key and the Vault collected-static-secrets secret to gain the mit_learn_service_id field.
  • Post-deploy: kubectl exec <mitxonline-pod> -n <ns> -- printenv MIT_LEARN_FASTLY_SERVICE_ID returns MIT Learn's service ID and differs from MITX_ONLINE_FASTLY_SERVICE_ID.

Checklist:

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new per-environment Fastly service ID (MIT Learn’s) into the MITxOnline Kubernetes static secrets so the application can target the correct Fastly service when issuing surrogate-key purges (supporting mitodl/mitxonline#3794).

Changes:

  • Expose MIT_LEARN_FASTLY_SERVICE_ID via the existing mitxonline-collected-static-secret Vault-agent templated secret.
  • Add fastly.mit_learn_service_id to the mitxonline SOPS secrets files for ci, qa, and production.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/ol_infrastructure/applications/mitxonline/k8s_secrets.py Adds MIT_LEARN_FASTLY_SERVICE_ID to the Vault-agent template set used for the collected static K8s Secret.
src/bridge/secrets/mitxonline/secrets.ci.yaml Adds encrypted fastly.mit_learn_service_id for CI.
src/bridge/secrets/mitxonline/secrets.qa.yaml Adds encrypted fastly.mit_learn_service_id for QA.
src/bridge/secrets/mitxonline/secrets.production.yaml Adds encrypted fastly.mit_learn_service_id for production.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Ardiea
Ardiea merged commit 2cbca1e into main Jul 29, 2026
7 checks passed
@Ardiea
Ardiea deleted the md/202607_mitxonline_pr_3794 branch July 29, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants