From 688ca162f89343ebabbfb5245adf49c4b6beddb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrew=20Beveridge=20=E2=98=84=EF=B8=8F?= Date: Wed, 4 Nov 2026 23:36:33 -0500 Subject: [PATCH] infra: give audio-download-job the Tornado key (0.291.1) (#1251) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `audio-download-job` does most YouTube downloads, and it gets secrets from Pulumi rather than CI's API deploy, so #1247's wiring alone would have left Tornado off for them. Already applied to prod with `gcloud run jobs update --update-secrets` (env diff checked: one variable added). This records it in Pulumi so a later apply doesn't remove it. Pulumi preview couldn't run from Andrew's Mac: its GCP provider fails with `socket is not connected` on IPv6 token requests, while `gcloud` works. Run a targeted preview later to confirm no diff: `scripts/gcp-admin pulumi preview --stack prod --diff --target 'urn:pulumi:prod::karaoke-gen-infrastructure::gcp:cloudrunv2/job:Job::audio-download-job-us-east4'` Merging also triggers the API deploy, which now finds secret `tornado-api-key` and wires it there. No local CodeRabbit review on this small config change, so the bot may review it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012RYLVTvqXyL4QyA2EjzQMG ## Summary by CodeRabbit * **Bug Fixes** * Updated credential availability for audio download processing. * **Documentation** * Clarified how the Tornado API credential is provided to the API service and audio download processing. Co-authored-by: Claude Opus 5.5 --- docs/ARCHITECTURE.md | 2 +- infrastructure/modules/cloud_run.py | 12 ++++++++++++ pyproject.toml | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 0d8697b7..68d49169 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -705,7 +705,7 @@ Audio can come from file upload or remote search (YouTube, torrents). All YouTub 2026-09-26; the backend and `audio-download-job` / `bulk-search-job` have no VPC egress, so every dependency they call must be reachable on a public address. - `FLACFETCH_API_KEY` - API key for authentication -- `TORNADO_API_KEY` - TornadoAPI key (secret `tornado-api-key`). When set, YouTube downloads and availability checks try Tornado first and fall back to flacfetch: WARNING per failed download, ERROR if the account is rejected. CI wires the secret once it has a version. It covers downloads only, so YouTube search still uses flacfetch's cookies. +- `TORNADO_API_KEY` - TornadoAPI key (secret `tornado-api-key`). When set, YouTube downloads and availability checks try Tornado first and fall back to flacfetch: WARNING per failed download, ERROR if the account is rejected. The secret was created by hand (not in `secrets.py`). CI wires it on the API service once it has a version; Pulumi wires it on `audio-download-job`, which does most YouTube downloads. It covers downloads only, so YouTube search still uses flacfetch's cookies. - `YOUTUBE_DOWNLOAD_PROVIDER` - set to `flacfetch` to switch Tornado off, e.g. `gcloud run services update karaoke-backend --update-env-vars YOUTUBE_DOWNLOAD_PROVIDER=flacfetch` (default `tornado`; the next CI deploy resets it, so also change the workflow to make it permanent). ## Worker Execution diff --git a/infrastructure/modules/cloud_run.py b/infrastructure/modules/cloud_run.py index 9162d6e9..a812dd67 100644 --- a/infrastructure/modules/cloud_run.py +++ b/infrastructure/modules/cloud_run.py @@ -516,6 +516,18 @@ def create_audio_download_job( ), ), ), + # TornadoAPI key: YouTube downloads try Tornado first, flacfetch is + # the fallback (backend/services/youtube_download_service.py). This job + # does most YouTube downloads; CI wires the same secret on the API service. + cloudrunv2.JobTemplateTemplateContainerEnvArgs( + name="TORNADO_API_KEY", + value_source=cloudrunv2.JobTemplateTemplateContainerEnvValueSourceArgs( + secret_key_ref=cloudrunv2.JobTemplateTemplateContainerEnvValueSourceSecretKeyRefArgs( + secret=f"projects/{PROJECT_ID}/secrets/tornado-api-key", + version="latest", + ), + ), + ), # Flacfetch API URL (public HTTPS endpoint; no VPC egress) cloudrunv2.JobTemplateTemplateContainerEnvArgs( name="FLACFETCH_API_URL", diff --git a/pyproject.toml b/pyproject.toml index 1552119a..9ed0c60a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "karaoke-gen" -version = "0.291.0" +version = "0.291.1" description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens." authors = ["Andrew Beveridge "] license = "MIT"