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: panic when setting a zero interval for ticker #2335

Merged
merged 1 commit into from
May 14, 2020
Merged

Conversation

docmerlin
Copy link
Contributor

@docmerlin docmerlin commented May 11, 2020

Required for all non-trivial PRs
  • Rebased/mergable
  • Tests pass
  • CHANGELOG.md updated

Closes #2281

@docmerlin docmerlin force-pushed the fix/tickerpanic branch 5 times, most recently from 97cb5b1 to 8e50903 Compare May 14, 2020 21:25
Copy link

@wolffcm wolffcm left a 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")
Copy link

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?

Copy link

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?

Copy link
Contributor Author

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.

Copy link

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")
Copy link

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?

Copy link
Contributor Author

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

Copy link

@wolffcm wolffcm left a comment

Choose a reason for hiding this comment

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

Looks good!

@docmerlin docmerlin merged commit bf60b18 into master May 14, 2020
@docmerlin docmerlin deleted the fix/tickerpanic branch May 14, 2020 22:12
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.

"Deadman" interval = 0s will crash kapacitor
2 participants