Logging to /dev/stdout breaks /dev/stdout after rotation occurs
dave-powell-kensho opened this issue · comments
What happened:
Set logging to stdout by passing arg --log-file=/dev/stdout
. After some hours/quantity of logs it appears that a log rotation occurs, moving the symlink /dev/stdout
and beginning a new file in its place.
Attach logs
# ls -al /dev/stdout*
-rw-------. 1 root root 67108864 Dec 19 17:55 /dev/stdout
lrwxrwxrwx. 1 root root 15 Dec 18 18:20 /dev/stdout-2023-12-19T07-40-03.471 -> /proc/self/fd/1
-rw-------. 1 root root 0 Dec 19 07:40 /dev/stdout-2023-12-19T07-40-03.471.gz
What you expected to happen:
No log rotation when logging to /dev/stdout
(or /dev/stderr
)
How to reproduce it (as minimally and precisely as possible):
Set arg --log-file=/dev/stdout
and generate enough output/wait long enough for a log rotation to take place.
Anything else we need to know?:
This is from the ECR image distribution, 602401143452.dkr.ecr.us-east-1.amazonaws.com/amazon/aws-network-policy-agent:v1.0.5
Environment:
- Kubernetes version (use
kubectl version
): v1.26.11 - CNI Version: v1.15.3
- Network Policy Agent Version: v1.0.5
- OS (e.g:
cat /etc/os-release
): Amazon Linux 2 - Kernel (e.g.
uname -a
): 5.10.192-183.736.amzn2.x86_64
@dave-powell-kensho I see that log rotate support was added in #87, which does appear to be present in v1.5.0
.
From looking at https://github.com/aws/aws-network-policy-agent/blob/main/pkg/logger/logger.go#L84, I am wondering if the problem is you using the string /dev/stdout
instead of just stdout
as the code seems to check for. Can you try stdout
?
@dave-powell-kensho I see that log rotate support was added in #87, which does appear to be present in
v1.5.0
.From looking at https://github.com/aws/aws-network-policy-agent/blob/main/pkg/logger/logger.go#L84, I am wondering if the problem is you using the string
/dev/stdout
instead of juststdout
as the code seems to check for. Can you trystdout
?
Changing to just stdout
did fix the issue. Thanks for looking into this!