Merge pull request #80651 from odinuge/kubectl-proxy-handle-error

Add error check in kubectl proxy on server setup
This commit is contained in:
Kubernetes Prow Robot 2020-02-09 11:23:52 -08:00 committed by GitHub
commit ca1514d03b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -99,7 +99,6 @@ vendor/k8s.io/kubectl/pkg/cmd/config
vendor/k8s.io/kubectl/pkg/cmd/edit
vendor/k8s.io/kubectl/pkg/cmd/exec
vendor/k8s.io/kubectl/pkg/cmd/get
vendor/k8s.io/kubectl/pkg/cmd/proxy
vendor/k8s.io/kubectl/pkg/cmd/rollingupdate
vendor/k8s.io/kubectl/pkg/cmd/scale
vendor/k8s.io/kubectl/pkg/cmd/set

View File

@ -200,6 +200,10 @@ func (o ProxyOptions) Validate() error {
func (o ProxyOptions) RunProxy() error {
server, err := proxy.NewServer(o.staticDir, o.apiPrefix, o.staticPrefix, o.filter, o.clientConfig, o.keepalive)
if err != nil {
return err
}
// Separate listening from serving so we can report the bound port
// when it is chosen by os (eg: port == 0)
var l net.Listener
@ -209,9 +213,8 @@ func (o ProxyOptions) RunProxy() error {
l, err = server.ListenUnix(o.unixSocket)
}
if err != nil {
klog.Fatal(err)
return err
}
fmt.Fprintf(o.IOStreams.Out, "Starting to serve on %s\n", l.Addr().String())
klog.Fatal(server.ServeOnListener(l))
return nil
return server.ServeOnListener(l)
}