-
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
client: don't emit task shutdown delay event if not waiting #16281
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.
LGTM!
// Check that we only emit the expected events. | ||
hasEvent := false | ||
for _, ev := range tr.state.Events { | ||
require.NotEqual(t, structs.TaskWaitingShuttingDownDelay, ev.Type) | ||
if ev.Type == structs.TaskSkippingShutdownDelay { | ||
hasEvent = true | ||
} | ||
} | ||
require.True(t, hasEvent) |
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.
Not a blocker, but I think this kind of loop is what must.Contains
was designed for?
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 couldn't quite make that work. The best I was able to do was something like this:
want := &structs.TaskEvent{Type: structs.TaskSkippingShutdownDelay}
must.SliceContainsFunc(t, tr.state.Events, want, func(a, b *structs.TaskEvent) bool {
return a.Type == b.Type
})
But SliceNotContainsFunc
, which I would have to use to check for the absence of TaskWaitingShuttingDownDelay
doesn't exist yet, so I left the initial implementation but replacing require
with must
.
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.
SliceNotContainsFunc
probably should exist, created shoenig/test#110
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.
Awesome, thanks!
I was thinking about the ergonomics of this use case, and I think it could be helpful to have something like these:
s := []string{"hit", "miss"}
must.SliceAtLeastOne(s, func(i string) bool {
return i == "hit"
}) // success
must.SliceAll(s, func(i string) bool {
return i == "hit"
}) // fail
must.SliceNone(s, func(i string) bool {
return i == "none"
}) // success
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.
LGTM!
#14775 introduced a new task event when the task runner is waiting for the
shutdown_delay
, but some requests can be configured to ignore theshutdown_delay
, in which case it can confusing to have this event, so emit one that notes the delay is being skipped instead.No changelog or backports necessary since #14775 has not being released yet.I just realized that I should've merged this for 1.5.0 🤦
Not big deal, but I added a changelog entry now.