Task · MDE-0059

Reserve manual collector triggers before scheduling background tasks

Description

Audit dimension 2 confirmed a live admission race at the v2.0.0 release tree. src/meraki_dashboard_exporter/app.py:1350-1363 checks CollectorManager.is_collector_running and then creates a background task. asyncio.create_task does not start the coroutine before the handler returns, so concurrent authenticated requests can all pass the check, each return started, and accumulate one task per request. CollectorManager later suppresses duplicate execution at collectors/manager.py:819-839, but only after those tasks begin. Existing endpoint tests cover the already-running state and a single mocked task, not concurrent real requests or task cleanup.

Acceptance Criteria

Definition of Done

Implementation Plan

Write a real concurrent authenticated-trigger regression plus completion, cancellation and failure cleanup coverage; install a synchronous per-collector reservation before task creation and clear it on every terminal path.

Final Summary

Reserved manual collector triggers synchronously before scheduling background work and released reservations on scheduling failure. Both intended regressions failed before the fix; just check and just ci passed at 5e8d9c23b76a2f2edd531c15c776cbfbcc9134fa; exact-head CI 33843833956 and publication 33843966820 succeeded.

View the source file on GitHub