From 2775c73018dbb4242ac04411d8cf2fcd56ea91f9 Mon Sep 17 00:00:00 2001 From: Yuto Nishida Date: Sat, 20 Jun 2026 17:03:57 -0700 Subject: [PATCH] [milky-way][orion-system] add root folders --- .../stage00/orion-system/main.jsonnet | 33 ++++++++++++++++--- milky-way/lib/sonarr.libsonnet | 3 +- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/milky-way/environments/stage00/orion-system/main.jsonnet b/milky-way/environments/stage00/orion-system/main.jsonnet index a67aeaa..3959ff4 100644 --- a/milky-way/environments/stage00/orion-system/main.jsonnet +++ b/milky-way/environments/stage00/orion-system/main.jsonnet @@ -155,7 +155,8 @@ local secrets = import 'milky-way/secrets/k8s-secret-values.jsonnet'; // Sonarr: monitors/grabs TV episodes, hands torrents to qbittorrent // (qbittorrent.default.svc.cluster.local:8080), then imports completed downloads by hardlinking - // them out of /data/downloads/qbittorrent into a library tree (e.g. /data/library/tv) on the + // them out of /data/downloads/qbittorrent into a library tree (/data/library/Animations and + // '/data/library/TV Shows', set as Sonarr root folders via buildarrConfig below) on the // SHARED mdata volume -- same PVC, same /data mount path as qbittorrent, so hardlinks/atomic // moves stay on one filesystem. WebUI via Tailscale L7 ingress; SQLite config on its own iSCSI // RWO PVC. The download-client/indexer links are entered in the UI post-deploy (they need API @@ -204,9 +205,12 @@ local secrets = import 'milky-way/secrets/k8s-secret-values.jsonnet'; update_times: ['%02d:00' % h for h in std.range(0, 23)], }, sonarr: { - // GLOBAL default for all sonarr instances (current + future). MUST stay false -- never - // clobber download clients added by hand in Sonarr's UI. - settings: { download_clients: { delete_unmanaged: false } }, + // GLOBAL defaults for all sonarr instances (current + future). MUST stay false -- never + // clobber download clients (or root folders) added by hand in Sonarr's UI. + settings: { + download_clients: { delete_unmanaged: false }, + media_management: { delete_unmanaged_root_folders: false }, + }, instances: { [sonarrOrionSystemInstanceName]: { hostname: utils.domainOfService(this.sonarr.service), @@ -227,6 +231,27 @@ local secrets = import 'milky-way/secrets/k8s-secret-values.jsonnet'; }, }, }, + media_management: { + delete_unmanaged_root_folders: false, // also explicit per-instance (belt & suspenders) + // These root folders are paths INSIDE the Sonarr container -- the `mdata` PVC, which + // Sonarr mounts at /data (matching qbittorrent so hardlinks stay on one fs). Pin + // volumeMounts[1] as the media mount, then assert that mount is /data, so a future + // mediaMountPath change (or a reordered/renamed mount) fails at evaluation instead of + // silently leaving these root folders pointing where Sonarr no longer mounts (its API + // rejects a non-existent path). The paths below stay LITERAL on purpose -- they must + // not auto-follow an accidental mountPath change. + local mediaMount = utils.assertAndReturn( + this.sonarr.deployment.spec.template.spec.containers[0].volumeMounts[1], + function(m) m.name == 'media', + 'sonarr volumeMounts[1] must be the media mount for these buildarr root_folders', + ), + assert mediaMount.mountPath == '/data' : + 'sonarr media mount must be at /data for these buildarr root_folders to resolve', + root_folders: [ + '/data/library/Animations', + '/data/library/TV Shows', + ], + }, }, }, }, diff --git a/milky-way/lib/sonarr.libsonnet b/milky-way/lib/sonarr.libsonnet index c8e8e90..4fba6da 100644 --- a/milky-way/lib/sonarr.libsonnet +++ b/milky-way/lib/sonarr.libsonnet @@ -13,7 +13,8 @@ local images = import 'milky-way/lib/images.libsonnet'; // pod must release the volume before a new one mounts it, hence strategy: Recreate. Media lives on // the SHARED `mdata` RWX-NFS PVC (the same one qbittorrent mounts), mounted here at the same path // so that downloads (/downloads/qbittorrent) and the library tree -// (/library/tv) are one filesystem -- hardlinks and atomic moves require that. +// (/library/{Animations,TV Shows}, set as Sonarr root folders via buildarr) are +// one filesystem -- hardlinks and atomic moves require that. // // Config that we pin declaratively via servarr env overrides (SONARR__
__, double // underscore; they win over config.xml on every boot): the API key (from a Secret, so it's stable -- 2.54.0