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

Add logic for finding next available port for gRPC if provided one is in use #1752

Merged
merged 1 commit into from Mar 7, 2019

Conversation

nkubala
Copy link
Contributor

@nkubala nkubala commented Mar 7, 2019

Fixes #1733

this adds functionality in the gRPC event server logic to be smarter about finding an available port if the provided one is already in use.

this also changes the CLI flag to be an int instead of a string, for clarity.

this will also issue a small warning to the user that their specified port is in use, if they provided a non-default port through the CLI.

@codecov-io
Copy link

Codecov Report

Merging #1752 into master will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1752   +/-   ##
=======================================
  Coverage   47.03%   47.03%           
=======================================
  Files         128      128           
  Lines        6213     6213           
=======================================
  Hits         2922     2922           
  Misses       2993     2993           
  Partials      298      298
Impacted Files Coverage Δ
pkg/skaffold/config/options.go 88.23% <ø> (ø) ⬆️
cmd/skaffold/app/cmd/cmd.go 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d8c5de6...67fd3fc. Read the comment docs.

1 similar comment
@codecov-io
Copy link

codecov-io commented Mar 7, 2019

Codecov Report

Merging #1752 into master will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1752   +/-   ##
=======================================
  Coverage   47.03%   47.03%           
=======================================
  Files         128      128           
  Lines        6213     6213           
=======================================
  Hits         2922     2922           
  Misses       2993     2993           
  Partials      298      298
Impacted Files Coverage Δ
pkg/skaffold/config/options.go 88.23% <ø> (ø) ⬆️
cmd/skaffold/app/cmd/cmd.go 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d8c5de6...67fd3fc. Read the comment docs.

@nkubala nkubala merged commit 80d0347 into GoogleContainerTools:master Mar 7, 2019
func newStatusServer(port string) (func() error, error) {
if port == "" {
func newStatusServer(originalPort int) (func() error, error) {
if originalPort == -1 {
Copy link
Member

Choose a reason for hiding this comment

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

I don't see why this would be -1? i see its called here with default port 50051?

serverShutdown, err = newStatusServer(opts.RPCPort)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was for testing as a way to bypass creating an RPC server in some cases. I probably should have removed it.

return func() error { return nil }, nil
}
l, err := net.Listen("tcp", port)
port := util.GetAvailablePort(originalPort)
if port != originalPort && originalPort != constants.DefaultRPCPort {
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't port != constants.DefaultRPCPort suffice?
is this to guard against condition where util.GetAvailbalePort returns -1?
Maybe we shd define an constant PORT_NOT_FOUND and assign it to -1 just to make this readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this logic is basically "if the user provided a different port than the skaffold default, but we couldn't use that port because it was already in use, warn them that we're using a different port than they might expect".

if the user didn't provide a port, they probably don't care that skaffold didn't use its own default. the port being used will still be in the logs.

Copy link
Member

Choose a reason for hiding this comment

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

ah.. ok.

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.

None yet

5 participants