-
Notifications
You must be signed in to change notification settings - Fork 490
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: panic when setting a zero interval for ticker #2335
Conversation
97cb5b1
to
8e50903
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.
This looks like a nice improvement, I just had some questions.
@@ -80,7 +80,7 @@ func (n *BarrierNode) newBarrier(group edge.GroupInfo, first edge.PointMeta) (ed | |||
) | |||
return periodicBarrier, periodicBarrier.Stop, nil | |||
default: | |||
return nil, nil, errors.New("unreachable code, barrier node should have non-zero idle or non-zero period") | |||
return nil, nil, errors.New("unreachable code, barrier node should have positive idle or positive period") |
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'm curious, what is the behavior supposed to be if period
and idle
are both set? Is that possible?
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.
The docs say it's based on one of them. I wonder if you should return an error if both are set?
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.
That is probably a good idea. I think it is outside the scope of this PR though.
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.
Yeah, that makes sense.
@@ -447,6 +448,9 @@ func unmarshalStats(data []byte, parents []Node, typ TypeOf) (Node, error) { | |||
} | |||
child := nodeParent.Stats(0) | |||
err := json.Unmarshal(data, child) | |||
if child.Interval == 0 { | |||
return nil, errors.New("zero is an invalid stats interval") |
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 code is for serializing kapacitor pipelines, isn't it? Doesn't this check belong in stats.go
?
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 added one to stats.go
8e50903
to
9a0d74a
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.
Looks good!
Required for all non-trivial PRs
Closes #2281