Refactor filterByTainted#27584
Conversation
7e36f94 to
bb1743b
Compare
bb1743b to
f838bfc
Compare
f838bfc to
fbd20af
Compare
|
Everytime I see |
|
why Nodes? |
gulducat
left a comment
There was a problem hiding this comment.
This is fabulous. The code itself looks solid to me. My comments are all about adding even more clarity based on the new structure.
| all := allocSet{tc.alloc.ID: tc.alloc} | ||
| state := ClusterState{Now: now, TaintedNodes: tc.nodeMap} | ||
|
|
||
| untainted, migrate, lost, disconnecting, reconnecting, ignore, expiring := all.filterByTainted(state) |
There was a problem hiding this comment.
I'll put this comment here so github makes it a thread to discuss, only tangentially related to this line.
I agree with @mismithhisler that we could rename this func, because filterByTainted is not very intuitive, but you're right that it's not Nodes that are being categorized. How about categorizeAllocs?
I also think the doc comment could be a little clearer, while we're at it, something like
// categorizeAllocs takes a set of tainted nodes and filters the allocation set
// into the following groups:
// 1. untainted: allocs on untainted nodes (AND clarify what exactly this means...)
// 2. migrate: allocs on nodes that are draining and need to be moved
// 3. lost: allocs on lost nodes or have expired and need to be replaced
// 4. disconnect: allocs on nodes that are disconnected, but have not had their ClientState set to unknown
// 5. reconecting: allocs on a node that has reconnected, and need ......
// 6. ignore: allocs in a state that results in a noop that only need to be counted
// 7. expiring: allocs on disconnected nodes and need to be marked lost (and possibly replaced)
func (set allocSet) categorizeAllocs(state ClusterState)
(untainted, migrate, lost, disconnecting, reconnecting, ignore, expiring allocSet) {?
There was a problem hiding this comment.
Co-authored-by: Daniel Bennett <8812489+gulducat@users.noreply.github.com>
5eb345c to
8a4a566
Compare
8a4a566 to
fc07039
Compare
|
|
Description
This PR attempts to refactor de function
filterByTaintedto make it clearer and easier to expand. It maintains all its functionality and adds testing.The approach is to have a priority organised classification rules of the shape
condition func(allocContext) boolthat will determine in with bucket should each allocation end up.The
allocContextcontains all the information necessary to classify an alloc:Testing & Reproduction steps
Links
Contributor Checklist
changelog entry using the
make clcommand.ensure regressions will be caught.
and job configuration, please update the Nomad product documentation, which is stored in the
web-unified-docsrepo. Refer to theweb-unified-docscontributor guide for docs guidelines.Please also consider whether the change requires notes within the upgrade
guide. If you would like help with the docs, tag the
nomad-docsteam in this PR.Reviewer Checklist
backporting document.
in the majority of situations. The main exceptions are long-lived feature branches or merges where
history should be preserved.
within the public repository.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.