Skip to content

Commit a68504b

Browse files
authored
Ignore NGINX cache manager process when looking for NGINX master process (#1058)
1 parent 4ae7de6 commit a68504b

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

internal/watcher/file/file_watcher_service.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ func (fws *FileWatcherService) isWatching(name string) bool {
180180
func (fws *FileWatcherService) handleEvent(ctx context.Context, event fsnotify.Event) {
181181
if fws.enabled.Load() {
182182
if fws.isEventSkippable(event) {
183-
slog.DebugContext(ctx, "Skipping FSNotify event", "event", event)
184183
return
185184
}
186185

@@ -238,7 +237,6 @@ func isExcludedFile(path string, excludeFiles []string) bool {
238237
slog.Error("Invalid path for excluding file", "file_path", pattern)
239238
continue
240239
} else if ok {
241-
slog.Debug("Excluding file from watcher as specified in config", "file_path", path)
242240
return true
243241
}
244242
}

internal/watcher/instance/nginx_process_parser.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,18 @@ func (npp *NginxProcessParser) Parse(ctx context.Context, processes []*nginxproc
103103
continue
104104
}
105105

106-
// proc is a master process
107-
nginxInfo, err := npp.getInfo(ctx, proc)
108-
if err != nil {
109-
slog.DebugContext(ctx, "Unable to get NGINX info", "pid", proc.PID, "error", err)
106+
// check if proc is a master process, process is not a worker but could be cache manager etc
107+
if proc.IsMaster() {
108+
nginxInfo, err := npp.getInfo(ctx, proc)
109+
if err != nil {
110+
slog.DebugContext(ctx, "Unable to get NGINX info", "pid", proc.PID, "error", err)
110111

111-
continue
112-
}
112+
continue
113+
}
113114

114-
instance := convertInfoToInstance(*nginxInfo)
115-
instanceMap[instance.GetInstanceMeta().GetInstanceId()] = instance
115+
instance := convertInfoToInstance(*nginxInfo)
116+
instanceMap[instance.GetInstanceMeta().GetInstanceId()] = instance
117+
}
116118
}
117119

118120
for _, instance := range instanceMap {

internal/watcher/instance/nginx_process_parser_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,19 @@ func TestNginxProcessParser_Parse_Processes(t *testing.T) {
352352
},
353353
expected: instancesTest4,
354354
},
355+
{
356+
name: "Test 5: 1 cache process",
357+
processes: []*nginxprocess.Process{
358+
{
359+
PID: 1234,
360+
PPID: 1,
361+
Name: "nginx",
362+
Cmd: "nginx: cache manager process",
363+
Exe: exePath,
364+
},
365+
},
366+
expected: make(map[string]*mpi.Instance),
367+
},
355368
}
356369

357370
for _, test := range tests {

0 commit comments

Comments
 (0)