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

Nomad Allocation Reschedule Storm Guard

Monitors HashiCorp Nomad client allocations for rapid reschedule loops, detecting crashing jobs and alerting SRE teams on Slack.

Categories
CoreInfrastructure

In distributed workload environments running HashiCorp Nomad, misconfigured batch jobs, failing container health checks, or node out-of-memory (OOM) evictions can cause task allocations to enter continuous restart loops.

When Nomad's reschedule stanza is configured with aggressive backoff parameters without maximum retry ceilings, the Nomad scheduler repeatedly relocates failing allocations across client nodes in rapid succession. This behavior creates an allocation reschedule storm: client nodes spend excessive CPU cycles pulling Docker images, mounting volumes, and allocating ephemeral ports, quickly exhausting host compute capacity and degrading co-located production workloads.

This blueprint provides an automated orchestration safety guard. Running on a recurrent ten-minute schedule, it interrogates the Nomad Allocations API, counts recent reschedule events and task failure frequencies, evaluates metrics against safe thresholds, and notifies SRE on-call engineers via Slack with exact diagnostic commands.

How it works

  1. Recurrent Pulse Trigger: The audit_nomad_allocations trigger (io.kestra.plugin.core.trigger.Schedule) initiates the audit every ten minutes.
  2. Nomad API Inspection: The scan_rescheduled_allocations task (io.kestra.plugin.scripts.python.Script) queries /v1/allocations, parsing RescheduleTracker events and identifying tasks undergoing repeated restart cycles.
  3. Threshold Gate: The evaluate_reschedule_storm flowable task (io.kestra.plugin.core.flow.If) evaluates whether total reschedule bursts or flapping allocations exceed safe limits.
  4. Slack Incident Alert: When a reschedule storm is confirmed, notify_slack_nomad_storm (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) delivers an actionable incident card detailing the top failing job, client node, and exact CLI diagnostic commands (nomad alloc logs, nomad job stop).
  5. Healthy Confirmation: When reschedule rates remain minimal, log_healthy_nomad_cluster logs nominal cluster stability.
  6. Manifest Export: The export_nomad_reschedule_manifest task records execution state for platform telemetry archives.

Architecture diagram

flowchart TD
    A[Schedule: Every 10 Minutes] --> B[scan_rescheduled_allocations: Nomad Allocations API]
    B --> C{Reschedule Storm Detected?}
    C -- Yes --> D[notify_slack_nomad_storm: Slack Webhook]
    C -- No --> E[log_healthy_nomad_cluster: Log]
    D --> F[export_nomad_reschedule_manifest: Return JSON]
    E --> F

Use cases

  • Flapping Container Detection: Detect applications crashing immediately upon initialization before they consume cluster-wide ephemeral disk or port allocations.
  • Noisy Neighbor Protection: Prevent a single broken task definition from consuming scheduler evaluations and degrading healthy production jobs.
  • Pre-Production Release Validation: Automatically catch canary deployments with broken database credentials or missing environment variables causing instant termination.

Inputs

Name Type Default Description
nomad_addr STRING "http://localhost:4646" Base URL of the HashiCorp Nomad server cluster API endpoint.
max_reschedules_threshold INT 10 Maximum allowable reschedule events across jobs within the window.
evaluation_window_minutes INT 15 Time window in minutes to inspect allocation lifecycle reschedule events.
slack_channel STRING "#sre-orchestration-alerts" Slack channel destination for workload orchestration incident notifications.

Expected outputs

  • {{ outputs.scan_rescheduled_allocations.vars.has_reschedule_storm }}: Boolean flag indicating if an active reschedule storm exists.
  • {{ outputs.scan_rescheduled_allocations.vars.total_reschedules }}: Total count of allocation reschedule events detected.
  • {{ outputs.scan_rescheduled_allocations.vars.flapping_count }}: Number of distinct allocations undergoing flapping behavior.
  • {{ outputs.scan_rescheduled_allocations.vars.top_job }}: Name of the job experiencing the highest restart volume.
  • {{ outputs.scan_rescheduled_allocations.outputFiles['nomad_reschedule_audit.json'] }}: Complete JSON diagnostic report.

Prerequisites

  • Reachable HashiCorp Nomad server or client endpoint with HTTP API enabled.
  • Incoming Webhook URL configured for your Slack SRE alerting channel.

Secrets

  • SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL with permissions to post messages.

Quick start

  1. Configure SLACK_WEBHOOK_URL in your Kestra namespace secrets.
  2. Import this flow YAML into your Kestra workspace.
  3. Update nomad_addr with your cluster URL (e.g., https://nomad.prod.internal:4646).
  4. Execute the flow manually from the Kestra UI to run an initial cluster stability audit.

Common pitfalls and troubleshooting

  • Nomad ACL Tokens: In secured clusters with Nomad ACLs enabled, pass the management or reader token via the X-Nomad-Token HTTP header in requests.
  • Dead Allocations vs Active Flapping: Nomad retains dead allocations for garbage collection (job.trash_after); ensure your query filter targets recent events rather than historical completed jobs.

How to extend

  • Add automated job suspension using PUT /v1/job/<job-id>/pause to quarantine flapping jobs automatically during severe storms.
  • Integrate with PagerDuty for critical alerting when cluster capacity decreases by more than 20%.
  • Forward allocation failure logs directly to Elasticsearch or Loki for automated root-cause clustering.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.