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

Changing AtoI to uParseInt to handle overflow problems. #108

Merged
merged 6 commits into from
Sep 7, 2019

Conversation

vegemitecheesetoast
Copy link
Contributor

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.

@k8s-ci-robot
Copy link
Contributor

Welcome @vegemitecheesetoast!

It looks like this is your first PR to kubernetes/utils 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/utils has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

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.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Aug 13, 2019
@k8s-ci-robot k8s-ci-robot requested review from deads2k and mcrute August 13, 2019 22:17
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 13, 2019
@vegemitecheesetoast
Copy link
Contributor Author

I signed it

@vegemitecheesetoast
Copy link
Contributor Author

/assign thockin

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 13, 2019
Copy link
Member

@thockin thockin left a 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 13, 2019
@thockin
Copy link
Member

thockin commented Aug 13, 2019

Travis is weird, got a 502 pulling a package. I kicked it

@thockin
Copy link
Member

thockin commented Aug 13, 2019

/hold for gorilla changes

@thockin thockin added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 13, 2019
@vegemitecheesetoast
Copy link
Contributor Author

I signed it

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 14, 2019
@vegemitecheesetoast
Copy link
Contributor Author

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

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..

go.mod Outdated Show resolved Hide resolved
@thockin
Copy link
Member

thockin commented Aug 14, 2019 via email

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 14, 2019
@vegemitecheesetoast
Copy link
Contributor Author

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.

@thockin
Copy link
Member

thockin commented Aug 15, 2019 via email

@vegemitecheesetoast
Copy link
Contributor Author

i signed it

@vegemitecheesetoast
Copy link
Contributor Author

k/utils is ostensibly our best supported and most general-purpose APIs. I
don't hate the bool flag.

If it's general purpose, bool flag it is! Also added tests.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 17, 2019
@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Aug 21, 2019
@vegemitecheesetoast
Copy link
Contributor Author

The travis failure is not your fault.

@munnerz I told you changing klog,V would hurt. @vegemitecheesetoast do you have a newer klog installed?

# k8s.io/utils/trace
trace/trace.go:100:57: invalid operation: stepThreshold == 0 || stepDuration > stepThreshold || klog.V(4) (mismatched types bool and klog.Verbose)
trace/trace.go:112:56: invalid operation: stepThreshold == 0 || stepDuration > stepThreshold || klog.V(4) (mismatched types bool and klog.Verbose)

This is the version I'm using in go.mod in utils: k8s.io/klog v0.3.0

@thockin
Copy link
Member

thockin commented Aug 29, 2019

Thanks!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 29, 2019
@thockin
Copy link
Member

thockin commented Aug 29, 2019

go.mod calls for 0.3.0 but go's tooling can sub a newer version.

What does go mod why say? or go mod graph ?

Are you building under a GOPATH or not?

@thockin
Copy link
Member

thockin commented Aug 29, 2019

oh, I guess it's not you, it's travis :)

@thockin
Copy link
Member

thockin commented Aug 29, 2019

#111 should fix travis

@thockin
Copy link
Member

thockin commented Aug 29, 2019

You might have to rebase.

git fetch upstream
git rebase upstream/master
git push -f

@thockin thockin removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 30, 2019
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 31, 2019
@thockin
Copy link
Member

thockin commented Aug 31, 2019

oh Travis.

You need to gofmt the file. Most of us end up doing that automatically on save (e.g. https://github.com/thockin/dotfiles/blob/master/vimrc)

@thockin
Copy link
Member

thockin commented Aug 31, 2019

Something like

gofmt -s -w net/*.go
git commit -a --amend
git push -f

@vegemitecheesetoast
Copy link
Contributor Author

OK, I ran the gofmt and did a git diff and saw that it made some fixes. Hope this is ok!

@dims
Copy link
Member

dims commented Sep 1, 2019

@vegemitecheesetoast please see the next problem in the travis CI job results

net/net.go:146:13: result of errors.New call not used
Makefile:29: recipe for target 'vet' failed

@vegemitecheesetoast
Copy link
Contributor Author

@dims
Sorry it's been so long! since last reply back from me.
net/net.go:146:13: result of errors.New call not used - fixed - sorry don't know what happened there!
Makefile:29: recipe for target 'vet' failed - I'm going to rebase and see if this fixes, because I didn't touch this, so hoping it solves itself :|

@vegemitecheesetoast
Copy link
Contributor Author

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?

@dims
Copy link
Member

dims commented Sep 7, 2019

/lgtm
/approve

Thanks for your efforts @vegemitecheesetoast !

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 7, 2019
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 3d4f5b7 into kubernetes:master Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants