Merge pull request #31894 from MrHohn/kubedns-sigterm

Automatic merge from submit-queue

Support graceful termination in kube-dns

Fix #31807 

kube-dns used to trap SIGINT and SIGTERM and call glog.Fatalf() when signal received.
Let the program keep running when signal occur to support graceful termination. It will be terminated by SIGKILL when grace period ends.

@thockin @girishkalele
This commit is contained in:
Kubernetes Submit Queue 2016-09-10 15:58:04 -07:00 committed by GitHub
commit bcdfb95ddd

View File

@ -125,12 +125,12 @@ func (server *KubeDNSServer) setupHealthzHandlers() {
}
// setupSignalHandlers runs a goroutine that waits on SIGINT or SIGTERM and logs it
// before exiting.
// program will be terminated by SIGKILL when grace period ends.
func setupSignalHandlers() {
sigChan := make(chan os.Signal)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
go func() {
glog.Fatalf("Received signal: %s", <-sigChan)
glog.Infof("Received signal: %s, will exit when the grace period ends", <-sigChan)
}()
}