From d2c76c9ac847e5fb18bbb1f5ce3bffc895ed8c4f Mon Sep 17 00:00:00 2001 From: SmokyZone Date: Sat, 24 Oct 2026 23:11:35 +0200 Subject: [PATCH] =?UTF-8?q?W=C3=B6chentlicher=20CronJob=20upgrade-search:?= =?UTF-8?q?=20Sonarr=20SeriesSearch=20+=20Radarr=20CutoffUnmet/Missing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- templates/upgrade-search.yaml | 81 +++++++++++++++++++++++++++++++++++ values.yaml | 6 +++ 2 files changed, 87 insertions(+) create mode 100644 templates/upgrade-search.yaml diff --git a/templates/upgrade-search.yaml b/templates/upgrade-search.yaml new file mode 100644 index 0000000..8c34d66 --- /dev/null +++ b/templates/upgrade-search.yaml @@ -0,0 +1,81 @@ +{{- /* +Weekly upgrade search: makes Sonarr/Radarr actively look for better releases (in practice: +German / German DL instead of English-only files) for everything already in the library. +RSS only sees new uploads, so older episodes would otherwise never be upgraded. + +- Sonarr: SeriesSearch for every monitored series. Sonarr's "Cutoff Unmet" list only looks + at quality, not at custom format scores, so CutoffUnmetEpisodeSearch would find nothing. +- Radarr: CutoffUnmetMoviesSearch (Radarr does consider CF scores) + MissingMoviesSearch. + +The API keys are read at runtime from the apps' config PVCs (mounted read-only), so they +never have to be copied into a Secret or into git. Reuses the Sonarr image (curl + jq). +*/ -}} +{{- if .Values.upgradeSearch.enabled }} +apiVersion: batch/v1 +kind: CronJob +metadata: + name: upgrade-search + namespace: {{ .Values.namespace }} + labels: + app.kubernetes.io/name: upgrade-search +spec: + schedule: {{ .Values.upgradeSearch.schedule | quote }} + timeZone: {{ .Values.common.tz }} + concurrencyPolicy: Forbid + successfulJobsHistoryLimit: 2 + failedJobsHistoryLimit: 2 + jobTemplate: + spec: + backoffLimit: 1 + ttlSecondsAfterFinished: 604800 + template: + metadata: + labels: + app.kubernetes.io/name: upgrade-search + spec: + restartPolicy: Never + securityContext: + runAsUser: {{ .Values.common.puid }} + runAsGroup: {{ .Values.common.pgid }} + containers: + - name: search + image: {{ .Values.apps.sonarr.image }} + command: ["/bin/sh", "-c"] + args: + - | + set -eu + key() { sed -n 's:.*\(.*\).*:\1:p' "$1"; } + cmd() { curl -sf -H "X-Api-Key: $2" -H "Content-Type: application/json" -X POST "$1/api/v3/command" -d "$3" | jq -r '"\(.name): \(.status)"'; } + + S=http://sonarr:8989; SK=$(key /sonarr/config.xml) + for id in $(curl -sf -H "X-Api-Key: $SK" "$S/api/v3/series" | jq -r '.[] | select(.monitored) | .id'); do + cmd "$S" "$SK" "{\"name\":\"SeriesSearch\",\"seriesId\":$id}" + done + + R=http://radarr:7878; RK=$(key /radarr/config.xml) + cmd "$R" "$RK" '{"name":"CutoffUnmetMoviesSearch"}' + cmd "$R" "$RK" '{"name":"MissingMoviesSearch"}' + resources: + requests: + cpu: 10m + memory: 32Mi + limits: + cpu: 200m + memory: 128Mi + volumeMounts: + - name: sonarr-config + mountPath: /sonarr + readOnly: true + - name: radarr-config + mountPath: /radarr + readOnly: true + volumes: + - name: sonarr-config + persistentVolumeClaim: + claimName: sonarr-config + readOnly: true + - name: radarr-config + persistentVolumeClaim: + claimName: radarr-config + readOnly: true +{{- end }} diff --git a/values.yaml b/values.yaml index 8d1db62..c56e491 100644 --- a/values.yaml +++ b/values.yaml @@ -53,6 +53,12 @@ ingress: # StorageClass for the per-app config PVCs, empty = cluster default. storageClassName: "" +# Weekly active search for upgrades (German instead of English-only), see +# templates/upgrade-search.yaml. Sunday 03:00 local time. +upgradeSearch: + enabled: true + schedule: "0 3 * * 0" + initImage: busybox:1.38 apps: