Script icon
Docker icon
If icon
SlackIncomingWebhook icon
Log icon
Return icon
Schedule icon

Corosync Totem Token Timeout and Quorum Loss Sentinel

Monitors Corosync Totem token retransmissions and ring failure events to prevent split-brain fencing storms and pacemaker quorum loss.

Categories
CoreInfrastructure

Audits Corosync cluster membership engine telemetry across high-availability database and virtualization nodes to detect Totem token timeouts, ring link degradation, and quorum loss.

How it works

  1. A schedule trigger executes the HA cluster audit workflow every 15 minutes.
  2. The Python task queries the Corosync Prometheus exporter endpoint (corosync-exporter:9221).
  3. The script extracts cumulative Totem token retransmissions, redundant ring health indicators, active node votes, and quorate flags.
  4. An evaluation gate determines whether token retransmit rates or ring link failures breach operational thresholds.
  5. When thresholds are breached, a high-priority Slack alert is dispatched to high-availability engineering teams.
  6. When Corosync rings circulate membership tokens cleanly without retransmissions, nominal telemetry is logged.
  7. A structured JSON audit manifest is emitted for enterprise high-availability compliance and fencing history archives.

Architecture diagram

graph TD
    Trigger[Schedule Trigger: 15m] --> ScanMetrics[Python Script: Scrape Corosync Exporter Metrics]
    ScanMetrics --> EvalBreach{Retransmits >= Threshold OR Ring Degraded OR Not Quorate?}
    EvalBreach -- Yes --> SlackAlert[Slack: High-Urgency HA Alert]
    EvalBreach -- No --> LogNominal[Log: Nominal Corosync Quorum State]
    SlackAlert --> EmitManifest[Debug Return: Corosync Audit Manifest]
    LogNominal --> EmitManifest

Architecture components

  • Trigger: Automated schedule polling at 15-minute intervals.
  • Script Task: Scrapes Corosync Prometheus exporter metrics using Docker container isolation.
  • Decision Gate: Evaluates whether Totem token retransmission storms exceed stability safety bounds.
  • Notification Task: Dispatches structured Slack alerts with cluster identity and quorum metrics.
  • Audit Manifest: Emits JSON execution payloads containing membership ring telemetry and timestamps.

Key capabilities

  • Continuous surveillance of Corosync Totem single-ring and Kronos redundant-ring protocols.
  • Rapid detection of network latency jitter causing heartbeat packet drops and token loss.
  • Early warning before Pacemaker fencing agents (STONITH) trigger catastrophic node reboots.
  • Zero external dependency execution via isolated containerized Python runners.

What you get

  • Preemptive alerting on high-availability cluster heartbeat degradation before split-brain occurs.
  • Automated detection of secondary ring communication drops in multi-homed clusters.
  • Real-time audit manifests capturing quorum vote distribution for compliance logs.
  • Configurable tolerance thresholds adaptable to 2-node, 3-node, and qdevice cluster topologies.

Who it's for

  • Linux systems engineers managing Pacemaker/Corosync active-passive and active-active clusters.
  • Database administrators maintaining high-availability PostgreSQL and MariaDB clusters.
  • Virtualization engineers operating Proxmox VE and oVirt high-availability compute clusters.
  • SREs overseeing critical bare-metal firewall and load balancer gateway failover pairs.

Why orchestrate this with Kestra

  • Deterministic Scheduling: Guarantees regular ring health audits without fragile local host crontabs.
  • Containerized Runners: Runs Python tasks inside isolated Docker containers without host package conflicts.
  • Condition Branching: Flowable If tasks route alerts and nominal logging cleanly without spaghetti code.
  • Enterprise Secret Safety: Securely injects Slack webhook credentials without plain-text exposure.

Use cases

  • Network Switch Port Flapping: Detects packet drops causing Corosync to continuously retransmit tokens.
  • STONITH Fencing Storm: Alerts before transient network partitions trigger cascading server power reboots.
  • Redundant Ring Failure (RRP): Identifies failure of ring 1 while ring 0 still maintains quorum.
  • QDevice Quorum Drop: Surfaces connectivity loss to external quorum tie-breaker arbitration nodes.

Inputs

Name Type Default Description
corosync_metrics_url STRING http://corosync-exporter.ha.svc.cluster.local:9221 Base HTTP URL exposing Corosync Prometheus metrics.
cluster_name STRING ha-database-cluster-prod Target Corosync cluster identifier under surveillance.
max_token_retransmits_threshold INT 5 Maximum allowable token retransmits before alerting.
lookback_minutes INT 15 Lookback evaluation window in minutes for error accumulation.
alert_on_token_timeouts BOOL true Toggle Slack alert dispatch upon detecting token timeouts.

Expected outputs

  • {{ outputs.scan_corosync_ring_metrics.vars.token_retransmits_count }}: Cumulative count of Totem token retransmissions.
  • {{ outputs.scan_corosync_ring_metrics.vars.is_ring_healthy }}: Boolean flag indicating cluster ring communication health.
  • {{ outputs.scan_corosync_ring_metrics.vars.active_quorum_votes }}: Total number of active quorum votes present in ring.
  • {{ outputs.scan_corosync_ring_metrics.vars.is_quorate }}: Boolean flag indicating if cluster maintains valid quorum.
  • {{ outputs.scan_corosync_ring_metrics.vars.is_alerting }}: Boolean flag indicating whether failure thresholds were breached.
  • {{ outputs.emit_audit_manifest.value }}: Structured JSON audit manifest emitted for compliance archives.

Prerequisites

  • Corosync daemon deployed with corosync_exporter or cmap statistics tool active on cluster nodes.
  • Exporter port 9221 reachable from the Kestra worker execution environment.
  • Docker daemon running on the Kestra host to execute containerized Python tasks.

Secrets

  • SLACK_WEBHOOK_URL: Incoming webhook URL for the target High Availability Slack alerting channel.

Quick start

  1. Verify that corosync_exporter is running and querying corosync-cmapctl.
  2. Configure the SLACK_WEBHOOK_URL secret in your Kestra namespace settings.
  3. Specify your production cluster name in cluster_name.
  4. Execute a manual test run via the Kestra UI to verify metric ingestion.
  5. Enable the periodic_corosync_audit trigger to establish automated continuous surveillance.

Common pitfalls and troubleshooting

  • Token Timeout Tuning: High network latency requires tuning token: 3000 (ms) in corosync.conf.
  • Multicast vs Knet Unicast: Modern clusters should use knet transport instead of legacy UDP multicast.
  • Two-Node Quorum Tie: Two-node clusters must configure wait_for_all: 1 or use a QDevice to avoid deadlocks.
  • IGMP Snooping Drops: Network switches with IGMP snooping can drop Corosync multicast discovery packets.

How to extend

  • Automated Cmap Diagnostics: Trigger a task to capture corosync-cfgtool -s diagnostics when token storms occur.
  • Pacemaker Resource Migration: Chain a graceful resource failover sub-flow when a node exhibits degraded ring health.
  • PagerDuty Escalation: Escalate immediately to infrastructure on-call engineers if cluster quorum is lost.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.