admin/maintenance: report whether the running manager queues a task type

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-11-27 13:33:26 -08:00
1 parent e01133bfa3
commit 97a6daa2a6
2 files changed
+27

No files matched your search

@@ -176,6 +176,11 @@ func (mm *MaintenanceManager) IsRunning() bool {
return mm.running
}
// IsTaskTypeEnabled reports whether the running manager queues tasks of taskType.
func (mm *MaintenanceManager) IsTaskTypeEnabled(taskType MaintenanceTaskType) bool {
return mm.IsRunning() && IsTaskEnabled(mm.scanner.policy, taskType)
}
// Stop terminates the maintenance manager. It is a no-op when the manager is not
// running, so a second call cannot close the already closed stop channel.
func (mm *MaintenanceManager) Stop() {
@@ -138,3 +138,25 @@ func TestMaintenanceManager_LogThrottling(t *testing.T) {
t.Errorf("Expected error count to be 25, got %d", manager.errorCount)
}
}
func TestMaintenanceManager_IsTaskTypeEnabled(t *testing.T) {
config := DefaultMaintenanceConfig()
config.Policy = &MaintenancePolicy{TaskPolicies: map[string]*TaskPolicy{
"ec_balance": {Enabled: true},
"vacuum": {Enabled: false},
}}
manager := NewMaintenanceManager(nil, config, nil)
if manager.IsTaskTypeEnabled("ec_balance") {
t.Fatal("a stopped manager queues nothing")
}
manager.mutex.Lock()
manager.running = true
manager.mutex.Unlock()
if !manager.IsTaskTypeEnabled("ec_balance") {
t.Fatal("ec_balance is enabled in the policy")
}
if manager.IsTaskTypeEnabled("vacuum") || manager.IsTaskTypeEnabled("balance") {
t.Fatal("disabled and missing task types are not enabled")
}
}