Skip to content

Commit 51af3c2

Browse files
committed
Change kernel specific name in code base and change syslog to filelog.
1 parent 01334e7 commit 51af3c2

26 files changed

+194
-194
lines changed

Dockerfile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ RUN test -h /etc/localtime && rm -f /etc/localtime && cp /usr/share/zoneinfo/UTC
2020

2121
ADD ./bin/node-problem-detector /node-problem-detector
2222
ADD config /config
23-
ENTRYPOINT ["/node-problem-detector", "--kernel-monitor=/config/kernel-monitor.json"]
23+
ENTRYPOINT ["/node-problem-detector", "--system-log-monitor=/config/kernel-monitor.json"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ List of supported problem daemons:
4949

5050
| Problem Daemon | NodeCondition | Description |
5151
|----------------|:---------------:|:------------|
52-
| [KernelMonitor](https://github.com/kubernetes/node-problem-detector/tree/master/pkg/kernelmonitor) | KernelDeadlock | A problem daemon monitors kernel log and reports problem according to predefined rules. |
52+
| [KernelMonitor](https://github.com/kubernetes/node-problem-detector/tree/master/pkg/logmonitor) | KernelDeadlock | A problem daemon monitors kernel log and reports problem according to predefined rules. |
5353

5454
# Usage
5555
## Flags

cmd/node_problem_detector.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ import (
2626
"github.com/golang/glog"
2727
"github.com/spf13/pflag"
2828

29-
"k8s.io/node-problem-detector/pkg/kernelmonitor"
3029
"k8s.io/node-problem-detector/pkg/options"
3130
"k8s.io/node-problem-detector/pkg/problemclient"
3231
"k8s.io/node-problem-detector/pkg/problemdetector"
32+
"k8s.io/node-problem-detector/pkg/systemlogmonitor"
3333
"k8s.io/node-problem-detector/pkg/version"
3434
)
3535

@@ -67,9 +67,9 @@ func main() {
6767
os.Exit(0)
6868
}
6969

70-
k := kernelmonitor.NewKernelMonitorOrDie(npdo.KernelMonitorConfigPath)
70+
l := systemlogmonitor.NewLogMonitorOrDie(npdo.SystemLogMonitorConfigPath)
7171
c := problemclient.NewClientOrDie(npdo)
72-
p := problemdetector.NewProblemDetector(k, c)
72+
p := problemdetector.NewProblemDetector(l, c)
7373

7474
// Start http server.
7575
if npdo.ServerPort > 0 {

config/docker-monitor-filelog.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"plugin": "syslog",
2+
"plugin": "filelog",
33
"pluginConfig": {
44
"timestamp": "^time=\"(\\S*)\"",
55
"message": "msg=\"([^\n]*)\"",

config/kernel-monitor-filelog.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"plugin": "syslog",
2+
"plugin": "filelog",
33
"pluginConfig": {
44
"timestamp": "^.{15}",
55
"message": "kernel: \\[.*\\] (.*)",

pkg/options/options.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030
type NodeProblemDetectorOptions struct {
3131
// command line options
3232

33-
// KernelMonitorConfigPath specifies the path to kernel monitor configuration file.
34-
KernelMonitorConfigPath string
33+
// SystemLogMonitorConfigPath specifies the path to system log monitor configuration file.
34+
SystemLogMonitorConfigPath string
3535
// ApiServerOverride is the custom URI used to connect to Kubernetes ApiServer.
3636
ApiServerOverride string
3737
// PrintVersion is the flag determining whether version information is printed.
@@ -55,8 +55,8 @@ func NewNodeProblemDetectorOptions() *NodeProblemDetectorOptions {
5555

5656
// AddFlags adds node problem detector command line options to pflag.
5757
func (npdo *NodeProblemDetectorOptions) AddFlags(fs *pflag.FlagSet) {
58-
fs.StringVar(&npdo.KernelMonitorConfigPath, "kernel-monitor",
59-
"/config/kernel-monitor.json", "The path to the kernel monitor config file")
58+
fs.StringVar(&npdo.SystemLogMonitorConfigPath, "system-log-monitor",
59+
"/config/kernel-monitor.json", "The path to the system log monitor config file")
6060
fs.StringVar(&npdo.ApiServerOverride, "apiserver-override",
6161
"", "Custom URI used to connect to Kubernetes ApiServer")
6262
fs.BoolVar(&npdo.PrintVersion, "version", false, "Print version information and quit")

pkg/problemdetector/problem_detector.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
"k8s.io/kubernetes/pkg/util/clock"
2525

2626
"k8s.io/node-problem-detector/pkg/condition"
27-
"k8s.io/node-problem-detector/pkg/kernelmonitor"
2827
"k8s.io/node-problem-detector/pkg/problemclient"
28+
"k8s.io/node-problem-detector/pkg/systemlogmonitor"
2929
"k8s.io/node-problem-detector/pkg/util"
3030
)
3131

@@ -39,12 +39,12 @@ type problemDetector struct {
3939
client problemclient.Client
4040
conditionManager condition.ConditionManager
4141
// TODO(random-liu): Use slices of problem daemons if multiple monitors are needed in the future
42-
monitor kernelmonitor.KernelMonitor
42+
monitor systemlogmonitor.LogMonitor
4343
}
4444

4545
// NewProblemDetector creates the problem detector. Currently we just directly passed in the problem daemons, but
4646
// in the future we may want to let the problem daemons register themselves.
47-
func NewProblemDetector(monitor kernelmonitor.KernelMonitor, client problemclient.Client) ProblemDetector {
47+
func NewProblemDetector(monitor systemlogmonitor.LogMonitor, client problemclient.Client) ProblemDetector {
4848
return &problemDetector{
4949
client: client,
5050
conditionManager: condition.NewConditionManager(client, clock.RealClock{}),

pkg/kernelmonitor/README.md renamed to pkg/systemlogmonitor/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ with new rule definition:
4343

4444
Kernel monitor supports different log management tools with different log
4545
watchers:
46-
* [syslog](https://github.com/kubernetes/node-problem-detector/blob/master/pkg/kernelmonitor/logwatchers/syslog)
47-
* [journald](https://github.com/kubernetes/node-problem-detector/blob/master/pkg/kernelmonitor/logwatchers/journald)
46+
* [syslog](https://github.com/kubernetes/node-problem-detector/blob/master/pkg/logmonitor/logwatchers/syslog)
47+
* [journald](https://github.com/kubernetes/node-problem-detector/blob/master/pkg/logmonitor/logwatchers/journald)
4848

4949
### Change Log Path
5050

@@ -57,5 +57,5 @@ You can always configure `logPath` and volume mount to match your OS distro.
5757
### New Log Watcher
5858

5959
Kernel monitor uses [Log
60-
Watcher](https://github.com/kubernetes/node-problem-detector/blob/master/pkg/kernelmonitor/logwatchers/types/log_watcher.go) to support different log management tools.
60+
Watcher](https://github.com/kubernetes/node-problem-detector/blob/master/pkg/logmonitor/logwatchers/types/log_watcher.go) to support different log management tools.
6161
It is easy to implement a new log watcher.

pkg/kernelmonitor/config.go renamed to pkg/systemlogmonitor/config.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package kernelmonitor
17+
package systemlogmonitor
1818

1919
import (
20-
watchertypes "k8s.io/node-problem-detector/pkg/kernelmonitor/logwatchers/types"
21-
kerntypes "k8s.io/node-problem-detector/pkg/kernelmonitor/types"
20+
watchertypes "k8s.io/node-problem-detector/pkg/systemlogmonitor/logwatchers/types"
21+
logtypes "k8s.io/node-problem-detector/pkg/systemlogmonitor/types"
2222
"k8s.io/node-problem-detector/pkg/types"
2323
)
2424

25-
// MonitorConfig is the configuration of kernel monitor.
25+
// MonitorConfig is the configuration of log monitor.
2626
type MonitorConfig struct {
27-
// WatcherConfig is the configuration of kernel log watcher.
27+
// WatcherConfig is the configuration of log watcher.
2828
watchertypes.WatcherConfig
2929
// BufferSize is the size (in lines) of the log buffer.
3030
BufferSize int `json:"bufferSize"`
31-
// Source is the source name of the kernel monitor
31+
// Source is the source name of the log monitor
3232
Source string `json:"source"`
33-
// DefaultConditions are the default states of all the conditions kernel monitor should handle.
33+
// DefaultConditions are the default states of all the conditions log monitor should handle.
3434
DefaultConditions []types.Condition `json:"conditions"`
35-
// Rules are the rules kernel monitor will follow to parse the log file.
36-
Rules []kerntypes.Rule `json:"rules"`
35+
// Rules are the rules log monitor will follow to parse the log file.
36+
Rules []logtypes.Rule `json:"rules"`
3737
}
3838

3939
// applyDefaultConfiguration applies default configurations.

pkg/kernelmonitor/log_buffer.go renamed to pkg/systemlogmonitor/log_buffer.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package kernelmonitor
17+
package systemlogmonitor
1818

1919
import (
2020
"regexp"
2121
"strings"
2222

23-
"k8s.io/node-problem-detector/pkg/kernelmonitor/types"
23+
"k8s.io/node-problem-detector/pkg/systemlogmonitor/types"
2424
)
2525

2626
// LogBuffer buffers the logs and supports match in the log buffer with regular expression.
2727
type LogBuffer interface {
2828
// Push pushes log into the log buffer.
29-
Push(*types.KernelLog)
29+
Push(*types.Log)
3030
// Match with regular expression in the log buffer.
31-
Match(string) []*types.KernelLog
31+
Match(string) []*types.Log
3232
// String returns a concatenated string of the buffered logs.
3333
String() string
3434
}
3535

3636
type logBuffer struct {
3737
// buffer is a simple ring buffer.
38-
buffer []*types.KernelLog
38+
buffer []*types.Log
3939
msg []string
4040
max int
4141
current int
@@ -47,20 +47,20 @@ type logBuffer struct {
4747
// lines of patterns we support.
4848
func NewLogBuffer(maxLines int) *logBuffer {
4949
return &logBuffer{
50-
buffer: make([]*types.KernelLog, maxLines, maxLines),
50+
buffer: make([]*types.Log, maxLines, maxLines),
5151
msg: make([]string, maxLines, maxLines),
5252
max: maxLines,
5353
}
5454
}
5555

56-
func (b *logBuffer) Push(log *types.KernelLog) {
56+
func (b *logBuffer) Push(log *types.Log) {
5757
b.buffer[b.current%b.max] = log
5858
b.msg[b.current%b.max] = log.Message
5959
b.current++
6060
}
6161

6262
// TODO(random-liu): Cache regexp if garbage collection becomes a problem someday.
63-
func (b *logBuffer) Match(expr string) []*types.KernelLog {
63+
func (b *logBuffer) Match(expr string) []*types.Log {
6464
// The expression should be checked outside, and it must match to the end.
6565
reg := regexp.MustCompile(expr + `\z`)
6666
log := b.String()
@@ -72,7 +72,7 @@ func (b *logBuffer) Match(expr string) []*types.KernelLog {
7272
// reverse index
7373
s := len(log) - loc[0] - 1
7474
total := 0
75-
matched := []*types.KernelLog{}
75+
matched := []*types.Log{}
7676
for i := b.tail(); i >= b.current && b.buffer[i%b.max] != nil; i-- {
7777
matched = append(matched, b.buffer[i%b.max])
7878
total += len(b.msg[i%b.max]) + 1 // Add '\n'

pkg/kernelmonitor/log_buffer_test.go renamed to pkg/systemlogmonitor/log_buffer_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package kernelmonitor
17+
package systemlogmonitor
1818

1919
import (
2020
"reflect"
2121
"testing"
2222

23-
"k8s.io/node-problem-detector/pkg/kernelmonitor/types"
23+
"k8s.io/node-problem-detector/pkg/systemlogmonitor/types"
2424
)
2525

2626
func TestPush(t *testing.T) {
@@ -52,7 +52,7 @@ func TestPush(t *testing.T) {
5252
} {
5353
b := NewLogBuffer(test.max)
5454
for _, log := range test.logs {
55-
b.Push(&types.KernelLog{Message: log})
55+
b.Push(&types.Log{Message: log})
5656
}
5757
got := b.String()
5858
if test.expected != got {
@@ -94,13 +94,13 @@ func TestMatch(t *testing.T) {
9494
} {
9595
b := NewLogBuffer(max)
9696
for _, log := range test.logs {
97-
b.Push(&types.KernelLog{Message: log})
97+
b.Push(&types.Log{Message: log})
9898
}
9999
for i, expr := range test.exprs {
100-
kLogs := b.Match(expr)
100+
logs := b.Match(expr)
101101
got := []string{}
102-
for _, kLog := range kLogs {
103-
got = append(got, kLog.Message)
102+
for _, log := range logs {
103+
got = append(got, log.Message)
104104
}
105105
if !reflect.DeepEqual(test.expected[i], got) {
106106
t.Errorf("case %d.%d: expected %v, got %v", c+1, i+1, test.expected[i], got)

0 commit comments

Comments
 (0)