Skip to content

Fix --purge-offline-worker-metrics - #383

Merged
adinhodovic merged 1 commit into
danihodovic:masterfrom
guidoiaquinti:master
Jun 9, 2026
Merged

Fix --purge-offline-worker-metrics#383
adinhodovic merged 1 commit into
danihodovic:masterfrom
guidoiaquinti:master

Conversation

@guidoiaquinti

Copy link
Copy Markdown
Contributor

I believe this PR fixes the --purge-offline-worker-metrics issue described at #362 so a late worker-offline event does not recreate a purged worker metric.

The bug could happen in this sequence:

  1. A worker is purged, removing its metrics from the exporter registry.
  2. A later worker-offline event arrives for the same hostname.
  3. track_worker_status() recreated celery_worker_up{hostname="old-worker"} 0.0.
  4. Since the worker had already been removed from worker_last_seen, the recreated zero-valued series was no longer eligible for future purge.

Now only online events directly create/update celery_worker_up. Offline events go through forget_worker(), which already no-ops for unknown or already-purged workers.

Note: AI assistance was used during investigation and validation.

@adinhodovic
adinhodovic merged commit ae2a019 into danihodovic:master Jun 9, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants