mirror of
https://github.com/kubernetes/node-problem-detector.git
synced 2026-04-19 08:57:10 +00:00
Make sure the path to known-modules.json is relative to the
system-stats-monitor.json file
This commit is contained in:
@@ -92,7 +92,7 @@
|
||||
}
|
||||
},
|
||||
"osFeature": {
|
||||
"KnownModulesConfigPath": "config/guestosconfig/known-modules.json",
|
||||
"KnownModulesConfigPath": "guestosconfig/known-modules.json",
|
||||
"metricsConfigs": {
|
||||
"system/os_feature": {
|
||||
"displayName": "system/os_feature"
|
||||
|
||||
@@ -92,7 +92,8 @@ UnknownModules are derived from the /proc/modules compared with the known-module
|
||||
|
||||
And an option:
|
||||
`knownModulesConfigPath`: The path to the file that contains the known modules(default
|
||||
modules) can be set. By default, the path is set to `known-modules.json`
|
||||
modules) can be set. By default, the path is set to `guestosconfig/known-modules.json`
|
||||
(relative to the system-stats-monitor config path).
|
||||
|
||||
### IP Stats (Net Dev)
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package systemstatsmonitor
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
@@ -89,6 +90,12 @@ func NewSystemStatsMonitorOrDie(configPath string) types.Monitor {
|
||||
ssm.memoryCollector = NewMemoryCollectorOrDie(&ssm.config.MemoryConfig)
|
||||
}
|
||||
if len(ssm.config.OsFeatureConfig.MetricsConfigs) > 0 {
|
||||
// update the KnownModulesConfigPath to relative the system-stats-monitors path
|
||||
// only when the KnownModulesConfigPath path is relative
|
||||
if !filepath.IsAbs(ssm.config.OsFeatureConfig.KnownModulesConfigPath) {
|
||||
ssm.config.OsFeatureConfig.KnownModulesConfigPath = filepath.Join(filepath.Dir(configPath),
|
||||
ssm.config.OsFeatureConfig.KnownModulesConfigPath)
|
||||
}
|
||||
ssm.osFeatureCollector = NewOsFeatureCollectorOrDie(&ssm.config.OsFeatureConfig)
|
||||
}
|
||||
if len(ssm.config.NetConfig.MetricsConfigs) > 0 {
|
||||
|
||||
@@ -28,4 +28,4 @@ func TestRegistration(t *testing.T) {
|
||||
assert.NotPanics(t,
|
||||
func() { problemdaemon.GetProblemDaemonHandlerOrDie(SystemStatsMonitorName) },
|
||||
"System stats monitor failed to register itself as a problem daemon.")
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
var (
|
||||
defaultInvokeIntervalString = (60 * time.Second).String()
|
||||
defaultlsblkTimeoutString = (5 * time.Second).String()
|
||||
defaultKnownModulesConfigPath = "config/guestosconfig/known-modules.json"
|
||||
defaultKnownModulesConfigPath = "guestosconfig/known-modules.json"
|
||||
)
|
||||
|
||||
type MetricConfig struct {
|
||||
|
||||
@@ -44,7 +44,7 @@ func TestApplyConfiguration(t *testing.T) {
|
||||
LsblkTimeoutString: "5s",
|
||||
},
|
||||
OsFeatureConfig: OSFeatureStatsConfig{
|
||||
KnownModulesConfigPath: "config/guestosconfig/known-modules.json",
|
||||
KnownModulesConfigPath: "guestosconfig/known-modules.json",
|
||||
},
|
||||
InvokeIntervalString: "60s",
|
||||
InvokeInterval: 60 * time.Second,
|
||||
@@ -62,7 +62,7 @@ func TestApplyConfiguration(t *testing.T) {
|
||||
LsblkTimeoutString: "5s",
|
||||
},
|
||||
OsFeatureConfig: OSFeatureStatsConfig{
|
||||
KnownModulesConfigPath: "config/guestosconfig/known-modules.json",
|
||||
KnownModulesConfigPath: "guestosconfig/known-modules.json",
|
||||
},
|
||||
InvokeIntervalString: "1m0s",
|
||||
InvokeInterval: 60 * time.Second,
|
||||
@@ -79,7 +79,7 @@ func TestApplyConfiguration(t *testing.T) {
|
||||
wantedConfig: SystemStatsConfig{
|
||||
DiskConfig: DiskStatsConfig{},
|
||||
OsFeatureConfig: OSFeatureStatsConfig{
|
||||
KnownModulesConfigPath: "config/guestosconfig/known-modules.json",
|
||||
KnownModulesConfigPath: "guestosconfig/known-modules.json",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user