in pkg/nitro_enclaves_device_monitor/monitor.go [87:124]
func run(nepm *NitroEnclavesPluginMonitor) bool {
cont := true
if nepm.state() != PluginRunning {
if err := nepm.devicePlugin.Start(); err != nil {
// Sleep and try again as long as the monitor is running.
time.Sleep(pluginStartRetryTimeout)
return cont
}
}
nepm.setState(PluginRunning)
glog.V(0).Infof("%v plugin state is: %v.", nepm.devicePlugin.ResourceName(), nepm.state())
L:
select {
case fsEvent := <-nepm.fsWatcher.Events:
//glog.V(0).Info("FS EVENT: ", fsEvent)
if fsEvent.Name == nepm.kubeletSocketName {
if fsEvent.Op&fsnotify.Create == fsnotify.Create {
glog.V(0).Infof("Kubelet sock has been re/created. The plugin needs a restart.")
nepm.setState(PluginRestarting)
break L
}
}
case sig := <-nepm.sigWatcher:
switch sig {
case syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT:
glog.V(0).Infof("Terminating plugin monitor... (Reason: \"%v\")", sig)
nepm.devicePlugin.Stop()
cont = false
break L
}
}
return cont
}