From 71fa34205e540d23c99586574ce8f82f880eade0 Mon Sep 17 00:00:00 2001 From: Aphral Griffin Date: Wed, 5 Feb 2025 15:29:01 +0000 Subject: [PATCH 1/3] add warning and exclude stdout and stderr --- internal/watcher/instance/nginx_config_parser.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/watcher/instance/nginx_config_parser.go b/internal/watcher/instance/nginx_config_parser.go index 505c41098..e91efd8d8 100644 --- a/internal/watcher/instance/nginx_config_parser.go +++ b/internal/watcher/instance/nginx_config_parser.go @@ -129,6 +129,10 @@ func (ncp *NginxConfigParser) createNginxConfigContext( if !ncp.ignoreLog(directive.Args[0]) { errorLog := ncp.errorLog(directive.Args[0], ncp.errorLogDirectiveLevel(directive)) nginxConfigContext.ErrorLogs = append(nginxConfigContext.ErrorLogs, errorLog) + } else { + slog.WarnContext(ctx, fmt.Sprintf("Error log outputs to %s. Unable to monitor logs during "+ + "config apply, log errors to file to enable error monitoring", directive.Args[0]), + "error_log", directive.Args[0]) } case "root": rootFiles := ncp.rootFiles(ctx, directive.Args[0]) @@ -185,7 +189,7 @@ func (ncp *NginxConfigParser) createNginxConfigContext( func (ncp *NginxConfigParser) ignoreLog(logPath string) bool { logLower := strings.ToLower(logPath) - ignoreLogs := []string{"off", "/dev/stderr", "/dev/stdout", "/dev/null"} + ignoreLogs := []string{"off", "/dev/stderr", "/dev/stdout", "/dev/null", "stderr", "stdout"} if strings.HasPrefix(logLower, "syslog:") || slices.Contains(ignoreLogs, logLower) { return true From b4d2416c8be43dc75f8e7d1265c56a66437c5de2 Mon Sep 17 00:00:00 2001 From: Aphral Griffin Date: Wed, 5 Feb 2025 16:24:08 +0000 Subject: [PATCH 2/3] add warning and exclude stdout and stderr --- internal/watcher/instance/nginx_config_parser.go | 6 +++--- .../watcher/instance/nginx_config_parser_test.go | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/internal/watcher/instance/nginx_config_parser.go b/internal/watcher/instance/nginx_config_parser.go index e91efd8d8..26e698ed6 100644 --- a/internal/watcher/instance/nginx_config_parser.go +++ b/internal/watcher/instance/nginx_config_parser.go @@ -130,9 +130,9 @@ func (ncp *NginxConfigParser) createNginxConfigContext( errorLog := ncp.errorLog(directive.Args[0], ncp.errorLogDirectiveLevel(directive)) nginxConfigContext.ErrorLogs = append(nginxConfigContext.ErrorLogs, errorLog) } else { - slog.WarnContext(ctx, fmt.Sprintf("Error log outputs to %s. Unable to monitor logs during "+ - "config apply, log errors to file to enable error monitoring", directive.Args[0]), - "error_log", directive.Args[0]) + slog.WarnContext(ctx, fmt.Sprintf("Currently error log outputs to %s. Log monitoring "+ + "is disabled while applying a config; "+"log errors to file to enable error monitoring", + directive.Args[0]), "error_log", directive.Args[0]) } case "root": rootFiles := ncp.rootFiles(ctx, directive.Args[0]) diff --git a/internal/watcher/instance/nginx_config_parser_test.go b/internal/watcher/instance/nginx_config_parser_test.go index 2c5f632d8..c0c320831 100644 --- a/internal/watcher/instance/nginx_config_parser_test.go +++ b/internal/watcher/instance/nginx_config_parser_test.go @@ -927,6 +927,20 @@ func TestNginxConfigParser_ignoreLog(t *testing.T) { expected: false, expectedLog: "Log being read is outside of allowed directories", }, + { + name: "Test 10: log stderr", + logPath: "stderr", + excludeLogs: []string{}, + expected: true, + expectedLog: "", + }, + { + name: "Test 11: log stdout", + logPath: "stdout", + excludeLogs: []string{}, + expected: true, + expectedLog: "", + }, } for _, test := range tests { From d8d728e1571504cbddd2708f086d0d55e5cae190 Mon Sep 17 00:00:00 2001 From: Aphral Griffin Date: Mon, 10 Feb 2025 14:10:18 +0000 Subject: [PATCH 3/3] clean up --- api/grpc/mpi/v1/command.pb.go | 2 +- api/grpc/mpi/v1/common.pb.go | 2 +- api/grpc/mpi/v1/files.pb.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/grpc/mpi/v1/command.pb.go b/api/grpc/mpi/v1/command.pb.go index 0e3edb591..0804228b7 100644 --- a/api/grpc/mpi/v1/command.pb.go +++ b/api/grpc/mpi/v1/command.pb.go @@ -8,7 +8,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.4 +// protoc-gen-go v1.36.5 // protoc (unknown) // source: mpi/v1/command.proto diff --git a/api/grpc/mpi/v1/common.pb.go b/api/grpc/mpi/v1/common.pb.go index 7451f04fc..1bef8b1fd 100644 --- a/api/grpc/mpi/v1/common.pb.go +++ b/api/grpc/mpi/v1/common.pb.go @@ -5,7 +5,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.4 +// protoc-gen-go v1.36.5 // protoc (unknown) // source: mpi/v1/common.proto diff --git a/api/grpc/mpi/v1/files.pb.go b/api/grpc/mpi/v1/files.pb.go index 36792a589..13b3ce5e4 100644 --- a/api/grpc/mpi/v1/files.pb.go +++ b/api/grpc/mpi/v1/files.pb.go @@ -5,7 +5,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.4 +// protoc-gen-go v1.36.5 // protoc (unknown) // source: mpi/v1/files.proto