Skip to content

Add a connectivity heartbeat between full speed test cycles - #23

Open
ashleigh-byte wants to merge 2 commits into
Role1776:mainfrom
ashleigh-byte:connectivity-heartbeat
Open

Add a connectivity heartbeat between full speed test cycles#23
ashleigh-byte wants to merge 2 commits into
Role1776:mainfrom
ashleigh-byte:connectivity-heartbeat

Conversation

@ashleigh-byte

Copy link
Copy Markdown
Contributor

SLEEP_TIME (default 1800s / 30 min) means a real outage could start and fully resolve between two full speed test cycles without ever triggering the existing outage/degradation alerting, which only samples once per cycle. This adds a lightweight check in between.

  • Runner.ping_host(): a TCP connect to host:port, timed, returning None on failure/timeout. Uses TCP rather than ICMP specifically to avoid needing raw-socket (root) privileges this tool doesn't otherwise require.
  • New config: HEARTBEAT_HOST (default 1.1.1.1), HEARTBEAT_PORT (443), HEARTBEAT_INTERVAL_SECONDS (60), HEARTBEAT_CONSECUTIVE_FAILURES (3).
  • _wait_with_heartbeat() replaces the plain time.sleep(SLEEP_TIME) at the end of the main loop, sleeping in HEARTBEAT_INTERVAL_SECONDS chunks and pinging after each one. Alerts once after N consecutive failures, again on recovery with duration -- same alert-once-per- episode pattern as the existing outage alerting.
  • Deliberately single-threaded (chunked sleep, not a background thread), consistent with the rest of this codebase and avoiding any concurrency concerns with the shared sqlite connection or notifier HTTP calls.

SLEEP_TIME (default 1800s / 30 min) means a real outage could start and
fully resolve between two full speed test cycles without ever
triggering the existing outage/degradation alerting, which only
samples once per cycle. This adds a lightweight check in between.

- Runner.ping_host(): a TCP connect to host:port, timed, returning None
  on failure/timeout. Uses TCP rather than ICMP specifically to avoid
  needing raw-socket (root) privileges this tool doesn't otherwise
  require.
- New config: HEARTBEAT_HOST (default 1.1.1.1), HEARTBEAT_PORT (443),
  HEARTBEAT_INTERVAL_SECONDS (60), HEARTBEAT_CONSECUTIVE_FAILURES (3).
- _wait_with_heartbeat() replaces the plain time.sleep(SLEEP_TIME) at
  the end of the main loop, sleeping in HEARTBEAT_INTERVAL_SECONDS
  chunks and pinging after each one. Alerts once after N consecutive
  failures, again on recovery with duration -- same alert-once-per-
  episode pattern as the existing outage alerting.
- Deliberately single-threaded (chunked sleep, not a background
  thread), consistent with the rest of this codebase and avoiding any
  concurrency concerns with the shared sqlite connection or notifier
  HTTP calls.

Test plan:
- Unit-tested ping_host: successful TCP connect against a real local
  listener, refused connection, and timeout against a non-routable
  address (verified it respects the timeout rather than hanging)
- Unit-tested HEARTBEAT_* config validation (defaults, overrides, port
  range boundaries)
- Unit-tested _wait_with_heartbeat: chunking arithmetic (total_seconds
  correctly split into interval-sized chunks), exactly one down alert
  and one recovery alert per episode, sub-interval total_seconds
  producing a single chunk, and below-threshold failures never
  alerting
Adds a Connectivity Heartbeat section explaining the TCP-connect check
and its four new env vars.
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.

1 participant