-
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
event stream: add events for dynamic host volumes #24721
Conversation
86c51bb
to
8977fde
Compare
Add a new topic to the event stream for host volumes. We'll emit events when a dynamic host volume is registered or deregistered, and whenever a node fingerprints with a changed volume. Ref: https://hashicorp.atlassian.net/browse/NET-11549
8977fde
to
0ee7051
Compare
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.
I have a little flight of fancy to consider, but lgtm!
return structs.Event{ | ||
Topic: structs.TopicHostVolume, | ||
Key: after.ID, | ||
FilterKeys: []string{ |
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.
DRY bikeshed: what if structs.HostVolume
had an Event()
method that returned this of itself? then it could be used in both places.
// nomad/structs/host_volumes.go
func (hv *HostVolume) Event() Event {
if hv == nil {
return Event{}
}
return Event{
Topic: TopicHostVolume,
Key: hv.ID,
Namespace: hv.Namespace,
FilterKeys: []string{
hv.ID,
hv.Name,
hv.PluginID,
},
Payload: &HostVolumeEvent{
Volume: hv,
},
}
}
extra bonus bikeshed: if all the other types did this too, then this eventFromChange
method could be real small, akin to
type eventer interface {
Event() structs.Event
}
if thing, ok := change.After.(eventer); ok {
return thing.Event(), true
} else {
return structs.Event{}, false
}
so adding something to the event stream could be (almost) as simple as satisfying that interface.
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.
I was thinking something along those lines while implementing this (and #24724). It'd improve the type safety too. But seeing as how I've already tried to shrink this PR by pulling out the CSI work to its own PR, any such refactoring should probably also be its own PR.
There's also a minor annoyance here too that the Eventer interface must be exported from nomad/structs
, but none of that code will be covered by nomad/structs
tests. The "test coverage goons" will frown, but there's really no logic there.
Add a new topic to the event stream for host volumes. We'll emit events when a dynamic host volume is registered or deregistered, and whenever a node fingerprints with a changed volume. Ref: https://hashicorp.atlassian.net/browse/NET-11549
Add a new topic to the event stream for host volumes. We'll emit events when a dynamic host volume is registered or deregistered, and whenever a node fingerprints with a changed volume.
Ref: https://hashicorp.atlassian.net/browse/NET-11549
CSI will be done in a separate PR.
Testing & Reproduction steps
In addition to the unit tests, you can use
nomad operator api "/v1/event/stream?topic=HostVolume"
to poll for host volume events while running the host volume demo setup scriptContributor Checklist
changelog entry using the
make cl
command.ensure regressions will be caught.
and job configuration, please update the Nomad website documentation to reflect this. Refer to
the website README for docs guidelines. Please also consider whether the
change requires notes within the upgrade guide.
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.