fix(arrs): stop queue cleanup worker when arrs is disabled at runtime#619
Merged
Conversation
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.
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.
Summary
arrs.enabled(orarrs.queue_cleanup_enabled) off via config previously did not stop the already-running queue cleanup worker. It kept ticking on its configured interval and loggingFailed to cleanup Sonarr queueagainst the now-disabled Sonarr/Radarr instances.Worker.Start(internal/arrs/worker/worker.go); there was noOnConfigChangehandler for the ARR subsystem, unlike the health subsystem which already does this.internal/health/controller.go:Service.RegisterConfigChangeHandlersubscribes to config changes and starts/stops the worker whenarrs.enabledorarrs.queue_cleanup_enabledflips.worker.IsQueueCleanupEnabled(cfg)centralizes the predicate.Worker.CleanupQueueso any in-flight tick after a disable no-ops cleanly.cmd/altmount/cmd/serve.goright afterStartWorker, alongside the otherOnConfigChangeregistrations.Test plan
arrs.enabled: trueand a reachable Sonarr instance — confirmARR queue cleanup worker startedappears.arrs.enabled: false(config.yaml or UI). ExpectARR worker disabled via config change, stoppingfollowed byARR queue cleanup worker stopped, and no furtherFailed to cleanup Sonarr queuewarnings on subsequent ticks.true. ExpectARR worker enabled via config change, startingand the worker resumes.queue_cleanup_enabled: falsesub-toggle (whilearrs.enabledstays true) produces the same stop/start behavior.go build ./...andgo vet ./...pass (verified locally).