Skip to content

feat(nomad): support HA mode with multiple servers#191

Open
aleksclark wants to merge 1 commit into
mainfrom
nomad-ha
Open

feat(nomad): support HA mode with multiple servers#191
aleksclark wants to merge 1 commit into
mainfrom
nomad-ha

Conversation

@aleksclark

Copy link
Copy Markdown
Collaborator

Summary

  • Add sticky failover across multiple Nomad server addresses so the integration keeps working when the Raft leader or an individual server is unreachable — essential for HA Nomad deployments.
  • Accept a new addresses credential (comma- or newline-separated, env NOMAD_ADDRS) alongside the existing address; values are parsed, trailing-slash-trimmed, deduplicated, and order-preserved. Fully backward compatible — single address / NOMAD_ADDR behaves exactly as before.
  • Failover retries the next server on transport errors and retryable 5xx/429, but returns definitive 4xx responses immediately (no pointless retry); request bodies are buffered once and replayed across attempts. preferred server index advances stickily so a downed server isn't retried on every call.

Details

  • integrations/nomad/nomad.go: nomad struct now holds addresses []string + preferred atomic.Uint32; split doRequest into a failover loop over doRequestTo; added parseAddresses, apiError, shouldFailover, plus Placeholders()/OptionalKeys() for web-UI guidance.
  • config/config.go: added addresses default credential and addresses → NOMAD_ADDRS env mapping.

Test plan

  • go build ./...
  • go test -race ./...
  • go vet ./...
  • go tool golangci-lint run (0 issues)
  • go tool gosec (clean)
  • New tests: parseAddresses, multi-address Configure, failover on server-down / 5xx, exhaustion → retryable, no-failover on 4xx, sticky preference, body replay, placeholder/optional-key hints
  • make deploy — built and restarted local daemon successfully

💘 Generated with Crush

Add sticky failover across multiple Nomad server addresses so the
integration keeps working when the leader or an individual server is
unreachable. Accepts a new addresses credential (comma/newline list,
NOMAD_ADDRS) alongside the existing address; requests fail over on
transport errors and retryable 5xx/429 while definitive 4xx responses
return immediately.

Co-Authored-By: Claude Opus <noreply@anthropic.com>

@acmacalister acmacalister left a comment

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.

CI/status checks are passing. Clean PR — no blocking issues found. LGTM.

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