Skip to content
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

fix: topic-handler duration() -> alertDuration() #2448

Merged
merged 3 commits into from
Dec 10, 2020
Merged

Conversation

docmerlin
Copy link
Contributor

@docmerlin docmerlin commented Dec 10, 2020

the topic handler match function duration() was colliding with the lambda function type conversion function duration. This removes that collision by changing the name of the topic handler match function to alertDuration.

Copy link
Contributor

@danxmoran danxmoran left a comment

Choose a reason for hiding this comment

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

Are there any low-hanging automated tests we could add?

@@ -2,6 +2,10 @@

## Unreleased

### Bugfixes
- [#2448](https://github.com/influxdata/kapacitor/pull/2448): Changes the alert-handler match function duration() to be alertDuration() to avoid name collision with the type conversion function of the same name.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this something we can change in a patch release? Or is it not really a breaking change because the collision was preventing all uses of the match function form?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yah, it isn't a breaking change because the old duration() function never actually worked.

if spec.Match != "" {
// Wrap handler in match handler
handlerDiag := s.diag.WithHandlerContext(ctx...)
h, err = newMatchHandler(spec.Match, h, handlerDiag)
if h == nil {
panic("handler is nil, this should not happen")
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this one need to be a panic? Could we return an err instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a state that should never happen and should panic. The problem was it was panic-ing in a very distant place and made it hard to debug.


if h.h == nil {
panic("h.h is nil")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a debug check, do we want to leave it in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doh, I thought I removed it.

@docmerlin docmerlin merged commit 1574f6a into master Dec 10, 2020
@docmerlin docmerlin deleted the fix/topic-handler branch December 10, 2020 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants