From 74d985b5431bbe57965797d4234c296d412a5bb5 Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Wed, 25 Feb 2026 20:20:36 +0100 Subject: [PATCH] fix: add delay in OnStackStart for status refresh timing The goroutine fires immediately but needs the stack manager's state to reflect 'running' before checking. Co-Authored-By: Claude Opus 4.6 --- controller/internal/integrations/lifecycle.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/controller/internal/integrations/lifecycle.go b/controller/internal/integrations/lifecycle.go index 910bf43..3c60eaa 100644 --- a/controller/internal/integrations/lifecycle.go +++ b/controller/internal/integrations/lifecycle.go @@ -2,6 +2,7 @@ package integrations import ( "context" + "time" "gitea.dooplex.hu/admin/felhom-controller/internal/stacks" ) @@ -56,7 +57,12 @@ func (m *Manager) OnStackStop(_ context.Context, stackName string) { // OnStackStart is called when a stack starts. // Re-applies integrations that were previously enabled but are not currently active. +// Waits briefly for the stack manager to refresh container state. func (m *Manager) OnStackStart(_ context.Context, stackName string) { + // Brief delay so the stack manager's periodic status refresh + // picks up the new container state (runs every 30s). + time.Sleep(5 * time.Second) + m.mu.Lock() defer m.mu.Unlock()