Merge pull request #60654 from dcbw/kubelet-notify-systemd

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

kubelet: notify systemd that kubelet has started

This call has no side-effects if systemd is not used or not installed.

Fixes: https://github.com/kubernetes/kubernetes/issues/59079

@smarterclayton @sjenning 

```release-note
kubelet now notifies systemd that it has finished starting, if systemd is available and running.
```
pull/6/head
Kubernetes Submit Queue 2018-03-03 02:25:21 -08:00 committed by GitHub
commit c6d0726df8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -131,6 +131,7 @@ go_library(
"//pkg/volume/secret:go_default_library",
"//pkg/volume/storageos:go_default_library",
"//pkg/volume/vsphere_volume:go_default_library",
"//vendor/github.com/coreos/go-systemd/daemon:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",

View File

@ -31,8 +31,10 @@ import (
"path"
"path/filepath"
"strconv"
"sync"
"time"
"github.com/coreos/go-systemd/daemon"
"github.com/golang/glog"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
@ -697,6 +699,9 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies) (err error) {
return nil
}
// If systemd is used, notify it that we have started
go daemon.SdNotify(false, "READY=1")
<-done
return nil
}
@ -937,20 +942,31 @@ func RunKubelet(kubeFlags *options.KubeletFlags, kubeCfg *kubeletconfiginternal.
}
func startKubelet(k kubelet.Bootstrap, podCfg *config.PodConfig, kubeCfg *kubeletconfiginternal.KubeletConfiguration, kubeDeps *kubelet.Dependencies, enableServer bool) {
wg := sync.WaitGroup{}
// start the kubelet
go wait.Until(func() { k.Run(podCfg.Updates()) }, 0, wait.NeverStop)
wg.Add(1)
go wait.Until(func() {
wg.Done()
k.Run(podCfg.Updates())
}, 0, wait.NeverStop)
// start the kubelet server
if enableServer {
wg.Add(1)
go wait.Until(func() {
wg.Done()
k.ListenAndServe(net.ParseIP(kubeCfg.Address), uint(kubeCfg.Port), kubeDeps.TLSOptions, kubeDeps.Auth, kubeCfg.EnableDebuggingHandlers, kubeCfg.EnableContentionProfiling)
}, 0, wait.NeverStop)
}
if kubeCfg.ReadOnlyPort > 0 {
wg.Add(1)
go wait.Until(func() {
wg.Done()
k.ListenAndServeReadOnly(net.ParseIP(kubeCfg.Address), uint(kubeCfg.ReadOnlyPort))
}, 0, wait.NeverStop)
}
wg.Wait()
}
func CreateAndInitKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,