diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-11-25 17:33:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-11-25 17:34:10 +0000 |
commit | 83ba6762cc43d9db581b979bb5e3445669e46cc2 (patch) | |
tree | 2e69833b43f791ed253a7a20318b767ebe56cdb8 /src/go/plugin/go.d/agent/vnodes | |
parent | Releasing debian version 1.47.5-1. (diff) | |
download | netdata-83ba6762cc43d9db581b979bb5e3445669e46cc2.tar.xz netdata-83ba6762cc43d9db581b979bb5e3445669e46cc2.zip |
Merging upstream version 2.0.3+dfsg (Closes: #923993, #1042533, #1045145).
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/go/plugin/go.d/agent/vnodes')
-rw-r--r-- | src/go/plugin/go.d/agent/vnodes/vnodes.go | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/go/plugin/go.d/agent/vnodes/vnodes.go b/src/go/plugin/go.d/agent/vnodes/vnodes.go index 3d332c261..2c0027b88 100644 --- a/src/go/plugin/go.d/agent/vnodes/vnodes.go +++ b/src/go/plugin/go.d/agent/vnodes/vnodes.go @@ -11,11 +11,10 @@ import ( "github.com/netdata/netdata/go/plugins/logger" + "github.com/google/uuid" "gopkg.in/yaml.v2" ) -var Disabled = false // TODO: remove after Netdata v1.39.0. Fix for "from source" stable-channel installations. - func New(confDir string) *Vnodes { vn := &Vnodes{ Logger: logger.New().With( @@ -39,9 +38,9 @@ type ( vnodes map[string]*VirtualNode } VirtualNode struct { - GUID string `yaml:"guid"` - Hostname string `yaml:"hostname"` - Labels map[string]string `yaml:"labels"` + GUID string `yaml:"guid" json:"guid"` + Hostname string `yaml:"hostname" json:"hostname"` + Labels map[string]string `yaml:"labels" json:"labels"` } ) @@ -101,7 +100,11 @@ func (vn *Vnodes) readConfDir() { for _, v := range cfg { if v.Hostname == "" || v.GUID == "" { - vn.Warningf("skipping virtual node '%+v': some required fields are missing (%s)", v, path) + vn.Warningf("skipping virtual node '%+v': required fields are missing (%s)", v, path) + continue + } + if err := uuid.Validate(v.GUID); err != nil { + vn.Warningf("skipping virtual node '%+v': invalid GUID: %v (%s)", v, err, path) continue } if _, ok := vn.vnodes[v.Hostname]; ok { @@ -127,7 +130,7 @@ func isConfigFile(path string) bool { } } -func loadConfigFile(conf interface{}, path string) error { +func loadConfigFile(conf any, path string) error { f, err := os.Open(path) if err != nil { return err |