diff --git a/src/go/plugin/go.d/agent/vnodes/vnodes.go b/src/go/plugin/go.d/agent/vnodes/vnodes.go index 9272f1514ec6c2..3d332c26140bb5 100644 --- a/src/go/plugin/go.d/agent/vnodes/vnodes.go +++ b/src/go/plugin/go.d/agent/vnodes/vnodes.go @@ -61,11 +61,39 @@ func (vn *Vnodes) readConfDir() { return nil } - if !d.Type().IsRegular() || !isConfigFile(path) { + if d.Type()&os.ModeSymlink != 0 { + dst, err := os.Readlink(path) + if err != nil { + vn.Warningf("failed to resolve symlink '%s': %v", path, err) + return nil + } + + if !filepath.IsAbs(dst) { + dst = filepath.Join(filepath.Dir(path), filepath.Clean(dst)) + } + + fi, err := os.Stat(dst) + if err != nil { + vn.Warningf("failed to stat resolved path '%s': %v", dst, err) + return nil + } + if !fi.Mode().IsRegular() { + vn.Debugf("'%s' is not a regular file, skipping it", dst) + return nil + } + path = dst + } else if !d.Type().IsRegular() { + vn.Debugf("'%s' is not a regular file, skipping it", path) + return nil + } + + if !isConfigFile(path) { + vn.Debugf("'%s' is not a config file (wrong extension), skipping it", path) return nil } var cfg []VirtualNode + if err := loadConfigFile(&cfg, path); err != nil { vn.Warning(err) return nil