fix(go.d/sd): skip unsupported discoverer configs (#21818)
Ilya Mashchenko committed
Feb 25, 2026 at 16:33 UTC
e0dad9f2b1c62603bbc4d46d6d9c4d1e9cff8329
3 files changed
+32
-3
src/go/plugin/agent/discovery/sd/sd.go
+6
@@ -238,6 +238,12 @@ func (d *ServiceDiscovery) addPipeline(ctx context.Context, conf confFile) {
238
d.Errorf("config '%s' has no discoverer configured", conf.source)
239
return
240
}
241
+ if !d.hasDiscovererType(scfg.DiscovererType()) {
242
+ if scfg.SourceType() != confgroup.TypeStock {
243
+ d.Warningf("config '%s' uses unsupported discoverer type '%s', skipping", conf.source, scfg.DiscovererType())
244
+ }
245
+ return
246
+ }
247
248
if scfg.Name() == "" {
249
d.Errorf("config '%s' has no name configured", conf.source)
src/go/plugin/agent/discovery/sd/sd_test.go
+25
@@ -83,6 +83,17 @@ func TestServiceDiscovery_Run(t *testing.T) {
83
}
84
}
85
86
+func TestServiceDiscovery_UnsupportedDiscovererConfigIsIgnored(t *testing.T) {
87
+ sim := &discoverySimExt{
88
+ configs: []confFile{
89
+ prepareUnsupportedDiscovererConfigFile("/usr/lib/netdata/conf.d/sd/unsupported.conf", "unsupported"),
90
+ },
91
+ wantPipelines: nil,
92
+ wantExposedCount: 0,
93
+ }
94
+ sim.run(t)
95
+}
96
+
97
func prepareConfigFile(source, name string) confFile {
98
disc, _ := pipeline.NewDiscovererPayload(testDiscovererTypeNetListeners, testNetListenersConfig{})
99
cfg := pipeline.Config{
@@ -97,6 +108,20 @@ func prepareConfigFile(source, name string) confFile {
108
}
109
}
110
111
+func prepareUnsupportedDiscovererConfigFile(source, name string) confFile {
112
+ disc, _ := pipeline.NewDiscovererPayload("unsupported", map[string]any{})
113
+ cfg := pipeline.Config{
114
+ Name: name,
115
+ Discoverer: disc,
116
+ }
117
+ bs, _ := yaml.Marshal(cfg)
118
+
119
+ return confFile{
120
+ source: source,
121
+ content: bs,
122
+ }
123
+}
124
+
125
func prepareEmptyConfigFile(source string) confFile {
126
return confFile{
127
source: source,
src/go/plugin/agent/discovery/sd/sim_test.go
+1
-3
@@ -108,9 +108,7 @@ func (sim *discoverySimExt) run(t *testing.T) {
108
109
// Check exposed configs after SD goroutine has stopped (no race on entry.Status).
110
// Caches survive shutdown — StopAll only stops pipelines, doesn't clear caches.
111
- if sim.wantExposedCount > 0 {
112
- assert.Equal(t, sim.wantExposedCount, mgr.exposed.Count(), "exposed configs count")
113
- }
111
+ assert.Equal(t, sim.wantExposedCount, mgr.exposed.Count(), "exposed configs count")
112
for _, want := range sim.wantExposed {
113
entry, ok := mgr.exposed.LookupByKey(want.discovererType + ":" + want.name)
114
if !assert.Truef(t, ok, "exposed config '%s:%s' not found", want.discovererType, want.name) {