Skip to content

Commit

Permalink
Merge pull request #28797 from aaronlevy/insecure-retry
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

Retry when apiserver fails to listen on insecure port

The apiserver will already continually retry when it fails to bind to the secure port. However, with the insecure port it does not retry, and any failures cause the apiserver to exit.

This change makes it so the api-server will retry on both insecure/secure ports.

A use-case for this change is for self-hosting the api-server, particularly when you are only running a single copy in your cluster. In some bootstrap and upgrade scenarios - it's necessary to replace/pivot from an existing api-server on the same host -- where you need a new copy running before tearing down the old (which is problematic when the api-server will try to bind to an in-use port and exit).
  • Loading branch information
k8s-merge-robot authored Jul 14, 2016
2 parents 54c8c82 + 25ac0dd commit 224b039
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/genericapiserver/genericapiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,18 @@ func (s *GenericAPIServer) Run(options *options.ServerRunOptions) {
Handler: apiserver.RecoverPanics(handler),
MaxHeaderBytes: 1 << 20,
}

glog.Infof("Serving insecurely on %s", insecureLocation)
glog.Fatal(http.ListenAndServe())
go func() {
defer utilruntime.HandleCrash()
for {
if err := http.ListenAndServe(); err != nil {
glog.Errorf("Unable to listen for insecure (%v); will try again.", err)
}
time.Sleep(15 * time.Second)
}
}()
select {}
}

// Exposes the given group version in API.
Expand Down

0 comments on commit 224b039

Please sign in to comment.