Skip to content

chore(orchestrator): Replace per-visit sweep logs with a heartbeat - #419

Open
morgan-wowk wants to merge 1 commit into
masterfrom
orchestrator-quiet-running-sweep
Open

morgan-wowk wants to merge 1 commit into
masterfrom
orchestrator-quiet-running-sweep

Conversation

@morgan-wowk

@morgan-wowk morgan-wowk commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Each visit of the running sweep logs three INFO lines, even when nothing changed. At 300–1000 active executions, that is tens of lines per second of noise. If the sweep hangs, the flood just stops, and nothing makes that easy to alert on.

Objective

Log only what carries information. The per-visit durations now come from the container_execution.refresh.duration metric added in #425.

sequenceDiagram
    participant Sweep as Orchestrator sweep
    participant Logs
    participant Metrics

    loop Every running container execution visit
        Sweep->>Metrics: refresh.duration (queries, processing)
        alt Queries or processing over 1s
            Sweep->>Logs: Slow running container execution visit
        else Normal visit
            Note over Sweep,Logs: No log line (before: 3 INFO lines)
        end
    end
    Sweep->>Logs: Orchestrator heartbeat, about once a minute, with queued and running counts
    Note over Logs: A missing heartbeat means the sweep stopped
Loading

Changes

  • Removes the three per-visit INFO lines: Before processing …, … remains in RUNNING state. and After processing ….
  • Adds Slow running container execution visit (queries: …ms, processing: …ms). It is logged only when either part takes over 1s, the same threshold the idle-queue log uses.
  • Adds Orchestrator heartbeat: processed N queued executions and M running container executions in the last 60s. It is logged even when both queues are idle.
  • State changes, terminations, cancellations, retries, exceptions and the orchestrator.process_running_execution span are unchanged.

Testing

  • pytest tests: 584 passed. TestHeartbeat covers an idle heartbeat and the counts resetting.
  • No test or downstream code matches on the removed messages.

@morgan-wowk
morgan-wowk requested a review from a team October 30, 2026 23:18
@morgan-wowk
morgan-wowk requested a review from Ark-kun as a code owner October 30, 2026 23:18
@morgan-wowk
morgan-wowk force-pushed the orchestrator-quiet-running-sweep branch from 4ebb687 to ac47a1e Compare October 30, 2026 23:29
_logger.info(
f"Before processing running container execution. Queries duration {queries_duration_ms}ms."
)
start_timestamp = time.monotonic_ns()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is moving this start_timestamp here intentional and any beahviour changes?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI-assisted: Yes, intentional. start_timestamp used to be set before the execution-node-IDs query, so that query was counted in both queries_duration_ms and the processing duration. Setting it after the queries makes the two numbers in the slow-visit line separate, which tells a slow database apart from a slow launcher. No other behaviour changes: duration_ms only feeds that log line.

Also added in f0daa92: a once-a-minute heartbeat (Orchestrator heartbeat: processed N queued executions and M running container executions in the last 60s.). The per-visit lines we removed were the only sign the sweep was alive, so the heartbeat keeps that signal at one line a minute. If it stops appearing, the sweep has stopped.

@morgan-wowk
morgan-wowk force-pushed the orchestrator-quiet-running-sweep branch from ac47a1e to f0daa92 Compare October 30, 2026 23:42
@morgan-wowk morgan-wowk changed the title chore(orchestrator): Stop logging every running container execution visit chore(orchestrator): Replace per-visit sweep logs with a heartbeat Oct 30, 2026
@morgan-wowk
morgan-wowk force-pushed the orchestrator-quiet-running-sweep branch from f0daa92 to 4d8615d Compare November 2, 2026 22:42
@morgan-wowk
morgan-wowk changed the base branch from master to orchestrator-sweep-metrics November 2, 2026 22:42
@morgan-wowk
morgan-wowk force-pushed the orchestrator-sweep-metrics branch from 9f0aa73 to d7b523d Compare November 2, 2026 22:47
@morgan-wowk
morgan-wowk force-pushed the orchestrator-quiet-running-sweep branch from 4d8615d to 27ead6d Compare November 2, 2026 22:47
@morgan-wowk
morgan-wowk force-pushed the orchestrator-sweep-metrics branch from d7b523d to 75a55e6 Compare November 2, 2026 22:49
@morgan-wowk
morgan-wowk force-pushed the orchestrator-quiet-running-sweep branch from 27ead6d to 227f42a Compare November 2, 2026 22:49
@morgan-wowk
morgan-wowk force-pushed the orchestrator-sweep-metrics branch from 75a55e6 to 89b07cc Compare November 2, 2026 22:52
@morgan-wowk
morgan-wowk force-pushed the orchestrator-quiet-running-sweep branch from 227f42a to 6f573cb Compare November 2, 2026 22:53
@morgan-wowk
morgan-wowk force-pushed the orchestrator-sweep-metrics branch from 89b07cc to 8da2f52 Compare November 3, 2026 00:40
@morgan-wowk
morgan-wowk force-pushed the orchestrator-quiet-running-sweep branch from 6f573cb to 1dbfb6d Compare November 3, 2026 00:41
@morgan-wowk
morgan-wowk force-pushed the orchestrator-sweep-metrics branch from 8da2f52 to aa4bb4e Compare November 3, 2026 03:51
@morgan-wowk
morgan-wowk force-pushed the orchestrator-quiet-running-sweep branch from 1dbfb6d to 99b4d85 Compare November 3, 2026 03:51
The running queue visits every pending or running container execution
round-robin, and each visit logged three INFO lines even when nothing
changed. With hundreds of active executions that is tens of lines per
second carrying no information.

Drop the "Before processing", "After processing" and "remains in state"
lines. Log one line only when a visit is slow: its queries or its
processing take over 1s, matching the existing slow-query threshold for
the idle queue log. The queries and processing times stay separate so a
slow database is distinguishable from a slow launcher.

Add a heartbeat line about once a minute from process_each_queue_once
with the number of queued and running executions processed since the
last one. The per-visit lines were the only sign that the sweep was
still going; the heartbeat keeps that signal at one line a minute, and
its absence means the sweep has stopped. State changes, terminations,
retries and errors keep their existing logs.
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