docs(media): document plex library scan triggers and regression check - #1493
Merged
Conversation
Radarr/Sonarr Plex Connect notifications and Plex's hourly periodic scan were both off, so nothing rescanned Plex's library since the last manual scan on 2026-06-19. Documents the fix (app settings, not GitOps) and the counterfactual check to detect a regression.
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.
Intent
Restore Plex library scanning so newly imported movies (and the captain's own films, invisible for 71 days) become visible again, and clear stale Plex database entries.
What was wrong: Plex had no library-scan trigger of any kind (never configured since first boot). Last manual scan was 2026-06-19T00:44:21Z. 96 movies imported by Radarr since then were invisible in Plex; 11 existing Plex entries pointed at files deleted by Radarr upgrades. No media files were ever lost - all on the NAS - Plex just never rescanned.
Fix applied (application settings only, not GitOps):
Verified: Movies library went from 635 to 730 entries (731 movie folders exist on disk; the 1-off is a pre-existing .VOB DVD rip that Plex does not scan, unrelated to this fault and out of scope). All 11 previously-dead file-path entries are gone (0 missing files found by checking every current Plex movie file path against disk). Commands and counts used for verification are documented in docs/media-stack.md.
Durable documentation: added a 'Library scan triggers' section to docs/media-stack.md recording what was changed, why it's invisible to GitOps (lives in each app's own database, lost on a config-volume rebuild), and a counterfactual check (disk folder count vs Plex library size vs scannedAt age) to detect a future regression of this same fault.
Constraints honored: no media files deleted, no storage layout changes, no quality-profile changes (those are explicitly out of scope, tracked separately in the outage-scout report's other findings), no GitOps manifest changes needed since this fix is entirely application state (Radarr/Sonarr Connect settings + Plex preferences), applied directly via each app's REST API using credentials read from cluster secrets and never printed.
What Changed
docs/media-stack.mdcovering the Radarr/Sonarr Connect notification and hourly scheduled library update that were configured out-of-band (not GitOps), and why FSEvent scanning stays off for NFS media.totalSizevsscannedAtage) and a note on the media-flow diagram that Plex needs Connect + scheduled updates rather than NFS filesystem events.Risk Assessment
✅ Low: Docs-only change that correctly records the application-state fix and now provides a working counterfactual check; no runtime or GitOps surface is altered.
Testing
Re-ran live Plex/Radarr/Sonarr checks after the docs totalSize fix: Movies totalSize is 734 near 736 on-disk folders (up from 635; still tracking new imports), scannedAt is fresh (2026-08-29T15:04:28Z), Connect notifications and hourly scheduled updates are present with FSEvent left off, every checked media Part path exists on disk, and the documented Size=0 counterfactual no longer reports a false empty library.
Evidence: Live plex scan-trigger verification summary
folder_count=736 totalSize="734" size="0" # would be wrong operator signal if grepped alone Movies scannedAt="1788015868" (2026-08-29T15:04:28Z) missing_paths=0/733 radarr: Plex Media Server host=plex.media.svc.cluster.local:32400 onDownload/Upgrade/Rename/MovieDelete=True/True/True/True sonarr: Plex Media Server host=plex.media.svc.cluster.local:32400 onDownload/Upgrade/Rename/EpisodeFileDelete=True/True/True/True ScheduledLibraryUpdatesEnabled=1 FSEvent=offEvidence: Full live verification write-up
Evidence: Missing Part path check
unique_paths=733 missing=0Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
docs/media-stack.md:299- The regression counterfactual does not actually implement the comparison it describes. (1) PLEX_TOKEN is extracted but never used; the curl still has a literal X-Plex-Token: <token> placeholder. (2) The grep keeps the full PlexOnlineToken="..." attribute text, so even wiring $PLEX_TOKEN would send a bad header. (3) Commands only print disk folder count plus title/scannedAt; nothing retrieves Plex library size/entry count, so operators cannot 'compare folder count against library size'. Fix the token extract (value only), pass it into curl, and add a size/totalSize query (or drop the size claim and document scannedAt-only detection).docs/media-stack.md:273- 'Full incident evidence: the 2026-08-29 scout report referenced from this repo's task history' points at non-repo task history, so future readers cannot follow it. Prefer an in-repo path, omit the dangling pointer, or inline the few durable facts already stated.🔧 Fix: Fix Plex counterfactual token and size check
✅ Re-checked - no issues remain.
🔧 **Test** - 1 issue found → auto-fixed ✅
docs/media-stack.md:308- The durable counterfactual check queries/library/sections/1/all?X-Plex-Container-Start=0&X-Plex-Container-Size=0and grepsMediaContainer...size=. Live against the fixed cluster that exact command returnsMediaContainer size="0"while the real library count istotalSize="730"(730 present paths, 731 folders). An operator following the doc would falsely conclude the library is empty. Fix by greppingtotalSize=(with Size=0) or dropping the zero page size and usingsize=.kubectl -n media exec deploy/plexlibrary counterfactual from docs/media-stack.md (folder count, sections scannedAt,/allsize/totalSize)kubectl -n media exec deploy/plexPreferences//:/prefsfor ScheduledLibraryUpdatesEnabled=1, ScheduledLibraryUpdateInterval=3600, FSEventLibraryUpdatesEnabled=0, autoEmptyTrash=1kubectl -n media exec deploy/plexabsolute media path existence check (730 present, 0 missing)kubectl -n downloads exec deploy/radarrGET/api/v3/notificationPlexServer Connect flags/hostkubectl -n downloads exec deploy/sonarrGET/api/v3/notificationPlexServer Connect flags/host🔧 Fix: Fix Plex counterfactual check to use totalSize
✅ Re-checked - no issues remain.
Live docs counterfactual against plex.media: diskfind /data/nas-media/Movies -mindepth 1 -maxdepth 1 -type d | wc -lvs/library/sections/1/all?X-Plex-Container-Size=0totalSize vs size, plus/library/sectionsscannedAtPlex Preferences.xml for ScheduledLibraryUpdatesEnabled / FSEventLibraryUpdatesEnabledRadarrGET /api/v3/notificationPlexServer Connect fields and onDownload/Upgrade/Rename/MovieDeleteSonarrGET /api/v3/notificationPlexServer Connect fields and onDownload/Upgrade/Rename/EpisodeFileDeletePart file= path existence check inside plex pod (733 unique paths, missing=0)Confirmeddocs/media-stack.mdcounterfactual greps totalSize after prior auto-fix✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.