Skip to content

node config: add default_ineligible configuration option#27965

Open
tehut wants to merge 4 commits into
mainfrom
default_ineligible
Open

node config: add default_ineligible configuration option#27965
tehut wants to merge 4 commits into
mainfrom
default_ineligible

Conversation

@tehut
Copy link
Copy Markdown
Contributor

@tehut tehut commented May 13, 2026

This PR picks up where @wjordan left off in #13082 as suggested in NMD-1461.

The original PR creates a DefaultIneligible config option on the client that allows a user to set nodes as ineligible at initialization.

Restart behavior came up in the original review and @wjordan correctly identified that upsertNodeTxn in state_store.go overwrites eligibility with the last known state of recognized nodes.

I added some steps to their TestClient_DefaultIneligble test to capture that behavior. The test now marks the node as Eligible queries to confirm desired state, restarts the node, and queries once again to confirm desired state.

Links

Refs:
NMD-1461
Closes: GH #10329
Rebase & inclusion of @wjordan's PR

Contributor Checklist

  • Changelog Entry If this PR changes user-facing behavior, please generate and add a
    changelog entry using the make cl command.
  • Testing Please add tests to cover any new functionality or to demonstrate bug fixes and
    ensure regressions will be caught.
  • Documentation If the change impacts user-facing functionality such as the CLI, API, UI,
    and job configuration, please update the Nomad product documentation, which is stored in the
    web-unified-docs repo. Refer to the web-unified-docs contributor 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-docs team in this PR.

Reviewer Checklist

  • Backport Labels Please add the correct backport labels as described by the internal
    backporting document.
  • Commit Type Ensure the correct merge method is selected which should be "squash and merge"
    in the majority of situations. The main exceptions are long-lived feature branches or merges where
    history should be preserved.
  • Enterprise PRs If this is an enterprise only PR, please add any required changelog entry
    within the public repository.
  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

Specifies if scheduling eligibility should be
disabled by default for new client nodes.
@tehut tehut changed the title Rebase of community add default_ineligible configuration option PR NMD-1461: Rebase of community PR: add default_ineligible configuration option May 13, 2026
@tgross tgross changed the title NMD-1461: Rebase of community PR: add default_ineligible configuration option node config: add default_ineligible configuration option May 13, 2026
@tehut tehut marked this pull request as ready for review May 13, 2026 20:11
@tehut tehut requested review from a team as code owners May 13, 2026 20:11
tgross
tgross previously approved these changes May 13, 2026
Copy link
Copy Markdown
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread client/client_test.go
var out structs.SingleNodeResponse

// Register should succeed
testutil.WaitForResult(func() (bool, error) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future work, this testutil.WaitForResult helper is really dodgy and has weird local-vs-CI behaviors. We have must.Wait in shoenig/test that's a little easier to use correctly and gives you fine-grained control.

Comment thread client/client_test.go Outdated
Comment thread client/client_test.go Outdated
return false, fmt.Errorf("missing reg")
}
must.Eq(t, structs.NodeSchedulingEligible, out3.Node.SchedulingEligibility)
return out3.Node.ID == req.NodeID, nil
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a weird assertion. Why would we ever get a different node here than the one we requested? And even if we did, why does that belong in this test?

Copy link
Copy Markdown
Contributor Author

@tehut tehut May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I see how this just smells weird. I re-used the original request since the query is identical. I can create a req3 so it doesn't make a person's eyes cross.

I'd done the same thing intentionally on ln 2399 to demonstrate that c1 and c2 are the same node, but I can rip that out also.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not really the issue so much as we're checking that we got the node ID we asked for, which would maybe be meaningful in a test of the node RPCs, but this is a test for the client configuration on startup.

Comment thread client/client_test.go
Comment on lines +2345 to +2355
// Update eligibility should succeed
must.Wait(t, wait.InitialSuccess(
wait.ErrorFunc(func() error {
err := s1.RPC("Node.UpdateEligibility", &req2, &out2)
if err != nil {
return err
}
must.NotEq(t, out2.NodeModifyIndex, out.Index)
return nil
}),
))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we waiting here? Isn't this a synchronous update?

Comment thread client/client_test.go
return false, fmt.Errorf("missing reg")
}
must.Eq(t, structs.NodeSchedulingIneligible, out.Node.SchedulingEligibility)
return out.Node.ID == req.NodeID, nil
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return out.Node.ID == req.NodeID, nil
return true, nil

Comment thread client/client_test.go
Comment on lines +2363 to +2374
must.Wait(t, wait.InitialSuccess(
wait.ErrorFunc(func() error {
err := s1.RPC("Node.GetNode", &req3, &out3)
if err != nil {
return err
}
must.Eq(t, structs.NodeSchedulingEligible, out3.Node.SchedulingEligibility)
return nil
}),
wait.Timeout(time.Second*1),
wait.Gap(time.Millisecond*30),
))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. The state store write was synchronous, so why are we waiting? Should we be waiting to see if it changes with wait.ContinualSuccesss? How long would we need to wait for if we did?

Comment thread client/client_test.go
Comment on lines +2394 to +2405
must.Wait(t, wait.InitialSuccess(
wait.ErrorFunc(func() error {
err := s1.RPC("Node.GetNode", &req4, &out4)
if err != nil {
return err
}
must.Eq(t, structs.NodeSchedulingEligible, out4.Node.SchedulingEligibility)
return nil
}),
wait.Timeout(time.Second*1),
wait.Gap(time.Millisecond*30),
))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will immediately succeed even if it flips, because the node just started and it takes a little bit to send a fingerprint. I think we need to wait until the initial fingerprint is sent as well, right? Can we detect that from this server RPC?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants