Skip to content

Commit 3130663

Browse files
committed
Change kernel specific name in code base.
1 parent aa07cb3 commit 3130663

24 files changed

+167
-167
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", "--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,7 +26,7 @@ import (
2626
"github.com/golang/glog"
2727
"github.com/spf13/pflag"
2828

29-
"k8s.io/node-problem-detector/pkg/kernelmonitor"
29+
"k8s.io/node-problem-detector/pkg/logmonitor"
3030
"k8s.io/node-problem-detector/pkg/options"
3131
"k8s.io/node-problem-detector/pkg/problemclient"
3232
"k8s.io/node-problem-detector/pkg/problemdetector"
@@ -67,9 +67,9 @@ func main() {
6767
os.Exit(0)
6868
}
6969

70-
k := kernelmonitor.NewKernelMonitorOrDie(npdo.KernelMonitorConfigPath)
70+
l := logmonitor.NewLogMonitorOrDie(npdo.LogMonitorConfigPath)
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 {

pkg/kernelmonitor/README.md renamed to pkg/logmonitor/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/logmonitor/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 logmonitor
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/logmonitor/logwatchers/types"
21+
logtypes "k8s.io/node-problem-detector/pkg/logmonitor/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/logmonitor/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 logmonitor
1818

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

23-
"k8s.io/node-problem-detector/pkg/kernelmonitor/types"
23+
"k8s.io/node-problem-detector/pkg/logmonitor/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/logmonitor/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 logmonitor
1818

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

23-
"k8s.io/node-problem-detector/pkg/kernelmonitor/types"
23+
"k8s.io/node-problem-detector/pkg/logmonitor/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)