Repository navigation
Description
Severity: P2 (orphaned workers persist until next ateapi restart)
Component: Control Plane — cmd/ateapi/internal/controlapi/syncer.go
Audit ID: CP-8
Maps to suspect: S2
Summary
reconcileOrphanedWorkers runs once at ateapi startup and paginates through all
worker records. If any store.ListWorkers call returns an error (e.g., Valkey is
intermittently slow during startup), the function returns immediately — skipping all
workers on remaining pages. Those workers' orphaned assignments and stale actors persist
until the next ateapi restart. The function logs the error but does not schedule a retry.
Root Cause
File: cmd/ateapi/internal/controlapi/syncer.go lines 234–270
func (s *WorkerPoolSyncer) reconcileOrphanedWorkers(ctx context.Context) error {
// ...
for {
workers, err := store.ListWorkers(ctx, cursor)
if err != nil {
s.logger.Error("Failed to list workers during startup reconcile", ...)
return err // ABORTS — remaining pages are never processed
}
for _, w := range workers {
if err := s.reconcileDeadWorker(ctx, w); err != nil {
s.logger.Error(...) // individual error: continues
}
}
if !more {
break
}
}
return nil
}Individual reconcileDeadWorker failures (line 267) continue to the next worker, but
a ListWorkers pagination error aborts the entire function.
Steps to Reproduce
- Have many workers in Valkey (enough to span multiple pages, typically > 100).
- Delete all worker pods while ateapi is down.
- Configure Valkey to return a transient error on the second
HSCANcall (use a proxy
or temporarily setmaxmemory-policy = noevictionand fill Valkey to trigger OOM
errors on writes, or use a packet filter timed to fire on the second scan). - Start ateapi; observe in logs:
Failed to list workers during startup reconcile: <error> - Verify workers from the first page are cleaned up; workers from the second+ pages
remain with stale actor assignments:kubectl ate list actors -a <atespace> # Shows actors in STATUS_RUNNING or STATUS_RESUMING that have no running pods
Expected Behavior
A ListWorkers error during startup reconciliation should either:
- Retry the entire reconciliation after a backoff delay, or
- Log a warning and continue to the next cursor position (best-effort reconciliation).
Suggested Fix
Wrap the reconciliation loop in a retry with exponential backoff:
func (s *WorkerPoolSyncer) reconcileOrphanedWorkers(ctx context.Context) {
backoff := wait.Backoff{...}
wait.ExponentialBackoffWithContext(ctx, backoff, func(ctx context.Context) (bool, error) {
err := s.runOrphanReconcilePass(ctx)
if err != nil {
s.logger.Warn("Orphan reconcile pass failed, will retry", "err", err)
return false, nil
}
return true, nil
})
}
Activity
[-]Startup orphan reconciliation aborts on ListWorkers pagination error — ghost workers persist[/-][+][P2] Startup orphan reconciliation aborts on ListWorkers pagination error — ghost workers persist[/+]fix(ateapi): retry stored-worker scan in syncer startup (#772)