open-nomad/nomad/drainer
Tim Gross 977c88dcea
drainer: test refactoring to clarify behavior around delete/down nodes (#16612)
This changeset refactors the tests of the draining node watcher so that we don't
mock the node watcher's `Remove` and `Update` methods for its own tests. Instead
we'll mock the node watcher's dependencies (the job watcher and deadline
notifier) and now unit tests can cover the real code. This allows us to remove a
bunch of TODOs in `watch_nodes.go` around testing and clarify some important
behaviors:

* Nodes that are down or disconnected will still be watched until the scheduler
  decides what to do with their allocations. This will drive the job watcher but
  not the node watcher, and that lets the node watcher gracefully handle cases
  where a heartbeat fails but the node heartbeats again before its allocs can be
  evicted.

* Stop watching nodes that have been deleted. The blocking query for nodes set
  the maximum index to the highest index of a node it found, rather than the
  index of the nodes table. This misses updates to the index from deleting
  nodes. This was done as an performance optimization to avoid excessive
  unblocking, but because the query is over all nodes anyways there's no
  optimization to be had here. Remove the optimization so we can detect deleted
  nodes without having to wait for an update to an unrelated node.
2023-03-23 14:07:09 -04:00
..
drain_heap.go
drain_heap_test.go
drain_testing.go drainer: test refactoring to clarify behavior around delete/down nodes (#16612) 2023-03-23 14:07:09 -04:00
drainer.go
drainer_util.go
drainer_util_test.go
draining_node.go
draining_node_test.go
watch_jobs.go drainer: test refactoring to clarify behavior around delete/down nodes (#16612) 2023-03-23 14:07:09 -04:00
watch_jobs_test.go
watch_nodes.go drainer: test refactoring to clarify behavior around delete/down nodes (#16612) 2023-03-23 14:07:09 -04:00
watch_nodes_test.go drainer: test refactoring to clarify behavior around delete/down nodes (#16612) 2023-03-23 14:07:09 -04:00