Merge pull request #28797 from aaronlevy/insecure-retry

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).
pull/6/head
k8s-merge-robot 2016-07-13 18:51:29 -07:00 committed by GitHub
commit 224b039307
1 changed files with 11 additions and 1 deletions

View File

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