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

UDP inputs now uses human friendly size to define MaxMessageSize #6886

Merged
merged 2 commits into from
Apr 19, 2018

Conversation

ph
Copy link
Contributor

@ph ph commented Apr 17, 2018

Uses go-humanize to parse values for MaxMessageSize and fallback to
raw bytes if no suffix is found. Also create a new type for future
configuration named cfgtype.ByteSize that will take care of correctly
unpacking values.

@ph ph added the Filebeat Filebeat label Apr 17, 2018

import "github.com/dustin/go-humanize"

type Size int64

Choose a reason for hiding this comment

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

exported type Size should have comment or be unexported

@@ -3,6 +3,8 @@ package udp
import (
"time"

humanize "github.com/dustin/go-humanize"
Copy link
Contributor

@kvch kvch Apr 17, 2018

Choose a reason for hiding this comment

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

I might be wrong, but AFAIK the prefix "go-" is removed automatically. So you don't need to alias this import.

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 really need to fix my editor to stop adding theses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kvch Your vim doesn't do that?

@ph ph force-pushed the fix/humanize-udp branch from 658c7e4 to 3942125 Compare April 17, 2018 19:38
@ph
Copy link
Contributor Author

ph commented Apr 17, 2018

@kvch updated

@ph
Copy link
Contributor Author

ph commented Apr 18, 2018

jenkins test this please

@ph ph added in progress Pull request is currently in progress. review and removed in progress Pull request is currently in progress. review labels Apr 18, 2018
@ph
Copy link
Contributor Author

ph commented Apr 18, 2018

@kvch don't merge it yet, I have second thoughts about the name, I think It will go with byteSize instead of size it will a bit more explicit.

@@ -18,7 +19,7 @@ type client struct {
done chan struct{}
metadata Metadata
splitFunc bufio.SplitFunc
maxReadMessage size
maxReadMessage common.Size
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we rename the variable here to be in line with the config naming? This will make it easier to read the code base.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will rename it to maxMessageSize

type Size int64

// Unpack convert a size defined from a human readable format into bytes.
func (s *Size) Unpack(value string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this as a temporarely fix to make migration easier. But I would remove it again in 7.0 to only have 1 way to configure the values.

This would mean to when someone uses it without a unit, we should log a deprecation warning.

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 am OK to add a deprecation warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ruflin When I tried to use cfgwarn in that file, I hit aimport cycle not allowed, to fix that I have either to move theses new common type out of common OR maybe cfgwarn out of common and have a backward compatible alias? ...

@ph ph force-pushed the fix/humanize-udp branch 2 times, most recently from 790363b to 77d5271 Compare April 18, 2018 19:36
@ph ph added review and removed in progress Pull request is currently in progress. labels Apr 18, 2018
@ph
Copy link
Contributor Author

ph commented Apr 18, 2018

@kvch @ruflin renamed updated and added the warning. 👍

Copy link
Contributor

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

I would keep the current default of 10KB as a mutline event can reach that limit pretty easily I'm thinking. If we change it, we should add it to the changelog.

Code LGTM.

@@ -12,7 +14,7 @@ var defaultConfig = config{
Type: "udp",
},
Config: udp.Config{
MaxMessageSize: 10240,
MaxMessageSize: 1 * humanize.KiByte,
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the late comment, but I just realised we are changing the default here from 10KB to 1KB?

@ph
Copy link
Contributor Author

ph commented Apr 19, 2018 via email

@ph
Copy link
Contributor Author

ph commented Apr 19, 2018

@ruflin all update good catch, waiting for green.

@@ -29,13 +29,13 @@ The `udp` input supports the following configuration options plus the
[id="{beatname_lc}-input-{type}-max-message-size"]
==== `max_message_size`

The maximum size of the message received over UDP. The default is `10240`.
The maximum size of the message received over UDP. The default is `1KiB`.
Copy link
Contributor

Choose a reason for hiding this comment

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

@ph I think you forgot the docs. Also see above.

ph added 2 commits April 19, 2018 09:31
Uses go-humanize to parse values for `MaxMessageSize` and fallback to
raw bytes if no suffix is found. Also create a new type for future
configuration named `cfgtype.ByteSize` that will take care of correctly
unpacking values.
@ph ph force-pushed the fix/humanize-udp branch from 28805e1 to cbdc861 Compare April 19, 2018 13:32
@ph
Copy link
Contributor Author

ph commented Apr 19, 2018

@ruflin I've fixed the docs issue and manually rebased to have a cleaner history.

Copy link
Contributor

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

WFG

@ruflin ruflin merged commit 227dc95 into elastic:master Apr 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants