Add existing monitors into the problem daemon registration hook.

This commit is contained in:
Xuewei Zhang
2019-06-13 00:51:17 -07:00
parent 63f0e35e56
commit a07176073a
9 changed files with 435 additions and 32 deletions
+11
View File
@@ -23,6 +23,7 @@ import (
"github.com/golang/glog"
"k8s.io/node-problem-detector/pkg/problemdaemon"
"k8s.io/node-problem-detector/pkg/systemlogmonitor/logwatchers"
watchertypes "k8s.io/node-problem-detector/pkg/systemlogmonitor/logwatchers/types"
logtypes "k8s.io/node-problem-detector/pkg/systemlogmonitor/types"
@@ -32,6 +33,16 @@ import (
"k8s.io/node-problem-detector/pkg/util/tomb"
)
const SystemLogMonitorName = "system-log-monitor"
func init() {
problemdaemon.Register(
SystemLogMonitorName,
types.ProblemDaemonHandler{
CreateProblemDaemonOrDie: NewLogMonitorOrDie,
CmdOptionDescription: "Set to config file paths."})
}
type logMonitor struct {
watcher watchertypes.LogWatcher
buffer LogBuffer
+9
View File
@@ -21,6 +21,9 @@ import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"k8s.io/node-problem-detector/pkg/problemdaemon"
logtypes "k8s.io/node-problem-detector/pkg/systemlogmonitor/types"
"k8s.io/node-problem-detector/pkg/types"
"k8s.io/node-problem-detector/pkg/util"
@@ -32,6 +35,12 @@ const (
testConditionB = "TestConditionB"
)
func TestRegistration(t *testing.T) {
assert.NotPanics(t,
func() { problemdaemon.GetProblemDaemonHandlerOrDie("system-log-monitor") },
"System log monitor failed to register itself as a problem daemon.")
}
func TestGenerateStatus(t *testing.T) {
initConditions := []types.Condition{
{