Skip to content

fix(arrs): stop queue cleanup worker when arrs is disabled at runtime#619

Merged
javi11 merged 1 commit into
mainfrom
session/jolly-euler-01b098
May 26, 2026
Merged

fix(arrs): stop queue cleanup worker when arrs is disabled at runtime#619
javi11 merged 1 commit into
mainfrom
session/jolly-euler-01b098

Conversation

@javi11
Copy link
Copy Markdown
Owner

@javi11 javi11 commented May 26, 2026

Summary

  • Toggling arrs.enabled (or arrs.queue_cleanup_enabled) off via config previously did not stop the already-running queue cleanup worker. It kept ticking on its configured interval and logging Failed to cleanup Sonarr queue against the now-disabled Sonarr/Radarr instances.
  • Root cause: the gate check lived only in Worker.Start (internal/arrs/worker/worker.go); there was no OnConfigChange handler for the ARR subsystem, unlike the health subsystem which already does this.
  • Fix mirrors the existing pattern in internal/health/controller.go:
    • New Service.RegisterConfigChangeHandler subscribes to config changes and starts/stops the worker when arrs.enabled or arrs.queue_cleanup_enabled flips.
    • New exported helper worker.IsQueueCleanupEnabled(cfg) centralizes the predicate.
    • Defensive early-return at the top of Worker.CleanupQueue so any in-flight tick after a disable no-ops cleanly.
    • Wired the handler in cmd/altmount/cmd/serve.go right after StartWorker, alongside the other OnConfigChange registrations.

Test plan

  • Start with arrs.enabled: true and a reachable Sonarr instance — confirm ARR queue cleanup worker started appears.
  • Set arrs.enabled: false (config.yaml or UI). Expect ARR worker disabled via config change, stopping followed by ARR queue cleanup worker stopped, and no further Failed to cleanup Sonarr queue warnings on subsequent ticks.
  • Toggle back to true. Expect ARR worker enabled via config change, starting and the worker resumes.
  • Verify the queue_cleanup_enabled: false sub-toggle (while arrs.enabled stays true) produces the same stop/start behavior.
  • go build ./... and go vet ./... pass (verified locally).

Toggling arrs.enabled (or arrs.queue_cleanup_enabled) off via config did
not stop the already-running queue cleanup worker, so it kept ticking and
logging "Failed to cleanup Sonarr queue" against now-disabled instances.

Register an OnConfigChange handler on the arrs service that starts/stops
the worker when either flag flips, and add a defensive runtime gate in
CleanupQueue so any in-flight tick after a disable no-ops cleanly. Mirrors
the existing pattern in internal/health/controller.go.
@javi11 javi11 merged commit 84edb5f into main May 26, 2026
2 checks passed
@javi11 javi11 deleted the session/jolly-euler-01b098 branch May 26, 2026 07:15
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.

1 participant