Merge pull request #299 from xueweiz/start

Correctly identify failures in problem daemon starting.
This commit is contained in:
Kubernetes Prow Robot
2019-06-27 10:47:22 -07:00
committed by GitHub
3 changed files with 9 additions and 6 deletions

View File

@@ -22,8 +22,8 @@ import (
"github.com/golang/glog"
"github.com/spf13/pflag"
"k8s.io/node-problem-detector/cmd/options"
_ "k8s.io/node-problem-detector/cmd/nodeproblemdetector/problemdaemonplugins"
"k8s.io/node-problem-detector/cmd/options"
"k8s.io/node-problem-detector/pkg/exporters/k8sexporter"
"k8s.io/node-problem-detector/pkg/exporters/prometheusexporter"
"k8s.io/node-problem-detector/pkg/problemdaemon"

View File

@@ -47,18 +47,20 @@ func NewProblemDetector(monitors []types.Monitor, exporters []types.Exporter) Pr
func (p *problemDetector) Run() error {
// Start the log monitors one by one.
var chans []<-chan *types.Status
failureCount := 0
for _, m := range p.monitors {
ch, err := m.Start()
if err != nil {
// Do not return error and keep on trying the following config files.
glog.Errorf("Failed to start problem daemon %v: %v", m, err)
failureCount += 1
continue
}
if ch != nil {
chans = append(chans, ch)
}
}
if len(chans) == 0 {
if len(p.monitors) == failureCount {
return fmt.Errorf("no problem daemon is successfully setup")
}
ch := groupChannel(chans)

View File

@@ -99,12 +99,13 @@ const (
Perm Type = "permanent"
)
// Monitor monitors log and custom plugins and reports node problem condition and event according to
// the rules.
// Monitor monitors the system and reports problems and metrics according to the rules.
type Monitor interface {
// Start starts the log monitor.
// Start starts the monitor.
// The Status channel is used to report problems. If the Monitor does not report any
// problem (i.e. metrics reporting only), the channel should be set to nil.
Start() (<-chan *Status, error)
// Stop stops the log monitor.
// Stop stops the monitor.
Stop()
}