Reduce default ec2net syslog noise; add optional debug logging#140
Reduce default ec2net syslog noise; add optional debug logging#140mjnowen wants to merge 1 commit intoamazonlinux:mainfrom
Conversation
Reduces repetitive IMDS/config messages in syslog while keeping operational info and errors. Debug can be enabled via systemd Environment= or in-script. - Gate debug() on EC2_NET_UTILS_DEBUG so debug messages are off by default - Document EC2_NET_UTILS_DEBUG at top of lib.sh (env or uncomment for local debug) - Reclassify "No addresses found" from info to debug (routine on primary/refresh) - Keep info/error unchanged; enable full debug with EC2_NET_UTILS_DEBUG=1
|
Feel like some of the debug logs like |
Hmmm, this is exactly the kind of log messages we are trying to not silence, just quieten via the |
|
Seems like we should be using built in syslog functionality rather than an enivornment variable. These logs are not needed 99% of the time but It does helps us track down race conditions live and catches them when they happen. |
Summary
Reduce default logging from
amazon-ec2-net-utilsso normal operation produces fewer ec2net lines in syslog, while keeping important info/error messages and making full debug output available when needed.Problem
On systems using the package (e.g. Ubuntu with systemd-networkd), ec2net logs many lines on every refresh: IMDS token and metadata queries, config file reuse, and "No addresses found" for the primary interface. That happens on every timer run and can dominate syslog, making it harder to spot real issues.
Changes
Optional debug logging
debug()inlib/lib.shonly callslog debug "$@"whenEC2_NET_UTILS_DEBUGis set (non-empty).Documentation and default at top of lib.sh
EC2_NET_UTILS_DEBUG.# EC2_NET_UTILS_DEBUG=1for temporary local debugging.: "${EC2_NET_UTILS_DEBUG:=}"so the variable is defaulted when unset; if systemd (or the script) sets it, that value is kept."No addresses found" reclassified
create_rules(), the message is changed frominfo()todebug()and uses${iface}instead of${ether}.Behaviour
EC2_NET_UTILS_DEBUG=1(or any non-empty value) via systemd (e.g.Environment=EC2_NET_UTILS_DEBUG=1in a unit override) or by uncommenting the line inlib.shfor local runs. All current debug messages (IMDS, config reuse, "No addresses found", etc.) are then logged.Testing
EC2_NET_UTILS_DEBUG; syslog should show only info/error from ec2net.Fixed:
EC2_NET_UTILS_DEBUG=1for the service or in the script and run refresh; previous verbose ec2net lines should appear again.With
EC2_NET_UTILS_DEBUG=1enabled, the syslog now looks like this:By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.