Prevent loading config twice in K8S (#3999)
When config dir is mounted from configmap, filepath.Walk() finds the same .conf file twice as 20-acme.conf is a link to ..data/20-acme.conf for example. This patch skips all folder names starting with '..' which is pretty uncommon and mainly used by Kubernetes mounts.
This commit is contained in:
parent
5b8401fa37
commit
af7382e224
|
@ -519,7 +519,13 @@ func (c *Config) LoadDirectory(path string) error {
|
||||||
log.Printf("W! Telegraf is not permitted to read %s", thispath)
|
log.Printf("W! Telegraf is not permitted to read %s", thispath)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
|
if strings.HasPrefix(info.Name(), "..") {
|
||||||
|
// skip Kubernetes mounts, prevening loading the same config twice
|
||||||
|
return filepath.SkipDir
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
name := info.Name()
|
name := info.Name()
|
||||||
|
|
4
internal/config/testdata/subconfig/..4984_10_04_08_28_06.119/invalid-config.conf
vendored
Normal file
4
internal/config/testdata/subconfig/..4984_10_04_08_28_06.119/invalid-config.conf
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# This invalid config file should be skipped during testing
|
||||||
|
# as it is an ..data folder
|
||||||
|
|
||||||
|
[[outputs.influxdb
|
Loading…
Reference in New Issue