-
Notifications
You must be signed in to change notification settings - Fork 203
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
Changing AtoI to uParseInt to handle overflow problems. #108
Conversation
Welcome @vegemitecheesetoast! |
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
I signed it |
/assign thockin |
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.
Something is funky with gorilla - you can just drop those files from this PR.
/lgtm
/approve
Travis is weird, got a 502 pulling a package. I kicked it |
/hold for gorilla changes |
I signed it |
I signed it |
net/net.go
Outdated
if !(0 < portInt && portInt <= 65535) { | ||
return 0, fmt.Errorf("%d is not a valid port: must be between 1 and 65535, inclusive", portInt) | ||
if port == 0 { | ||
return 0, errors.New("Port number can not be 0") |
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.
It might be 0 if you want the system to pick the port for you..
We need to make a call on this as an API - does it allow 0 and expect the
caller to special-case disallow 0, or does it disallow 0 and expect the
caller to test for 0 itself?
Or do we add a flag `allowZero bool` and let callers decide that way? I
actually don't hate that.
…On Wed, Aug 14, 2019 at 12:21 AM Bowei Du ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In net/net.go
<#108 (comment)>:
> if err != nil {
return 0, err
}
- if !(0 < portInt && portInt <= 65535) {
- return 0, fmt.Errorf("%d is not a valid port: must be between 1 and 65535, inclusive", portInt)
+ if port == 0 {
+ return 0, errors.New("Port number can not be 0")
It might be 0 if you want the system to pick the port for you..
------------------------------
In go.mod
<#108 (comment)>:
> @@ -4,6 +4,7 @@ go 1.12
require (
github.com/davecgh/go-spew v1.1.1
+ github.com/gorilla/mux v1.6.3-0.20180517173623-c85619274f5d // indirect
weird why it's pulling this stuff in, your change doesn't reference this.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#108?email_source=notifications&email_token=ABKWAVEMBXV6FDIOHXKHN5DQEOXADA5CNFSM4ILPIOLKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCBP25PY#pullrequestreview-274706111>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABKWAVCX3YQZQR4HYMTRV5LQEOXADANCNFSM4ILPIOLA>
.
|
dd35088
to
47c1486
Compare
47c1486
to
f42d196
Compare
I have two sided thoughts on this one: We already have this function I found in kubernetes/
This above code tests it's a valid port number. My thought is this - the purpose of this function isn't to test if the port number is valid, it's just to convert the port number into a 16 bit integer from a string. bowei@'s point is that we may want the system to choose for us. Do we have a separate function that makes that choice? My other thought is that the function is called ParsePort(), so maybe it should check if it's a valid port, else it should be called ParseInt(). The bool is the third option, Not sure how I feel about that. I'm new to this codebase, so I'm not quite sure what kubernetes style would gravitate towards. |
`IsValidPortNum()` is *specifically* for API validation, where (TTBOMK)
nobody ever allows 0.
I'm new to this codebase, so I'm not quite sure what kubernetes style
would gravitate towards.
k/utils is ostensibly our best supported and most general-purpose APIs. I
don't hate the bool flag.
My instinct is that most callers DO NOT want to allow 0, so if we make this
allow 0, we violate POLS.
Maybe we should audit all the call-sites to see how many do or don't allow
0 ?
…On Thu, Aug 15, 2019 at 2:37 AM Vegemite Cheese Toast < ***@***.***> wrote:
I have two sided thoughts on this one:
We already have this function I found in kubernetes/
// IsValidPortNum tests that the argument is a valid, non-zero port number.
func IsValidPortNum(port int) []string {
if 1 <= port && port <= 65535 {
return nil
}
return []string{InclusiveRangeError(1, 65535)}
}
This above code tests it's a valid port number. My thought is this - the
purpose of this function isn't to test if the port number is valid, it's
just to convert the port number into a 16 bit integer from a string. bowei@'s
point is that we may want the system to choose for us. Do we have a
separate function that makes that choice?
My other thought is that the function is called ParsePort(), so maybe it
should check if it's a valid port, else it should be called ParseInt().
The bool is the third option, Not sure how I feel about that.
I'm new to this codebase, so I'm not quite sure what kubernetes style
would gravitate towards.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#108?email_source=notifications&email_token=ABKWAVCRDL5P4UEBNK5EHBDQEUPXDA5CNFSM4ILPIOLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4LLMSY#issuecomment-521582155>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABKWAVCVLFCHRGUWSFYRIFLQEUPXDANCNFSM4ILPIOLA>
.
|
i signed it |
If it's general purpose, bool flag it is! Also added tests. |
This is the version I'm using in go.mod in utils: k8s.io/klog v0.3.0 |
Thanks! /lgtm |
go.mod calls for 0.3.0 but go's tooling can sub a newer version. What does Are you building under a GOPATH or not? |
oh, I guess it's not you, it's travis :) |
#111 should fix travis |
You might have to rebase.
|
…tegers. Also removing the check for port range because uParseInt provides us with that now.
d7f10bf
to
9ac6bf0
Compare
oh Travis. You need to |
Something like
|
9ac6bf0
to
5d7385d
Compare
OK, I ran the gofmt and did a git diff and saw that it made some fixes. Hope this is ok! |
@vegemitecheesetoast please see the next problem in the travis CI job results
|
@dims |
Apparently this travis build now passes. Please let me know if there is anything else I can do, otherwise, do I just wait to get this merged? |
/lgtm Thanks for your efforts @vegemitecheesetoast ! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dims, thockin, vegemitecheesetoast The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Changing AtoI to uParseInt to handle overflow problems with 16 bit integers. Also removing the check for port range because uParseInt provides us with that now.