mirror of
https://github.com/kubernetes/node-problem-detector.git
synced 2026-08-28 01:47:20 +00:00
fix the static ckeck linter issues
This commit is contained in:
@@ -54,8 +54,8 @@ func (mc *MonitorConfig) ApplyDefaultConfiguration() {
|
||||
if mc.EnableMetricsReporting == nil {
|
||||
mc.EnableMetricsReporting = &defaultEnableMetricsReporting
|
||||
}
|
||||
if mc.WatcherConfig.Lookback == "" {
|
||||
mc.WatcherConfig.Lookback = defaultLookback
|
||||
if mc.Lookback == "" {
|
||||
mc.Lookback = defaultLookback
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ type logBuffer struct {
|
||||
// lines of patterns we support.
|
||||
func NewLogBuffer(maxLines int) *logBuffer {
|
||||
return &logBuffer{
|
||||
buffer: make([]*types.Log, maxLines, maxLines),
|
||||
msg: make([]string, maxLines, maxLines),
|
||||
buffer: make([]*types.Log, maxLines),
|
||||
msg: make([]string, maxLines),
|
||||
max: maxLines,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
|
||||
"k8s.io/node-problem-detector/pkg/problemdaemon"
|
||||
"k8s.io/node-problem-detector/pkg/problemmetrics"
|
||||
logtypes "k8s.io/node-problem-detector/pkg/systemlogmonitor/types"
|
||||
systemlogtypes "k8s.io/node-problem-detector/pkg/systemlogmonitor/types"
|
||||
"k8s.io/node-problem-detector/pkg/types"
|
||||
"k8s.io/node-problem-detector/pkg/util"
|
||||
@@ -58,7 +57,7 @@ func TestGenerateStatusForConditions(t *testing.T) {
|
||||
Transition: time.Unix(500, 500),
|
||||
},
|
||||
}
|
||||
logs := []*logtypes.Log{
|
||||
logs := []*systemlogtypes.Log{
|
||||
{
|
||||
Timestamp: time.Unix(1000, 1000),
|
||||
Message: "test message 1",
|
||||
@@ -69,12 +68,12 @@ func TestGenerateStatusForConditions(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for c, test := range []struct {
|
||||
rule logtypes.Rule
|
||||
rule systemlogtypes.Rule
|
||||
expected types.Status
|
||||
}{
|
||||
// Do not need Pattern because we don't do pattern match in this test
|
||||
{
|
||||
rule: logtypes.Rule{
|
||||
rule: systemlogtypes.Rule{
|
||||
Type: types.Perm,
|
||||
Condition: testConditionA,
|
||||
Reason: "test reason",
|
||||
@@ -102,7 +101,7 @@ func TestGenerateStatusForConditions(t *testing.T) {
|
||||
},
|
||||
// Should not update transition time when status and reason are not changed.
|
||||
{
|
||||
rule: logtypes.Rule{
|
||||
rule: systemlogtypes.Rule{
|
||||
Type: types.Perm,
|
||||
Condition: testConditionA,
|
||||
Reason: "initial reason",
|
||||
@@ -121,7 +120,7 @@ func TestGenerateStatusForConditions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
rule: logtypes.Rule{
|
||||
rule: systemlogtypes.Rule{
|
||||
Type: types.Temp,
|
||||
Reason: "test reason",
|
||||
},
|
||||
@@ -157,19 +156,19 @@ func TestGenerateStatusForMetrics(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
conditions []types.Condition
|
||||
triggeredRules []logtypes.Rule
|
||||
triggeredRules []systemlogtypes.Rule
|
||||
expectedMetrics []metrics.Int64MetricRepresentation
|
||||
}{
|
||||
{
|
||||
name: "one temporary problem that has not happened",
|
||||
conditions: []types.Condition{},
|
||||
triggeredRules: []logtypes.Rule{},
|
||||
triggeredRules: []systemlogtypes.Rule{},
|
||||
expectedMetrics: []metrics.Int64MetricRepresentation{},
|
||||
},
|
||||
{
|
||||
name: "one temporary problem happened once",
|
||||
conditions: []types.Condition{},
|
||||
triggeredRules: []logtypes.Rule{
|
||||
triggeredRules: []systemlogtypes.Rule{
|
||||
{
|
||||
Type: types.Temp,
|
||||
Reason: "problem reason foo",
|
||||
@@ -186,7 +185,7 @@ func TestGenerateStatusForMetrics(t *testing.T) {
|
||||
{
|
||||
name: "one temporary problem happened twice",
|
||||
conditions: []types.Condition{},
|
||||
triggeredRules: []logtypes.Rule{
|
||||
triggeredRules: []systemlogtypes.Rule{
|
||||
{
|
||||
Type: types.Temp,
|
||||
Reason: "problem reason foo",
|
||||
@@ -207,7 +206,7 @@ func TestGenerateStatusForMetrics(t *testing.T) {
|
||||
{
|
||||
name: "two different temporary problems happened",
|
||||
conditions: []types.Condition{},
|
||||
triggeredRules: []logtypes.Rule{
|
||||
triggeredRules: []systemlogtypes.Rule{
|
||||
{
|
||||
Type: types.Temp,
|
||||
Reason: "problem reason foo",
|
||||
@@ -238,7 +237,7 @@ func TestGenerateStatusForMetrics(t *testing.T) {
|
||||
Status: types.False,
|
||||
},
|
||||
},
|
||||
triggeredRules: []logtypes.Rule{
|
||||
triggeredRules: []systemlogtypes.Rule{
|
||||
{
|
||||
Type: types.Perm,
|
||||
Condition: "ConditionA",
|
||||
@@ -266,7 +265,7 @@ func TestGenerateStatusForMetrics(t *testing.T) {
|
||||
Status: types.False,
|
||||
},
|
||||
},
|
||||
triggeredRules: []logtypes.Rule{
|
||||
triggeredRules: []systemlogtypes.Rule{
|
||||
{
|
||||
Type: types.Perm,
|
||||
Condition: "ConditionA",
|
||||
@@ -299,7 +298,7 @@ func TestGenerateStatusForMetrics(t *testing.T) {
|
||||
Status: types.False,
|
||||
},
|
||||
},
|
||||
triggeredRules: []logtypes.Rule{
|
||||
triggeredRules: []systemlogtypes.Rule{
|
||||
{
|
||||
Type: types.Perm,
|
||||
Condition: "ConditionA",
|
||||
@@ -346,7 +345,7 @@ func TestGenerateStatusForMetrics(t *testing.T) {
|
||||
Status: types.False,
|
||||
},
|
||||
},
|
||||
triggeredRules: []logtypes.Rule{
|
||||
triggeredRules: []systemlogtypes.Rule{
|
||||
{
|
||||
Type: types.Perm,
|
||||
Condition: "ConditionA",
|
||||
@@ -397,7 +396,7 @@ func TestGenerateStatusForMetrics(t *testing.T) {
|
||||
problemmetrics.GlobalProblemMetricsManager = fakePMM
|
||||
|
||||
for _, rule := range test.triggeredRules {
|
||||
l.generateStatus([]*logtypes.Log{{}}, rule)
|
||||
l.generateStatus([]*systemlogtypes.Log{{}}, rule)
|
||||
}
|
||||
|
||||
gotMetrics := append(fakeProblemCounter.ListMetrics(), fakeProblemGauge.ListMetrics()...)
|
||||
@@ -411,17 +410,17 @@ func TestGenerateStatusForMetrics(t *testing.T) {
|
||||
func TestInitializeProblemMetricsOrDie(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
rules []logtypes.Rule
|
||||
rules []systemlogtypes.Rule
|
||||
expectedMetrics []metrics.Int64MetricRepresentation
|
||||
}{
|
||||
{
|
||||
name: "no problem type at all",
|
||||
rules: []logtypes.Rule{},
|
||||
rules: []systemlogtypes.Rule{},
|
||||
expectedMetrics: []metrics.Int64MetricRepresentation{},
|
||||
},
|
||||
{
|
||||
name: "one type of temporary problem",
|
||||
rules: []logtypes.Rule{
|
||||
rules: []systemlogtypes.Rule{
|
||||
{
|
||||
Type: types.Temp,
|
||||
Reason: "problem reason foo",
|
||||
@@ -437,7 +436,7 @@ func TestInitializeProblemMetricsOrDie(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "one type of permanent problem",
|
||||
rules: []logtypes.Rule{
|
||||
rules: []systemlogtypes.Rule{
|
||||
{
|
||||
Type: types.Perm,
|
||||
Condition: "ConditionA",
|
||||
@@ -459,7 +458,7 @@ func TestInitializeProblemMetricsOrDie(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "duplicate temporary problem types",
|
||||
rules: []logtypes.Rule{
|
||||
rules: []systemlogtypes.Rule{
|
||||
{
|
||||
Type: types.Temp,
|
||||
Reason: "problem reason foo",
|
||||
@@ -479,7 +478,7 @@ func TestInitializeProblemMetricsOrDie(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "multiple temporary problem types",
|
||||
rules: []logtypes.Rule{
|
||||
rules: []systemlogtypes.Rule{
|
||||
{
|
||||
Type: types.Temp,
|
||||
Reason: "problem reason foo",
|
||||
@@ -504,7 +503,7 @@ func TestInitializeProblemMetricsOrDie(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "multiple permanent problem types with same condition",
|
||||
rules: []logtypes.Rule{
|
||||
rules: []systemlogtypes.Rule{
|
||||
{
|
||||
Type: types.Perm,
|
||||
Condition: "ConditionA",
|
||||
@@ -541,7 +540,7 @@ func TestInitializeProblemMetricsOrDie(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "multiple permanent problem types with different conditions",
|
||||
rules: []logtypes.Rule{
|
||||
rules: []systemlogtypes.Rule{
|
||||
{
|
||||
Type: types.Perm,
|
||||
Condition: "ConditionA",
|
||||
@@ -578,7 +577,7 @@ func TestInitializeProblemMetricsOrDie(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "duplicate permanent problem types",
|
||||
rules: []logtypes.Rule{
|
||||
rules: []systemlogtypes.Rule{
|
||||
{
|
||||
Type: types.Perm,
|
||||
Condition: "ConditionA",
|
||||
@@ -605,7 +604,7 @@ func TestInitializeProblemMetricsOrDie(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "mixture of temporary and permanent problem types",
|
||||
rules: []logtypes.Rule{
|
||||
rules: []systemlogtypes.Rule{
|
||||
{
|
||||
Type: types.Temp,
|
||||
Reason: "problem reason foo",
|
||||
|
||||
Reference in New Issue
Block a user