fix(go.d): try rel path before checking well-known path for user and stock dirs (#20912)
Ilya Mashchenko committed
Sep 2, 2025 at 17:10 UTC
0c4f09f1cffc126ec4a859863b7fd1da8c63e59a
1 file changed
+14
-2
src/go/plugin/go.d/pkg/pluginconfig/pluginconfig.go
+14
-2
@@ -135,6 +135,12 @@ func (d *directories) initUserRoots(opts *cli.Option, env envData, execDir strin
135
return
136
}
137
138
+ relDir := safePathClean(filepath.Join(execDir, "..", "..", "..", "..", "etc", "netdata"))
139
+ if isDirExists(relDir) {
140
+ d.userConfigDirs = multipath.New(relDir)
141
+ return
142
+ }
143
+
144
// 3) Fallback if empty
145
for _, dir := range []string{
146
handleDirOnWin(env.cygwinBase, "/etc/netdata", execDir),
@@ -146,7 +152,7 @@ func (d *directories) initUserRoots(opts *cli.Option, env envData, execDir strin
152
}
153
}
154
149
- d.userConfigDirs = multipath.New(filepath.Join(execDir, "..", "..", "..", "..", "etc", "netdata"))
155
+ d.userConfigDirs = multipath.New(relDir)
156
}
157
158
// Build step 2: initialize single "stock" root: env, common locations, build-relative fallback.
@@ -156,6 +162,12 @@ func (d *directories) initStockRoot(env envData, execDir string) {
162
return
163
}
164
165
+ relDir := safePathClean(filepath.Join(execDir, "..", "..", "..", "..", "usr", "lib", "netdata", "conf.d"))
166
+ if isDirExists(relDir) {
167
+ d.stockConfigDir = relDir
168
+ return
169
+ }
170
+
171
for _, dir := range []string{
172
handleDirOnWin(env.cygwinBase, "/usr/lib/netdata/conf.d", execDir),
173
handleDirOnWin(env.cygwinBase, "/opt/netdata/usr/lib/netdata/conf.d", execDir),
@@ -166,7 +178,7 @@ func (d *directories) initStockRoot(env envData, execDir string) {
178
}
179
}
180
169
- d.stockConfigDir = filepath.Join(execDir, "..", "..", "..", "..", "usr", "lib", "netdata", "conf.d")
181
+ d.stockConfigDir = relDir
182
}
183
184
// Build step 3: derive collectors dirs from roots.