Go to file
Luiz Aoqui 3479e2231f
core: enforce strict steps for clients reconnect (#15808)
When a Nomad client that is running an allocation with
`max_client_disconnect` set misses a heartbeat the Nomad server will
update its status to `disconnected`.

Upon reconnecting, the client will make three main RPC calls:

- `Node.UpdateStatus` is used to set the client status to `ready`.
- `Node.UpdateAlloc` is used to update the client-side information about
  allocations, such as their `ClientStatus`, task states etc.
- `Node.Register` is used to upsert the entire node information,
  including its status.

These calls are made concurrently and are also running in parallel with
the scheduler. Depending on the order they run the scheduler may end up
with incomplete data when reconciling allocations.

For example, a client disconnects and its replacement allocation cannot
be placed anywhere else, so there's a pending eval waiting for
resources.

When this client comes back the order of events may be:

1. Client calls `Node.UpdateStatus` and is now `ready`.
2. Scheduler reconciles allocations and places the replacement alloc to
   the client. The client is now assigned two allocations: the original
   alloc that is still `unknown` and the replacement that is `pending`.
3. Client calls `Node.UpdateAlloc` and updates the original alloc to
   `running`.
4. Scheduler notices too many allocs and stops the replacement.

This creates unnecessary placements or, in a different order of events,
may leave the job without any allocations running until the whole state
is updated and reconciled.

To avoid problems like this clients must update _all_ of its relevant
information before they can be considered `ready` and available for
scheduling.

To achieve this goal the RPC endpoints mentioned above have been
modified to enforce strict steps for nodes reconnecting:

- `Node.Register` does not set the client status anymore.
- `Node.UpdateStatus` sets the reconnecting client to the `initializing`
  status until it successfully calls `Node.UpdateAlloc`.

These changes are done server-side to avoid the need of additional
coordination between clients and servers. Clients are kept oblivious of
these changes and will keep making these calls as they normally would.

The verification of whether allocations have been updates is done by
storing and comparing the Raft index of the last time the client missed
a heartbeat and the last time it updated its allocations.
2023-01-25 15:53:59 -05:00
.changelog core: enforce strict steps for clients reconnect (#15808) 2023-01-25 15:53:59 -05:00
.circleci build: update to go 1.19.5 (#15769) 2023-01-13 09:57:32 -06:00
.github docs: Migrate link formats (#15779) 2023-01-25 09:31:14 -08:00
.release Prepare for next release 2022-11-22 12:56:29 -05:00
.semgrep WI: allow workloads to use RPCs associated with HTTP API (#15870) 2023-01-25 14:33:06 -05:00
.tours Make number of scheduler workers reloadable (#11593) 2022-01-06 11:56:13 -05:00
acl Migrate acls to generics (#13721) 2022-12-19 09:56:28 -08:00
api Merge branch 'main' into sso/gh-13120-oidc-login 2023-01-18 10:05:31 +00:00
ci ci: swap freeport for portal in packages (#15661) 2023-01-03 11:25:20 -06:00
client implement pre-forwarding auth on select RPCs (#15513) 2023-01-24 10:52:07 -05:00
command add metric for count of RPC requests (#15515) 2023-01-24 11:54:20 -05:00
contributing build: update to go 1.19.5 (#15769) 2023-01-13 09:57:32 -06:00
demo demo/docs: update demo of Kadalu CSI Plugin (#13610) 2022-07-06 10:24:34 -04:00
dev docs: swap master for main in Nomad repo 2021-03-08 14:26:31 -05:00
drivers docker: add option for Windows isolation modes (#15819) 2023-01-24 16:31:48 -05:00
e2e e2e: fixup reference to exported test type (#15786) 2023-01-17 12:13:57 -06:00
helper vault: configure user agent on Nomad vault clients (#15745) 2023-01-10 10:39:45 -06:00
integrations
internal/testing/apitests api: add OIDC HTTP API endpoints and SDK. 2023-01-13 13:15:58 +00:00
jobspec api: remove `mapstructure` tags from`Port` struct (#12916) 2022-11-08 11:26:28 +01:00
jobspec2 consul/connect: use block not optional for opaque map (#15765) 2023-01-12 10:39:10 -06:00
lib cli: use localhost for default login callback address. (#15820) 2023-01-19 16:46:17 +01:00
nomad core: enforce strict steps for clients reconnect (#15808) 2023-01-25 15:53:59 -05:00
plugins Add mount propagation to protobuf definition of mounts (#15096) 2022-11-17 18:14:59 -05:00
scheduler scheduler: allow using device ID as attribute (#15455) 2023-01-10 14:28:23 -05:00
scripts build: update to go 1.19.5 (#15769) 2023-01-13 09:57:32 -06:00
terraform terraform: update installed versions of HashiCorp tools. (#13635) 2022-07-07 16:12:19 +02:00
testutil core: enforce strict steps for clients reconnect (#15808) 2023-01-25 15:53:59 -05:00
tools make: add target cl for create changelog entry (#15186) 2022-11-08 09:43:32 -06:00
ui Merge branch 'main' into sso/gh-13120-oidc-login 2023-01-18 10:05:31 +00:00
version Prepare for next release 2022-11-22 12:56:29 -05:00
website docs: Migrate link formats (#15779) 2023-01-25 09:31:14 -08:00
.git-blame-ignore-revs ignore b0a20b4dc965a38b0c843f47c16685ccad7439da (#13648) 2022-07-07 15:16:18 -07:00
.gitattributes
.gitignore ci: use groups of tests in gha (#15018) 2022-10-27 09:02:58 -05:00
.go-version build: update to go 1.19.5 (#15769) 2023-01-13 09:57:32 -06:00
.golangci.yml build: update linters (#15063) 2022-10-27 15:02:30 -05:00
.semgrepignore build: disable semgrep on structs.go for now 2022-02-01 10:09:49 -06:00
CHANGELOG.md changelogs for 1.3.8 and 1.2.15 2022-11-22 12:57:55 -05:00
CODEOWNERS ensure engineering has merge authority on build pipeline (#15350) 2022-11-21 14:30:02 -05:00
GNUmakefile api: make api tests fast and more concurrency safe (#15543) 2022-12-16 12:25:28 -06:00
LICENSE [COMPLIANCE] Update MPL 2.0 LICENSE (#14884) 2022-10-13 08:43:12 -04:00
README.md readme: remove Gitter lobby link. (#14195) 2022-08-22 10:33:20 +02:00
Vagrantfile tools: update virtualbox networking configuration (#11561) 2021-11-24 10:45:58 -05:00
build_linux_arm.go gofmt all the files 2021-10-01 10:14:28 -04:00
go.mod build(deps): bump github.com/prometheus/common from 0.37.0 to 0.39.0 (#15793) 2023-01-19 11:01:28 -06:00
go.sum build(deps): bump github.com/prometheus/common from 0.37.0 to 0.39.0 (#15793) 2023-01-19 11:01:28 -06:00
main.go client: sandbox go-getter subprocess with landlock (#15328) 2022-12-07 16:02:25 -06:00
main_test.go

README.md

Nomad License: MPL 2.0 Discuss

HashiCorp Nomad logo

Nomad is a simple and flexible workload orchestrator to deploy and manage containers (docker, podman), non-containerized applications (executable, Java), and virtual machines (qemu) across on-prem and clouds at scale.

Nomad is supported on Linux, Windows, and macOS. A commercial version of Nomad, Nomad Enterprise, is also available.

Nomad provides several key features:

  • Deploy Containers and Legacy Applications: Nomads flexibility as an orchestrator enables an organization to run containers, legacy, and batch applications together on the same infrastructure. Nomad brings core orchestration benefits to legacy applications without needing to containerize via pluggable task drivers.

  • Simple & Reliable: Nomad runs as a single binary and is entirely self contained - combining resource management and scheduling into a single system. Nomad does not require any external services for storage or coordination. Nomad automatically handles application, node, and driver failures. Nomad is distributed and resilient, using leader election and state replication to provide high availability in the event of failures.

  • Device Plugins & GPU Support: Nomad offers built-in support for GPU workloads such as machine learning (ML) and artificial intelligence (AI). Nomad uses device plugins to automatically detect and utilize resources from hardware devices such as GPU, FPGAs, and TPUs.

  • Federation for Multi-Region, Multi-Cloud: Nomad was designed to support infrastructure at a global scale. Nomad supports federation out-of-the-box and can deploy applications across multiple regions and clouds.

  • Proven Scalability: Nomad is optimistically concurrent, which increases throughput and reduces latency for workloads. Nomad has been proven to scale to clusters of 10K+ nodes in real-world production environments.

  • HashiCorp Ecosystem: Nomad integrates seamlessly with Terraform, Consul, Vault for provisioning, service discovery, and secrets management.

Quick Start

Testing

See Learn: Getting Started for instructions on setting up a local Nomad cluster for non-production use.

Optionally, find Terraform manifests for bringing up a development Nomad cluster on a public cloud in the terraform directory.

Production

See Learn: Nomad Reference Architecture for recommended practices and a reference architecture for production deployments.

Documentation

Full, comprehensive documentation is available on the Nomad website: https://www.nomadproject.io/docs

Guides are available on HashiCorp Learn.

Contributing

See the contributing directory for more developer documentation.