Isol. CPU plugin on startup: wait for kubelet.sock to be ready
Change-Id: Id5b138fccb40648646dc6ff93c1001ef3bf44751 Signed-off-by: Kaustubh Dhokte <kaustubh.dhokte@windriver.com>
This commit is contained in:
parent
1b0db90e43
commit
bf636bf642
|
@ -211,6 +211,13 @@ func (srv *server) setupAndServe(namespace string, devicePluginPath string, kube
|
|||
pluginEndpoint := pluginPrefix + ".sock"
|
||||
pluginSocket := path.Join(devicePluginPath, pluginEndpoint)
|
||||
|
||||
// Wait for the kubelet RPC server to start
|
||||
if err := waitForServer(kubeletSocket, 60*time.Second); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("Connection test successful with the Kubelet socket at ", kubeletSocket)
|
||||
|
||||
if err := waitForServer(pluginSocket, time.Second); err == nil {
|
||||
return errors.Errorf("Socket %s is already in use", pluginSocket)
|
||||
}
|
||||
|
@ -235,6 +242,12 @@ func (srv *server) setupAndServe(namespace string, devicePluginPath string, kube
|
|||
return err
|
||||
}
|
||||
|
||||
// Kubelet removes plugin socket when it (re)starts
|
||||
// plugin must restart in this case
|
||||
if err = watchFile(pluginSocket); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Register with Kubelet.
|
||||
err = registerWithKubelet(kubeletSocket, pluginEndpoint, resourceName)
|
||||
if err != nil {
|
||||
|
@ -242,12 +255,6 @@ func (srv *server) setupAndServe(namespace string, devicePluginPath string, kube
|
|||
}
|
||||
fmt.Printf("Device plugin for %s registered\n", srv.devType)
|
||||
|
||||
// Kubelet removes plugin socket when it (re)starts
|
||||
// plugin must restart in this case
|
||||
if err = watchFile(pluginSocket); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if srv.getState() == serving {
|
||||
srv.grpcServer.Stop()
|
||||
fmt.Printf("Socket %s removed, restarting\n", pluginSocket)
|
||||
|
|
Loading…
Reference in New Issue