Skip to content

add source/destination parity Celery task - #312

Open
maperu wants to merge 3 commits into
masterfrom
maperu/parityMonitor
Open

add source/destination parity Celery task#312
maperu wants to merge 3 commits into
masterfrom
maperu/parityMonitor

Conversation

@maperu

@maperu maperu commented Jun 17, 2026

Copy link
Copy Markdown

Adds check_source_destination_parity to lemur/common/celery.py.

The task does a strict 1:1 label match between sources and destinations and emits:

  • lemur.parity.destinations_missing_source (gauge): count of destination labels with no matching source
  • lemur.parity.sources_missing_destination (gauge): count of source labels with no matching destination
  • lemur.parity.unmatched_destination (counter per label)
  • lemur.parity.unmatched_source (counter per label)

The per-label counters give the Datadog monitor enough breadcrumbs to surface which specific labels are unpaired when an alert fires.

Why this matters: sync_update_destination in lemur/sources/service.py auto-attaches a destination to source-imported certs only when labels match exactly. A renamed source, or a destination added without its discovery counterpart, silently breaks that auto-attach loop. This task makes the drift observable.

Beat scheduling is out of scope here — that lives in k8s-resources/k8s/lemur/chart/config/lemur.conf.py and will be wired up only for commercial/gov (dev/sandbox intentionally has source/destination split after the lemur-dev isolation work).

Part of the P0 "Lemur monitoring gaps" cleanup item.

maperu added 2 commits June 17, 2026 13:51
New `check_source_destination_parity` task emits gauges for the count
of destinations without a same-label source and sources without a
same-label destination, plus per-label counters so a Datadog monitor
can alert on the aggregate and surface which specific labels are
unpaired.

Same-label parity is the contract used by
`sync_update_destination` in lemur/sources/service.py: source-imported
certs are auto-attached to a destination only when the labels match
exactly. Drift (renamed source, destination added without its
discovery counterpart) breaks that auto-attach silently. This task
makes the drift observable.

The task isn't wired into the Celery beat schedule here -- scheduling
goes in k8s-resources/k8s/lemur/chart/config/lemur.conf.py, and only
on commercial/gov (dev/sandbox intentionally has source/destination
split as part of the lemur-dev isolation work).
Splits pure-observability Celery tasks (read DB, emit metrics, no state
change) into their own module. lemur/common/celery.py was mixing
business-logic tasks (cert rotation, source sync) with monitoring
tasks; this PR starts the separation by putting the new
check_source_destination_parity task in lemur/common/monitoring.py.

Existing monitoring-only tasks
(report_celery_last_success_metrics, report_*_task signal handlers)
stay in celery.py for now -- they're referenced by the Celery beat
schedule in k8s-resources by full module path, so moving them is a
coordinated cross-repo change worth doing as a separate cleanup PR.
@maperu
maperu marked this pull request as ready for review June 17, 2026 18:05
@maperu
maperu requested review from a team as code owners June 17, 2026 18:05
Clarify purpose of monitoring tasks in comments.
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