fix(archied): load and report EDA playbooks at start instead of at the first dispatch

This commit is contained in:
sam committed 2026-10-13 17:22:01 +11:00
1 parent aa23cce23e
commit 48371f3291
3 files changed
+28 -6

No files matched your search

+9 -6
View File
@@ -67,9 +67,10 @@ import (
// reverse at shutdown, matching the LIFO ordering of the deferred calls
// they replace.
type boot struct {
catalog *modelcatalog.Catalog
cfg config.Config
log *slog.Logger
catalog *modelcatalog.Catalog
cfg config.Config
log *slog.Logger
playbooks *controlplane.LivePlaybooks
// stderrLog keeps setupLogging on stderr, never touching cfg.Log.File. An
// offline command reads the bootstrap config but is not the daemon: creating
@@ -864,7 +865,9 @@ func (b *boot) startModelCatalogRefresh(ctx context.Context) {
}
func (b *boot) livePlaybooks() *controlplane.LivePlaybooks {
live := controlplane.NewLivePlaybooks(b.controlPlaneRPC, b.log)
live.ApplyStatus = b.applyStatus
return live
b.playbooks = controlplane.NewLivePlaybooks(b.controlPlaneRPC, b.log)
b.playbooks.ApplyStatus = b.applyStatus
return b.playbooks
}
const playbookRefreshInterval = 30 * time.Second
+1
View File
@@ -207,6 +207,7 @@ func Run() int { //nolint:cyclop,funlen // the composition root's setup sequence
}
b.buildDaemon()
b.playbooks.Keep(ctx, playbookRefreshInterval)
b.wireConfigSurfaces(ctx, args.cfgPath, args.overlayPath)
if err := b.startServices(ctx); err != nil {
@@ -41,6 +41,24 @@ func NewLivePlaybooks(client pb.ControlPlaneServiceClient, log *slog.Logger) *Li
return &LivePlaybooks{rpc: client, log: log, orgs: map[org.OrgID]*orgPlaybooks{}}
}
// Keep loads the default org's playbooks now and every interval after, so the
// apply status is reported without waiting for the first dispatch.
func (l *LivePlaybooks) Keep(ctx context.Context, interval time.Duration) {
l.current(ctx)
go func() {
ticker := time.NewTicker(interval)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
l.current(ctx)
}
}
}()
}
// current reads the playbooks of the org ctx acts in; the query carries that
// org, so a task is matched against its own org's document.
func (l *LivePlaybooks) current(ctx context.Context) *playbook.Store {