Skip to content

Commit 8b137c4

Browse files
authored
Ignore stdout & stderr logs and log warning (#973)
1 parent 4c8ba7e commit 8b137c4

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

api/grpc/mpi/v1/command.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/grpc/mpi/v1/common.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/grpc/mpi/v1/files.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/watcher/instance/nginx_config_parser.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ func (ncp *NginxConfigParser) createNginxConfigContext(
129129
if !ncp.ignoreLog(directive.Args[0]) {
130130
errorLog := ncp.errorLog(directive.Args[0], ncp.errorLogDirectiveLevel(directive))
131131
nginxConfigContext.ErrorLogs = append(nginxConfigContext.ErrorLogs, errorLog)
132+
} else {
133+
slog.WarnContext(ctx, fmt.Sprintf("Currently error log outputs to %s. Log monitoring "+
134+
"is disabled while applying a config; "+"log errors to file to enable error monitoring",
135+
directive.Args[0]), "error_log", directive.Args[0])
132136
}
133137
case "root":
134138
rootFiles := ncp.rootFiles(ctx, directive.Args[0])
@@ -185,7 +189,7 @@ func (ncp *NginxConfigParser) createNginxConfigContext(
185189

186190
func (ncp *NginxConfigParser) ignoreLog(logPath string) bool {
187191
logLower := strings.ToLower(logPath)
188-
ignoreLogs := []string{"off", "/dev/stderr", "/dev/stdout", "/dev/null"}
192+
ignoreLogs := []string{"off", "/dev/stderr", "/dev/stdout", "/dev/null", "stderr", "stdout"}
189193

190194
if strings.HasPrefix(logLower, "syslog:") || slices.Contains(ignoreLogs, logLower) {
191195
return true

internal/watcher/instance/nginx_config_parser_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,20 @@ func TestNginxConfigParser_ignoreLog(t *testing.T) {
927927
expected: false,
928928
expectedLog: "Log being read is outside of allowed directories",
929929
},
930+
{
931+
name: "Test 10: log stderr",
932+
logPath: "stderr",
933+
excludeLogs: []string{},
934+
expected: true,
935+
expectedLog: "",
936+
},
937+
{
938+
name: "Test 11: log stdout",
939+
logPath: "stdout",
940+
excludeLogs: []string{},
941+
expected: true,
942+
expectedLog: "",
943+
},
930944
}
931945

932946
for _, test := range tests {

0 commit comments

Comments
 (0)