-
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
remove deprecated Drain
field from structs.Node
#10202
Conversation
3a0e029
to
58bda09
Compare
58bda09
to
379281c
Compare
379281c
to
18194d6
Compare
18194d6
to
c93094d
Compare
node drain: use msgtype on txn so that events are emitted wip: encoding extension to add Node.Drain field back to API responses new approach for hiding Node.SecretID in the API, using `json` tag documented this approach in the contributing guide refactored the JSON handlers with extensions modified event stream encoding to use the go-msgpack encoders with the extensions
c93094d
to
574d26c
Compare
@@ -94,57 +94,6 @@ func TestEventFromChange_ACLTokenSecretID(t *testing.T) { | |||
require.Empty(t, tokenEvent2.ACLToken.SecretID) | |||
} | |||
|
|||
// TestEventFromChange_NodeSecretID ensures that a node's secret ID is not |
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 check is provided in a new test:
https://github.com/hashicorp/nomad/pull/10202/files#diff-4dd5ab69dbb20720939d5d0edc23108a3b6427943ff1b71f2fea90a79481c80dR168-R169
along with a sibling test for /v1/node/:id
provided here:
https://github.com/hashicorp/nomad/pull/10202/files#diff-0acc6b10aaabc14cceeb1cbb9b9ded8935451d1f6b4514ee1806b5c9af1ff252R181
@@ -966,9 +966,10 @@ func (s *StateStore) BatchUpdateNodeDrain(msgType structs.MessageType, index uin | |||
// UpdateNodeDrain is used to update the drain of a node | |||
func (s *StateStore) UpdateNodeDrain(msgType structs.MessageType, index uint64, nodeID string, drain *structs.DrainStrategy, markEligible bool, updatedAt int64, event *structs.NodeEvent) error { | |||
|
|||
txn := s.db.WriteTxn(index) | |||
txn := s.db.WriteTxnMsgT(msgType, index) |
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 was preventing Node drain completion from firing an event
} else if node.Drain { | ||
// Deprecate in favor of scheduling eligibility and remove post-0.8 | ||
return false, "node is draining", nil | ||
return false, "node is not eligible", nil |
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.
changed this error message because it seemed wrong. is that allowed? @schmichael , @tgross
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.
Good catch! Your message looks right to me.
} | ||
// Ensure SchedulingEligibility is correctly set whenever draining so the plan applier and other scheduling logic | ||
// only need to check SchedulingEligibility when determining whether a placement is feasible on a node. | ||
if n.DrainStrategy != nil { |
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.
@schmichael , added a comment as requested and tightened this up to make sure we honor the invariant.
@schmichael , i rolled back the suggested changes around RPC and |
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.
Looks great!
this was unecessary after refactoring, so this moves them back to their original location in package structs
The CSI HTTP API has to transform the CSI volume to redact secrets, remove the claims fields, and to consolidate the allocation stubs into a single slice of alloc stubs. This was done manually in #8590 but this is a large amount of code and has proven both very bug prone (see #8659, #8666, #8699, #8735, and #12150) and requires updating lots of code every time we add a field to volumes or plugins. In #10202 we introduce encoding improvements for the `Node` struct that allow a more minimal transformation. Apply this same approach to serializing `structs.CSIVolume` to API responses. Also, the original reasoning behind #8590 for plugins no longer holds because the counts are now denormalized within the state store, so we can simply remove this transformation entirely.
The CSI HTTP API has to transform the CSI volume to redact secrets, remove the claims fields, and to consolidate the allocation stubs into a single slice of alloc stubs. This was done manually in #8590 but this is a large amount of code and has proven both very bug prone (see #8659, #8666, #8699, #8735, and #12150) and requires updating lots of code every time we add a field to volumes or plugins. In #10202 we introduce encoding improvements for the `Node` struct that allow a more minimal transformation. Apply this same approach to serializing `structs.CSIVolume` to API responses. Also, the original reasoning behind #8590 for plugins no longer holds because the counts are now denormalized within the state store, so we can simply remove this transformation entirely.
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
Note: upgrade testing on this PR should verify that
.SecretID
is not emitted by the API (using curl, not the Nomad CLI), and that.Drain
is emitted.This is an attempt to remove the
Drain
field fromstructs.Node
, while still keeping backwards compatibility with theapi.Node.Drain
field. The questions at play are:Here's what the PR does:
Drain
field fromstructs/Node
and deleted code/tests associated with this field.Node.Drain
field back to API responsesstructs.Node.SecretID
, instead allowing the encoder to remove it using ajson
tag on the struct, which works because (:til:) we have configured msgpack encoding for raft to exclusively considercodec
tagsI added some benchmarking to see whether the JSON encoding extensions were expensive, with the following results:
So, 600ns cost with the extensions. Do with that what you will. Note, this doesn't compare against doing a struct-to-API conversion as part of encoding (because I didn't want to write it). Also, it's possible that this is slower because of neglected generated structs; I didn't investigate because of https://m.xkcd.com/1319/