-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add default_ineligible configuration option #13082
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @wjordan and thanks for taking an initial pass at this. I have added some inline comments around the functionality.
I am also curious of how this approach would work. If the value is set via a config file value, would the operator be expected to modify this value and then restart the agent?
The Nomad API also includes a method for updating node eligibility which operators could use. If this was the case, and the agent restarted (crash or otherwise) would the config value override what the API call did?
client/client.go
Outdated
if node == nil { | ||
node = &structs.Node{} | ||
if c.config.DefaultIneligible { | ||
node.SchedulingEligibility = api.NodeSchedulingIneligible | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This nil check is a safety check to avoid a panic in the event the node config object is not correctly set. If we chase the function calls from this client.setupNode
call we see:
- it is called by
client.NewClient
which comes fromagent.setupClient
- the
agent.setupClient
function includes a call toagent.clientConfig
agent.clientConfig
callsconvertClientConfig
which performs a number of node struct setup items
Therefore during normal and hopefully every client setup this condition is never hit and therefore the eligibility toggle is not used.
@@ -1795,3 +1796,18 @@ func TestClient_ReconnectAllocs(t *testing.T) { | |||
require.False(t, invalid, "expected alloc to not be marked invalid") | |||
require.Equal(t, unknownAlloc.AllocModifyIndex, finalAlloc.AllocModifyIndex) | |||
} | |||
|
|||
func TestClient_DefaultIneligible(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test seems like it is attempting to match the exact conditions seen within the code which as previously noted is a bit of a red herring.
e649855
to
cb2484b
Compare
Thanks @jrasell for quick feedback and pointing me in the right direction with the implementation. I've updated the code to pass I've updated the test as well. Please take a look and let me know if this is headed in the right direction! |
To answer your questions:
The intended behavior is to only apply the config value as an initial default for newly-registered nodes, so the operator would be expected to set this via a config file value before starting the agent the first time.
No, the config value is only intended to allow configuring the default for newly-registered nodes, so it wouldn't override anything once the node has been registered. |
8467d86
to
31e6a62
Compare
Specifies if scheduling eligibility should be disabled by default for new client nodes.
31e6a62
to
abc5188
Compare
Third attempt at this in abc5188, just set the client node's This value will be sent to the server on the initial registration. Re-registering an existing node (e.g., on agent restart) should already correctly preserve the existing value, thanks to existing logic in nomad/nomad/state/state_store.go Line 896 in 5b5c853
|
any update on this? was surprised that this isn't supported yet. |
Are there any updates on this? |
Any updates on this change? |
@wjordan would you be able to rebase the PR? If not, mind if I reissue it to get this feature merged by the hashicorp folks? |
Specifies if scheduling eligibility should be disabled by default for new client nodes.
Fixes #13081, see this issue for discussion of the use-case.