kubernetes-sigs / ip-masq-agent

Manage IP masquerade on nodes
Apache License 2.0
217 stars 70 forks source link

Consider setting `klog.SetOutput(os.Stdout)` #168

Open jingyuanliang opened 9 hours ago

jingyuanliang commented 9 hours ago

This agent doesn't output anything to stdout by default, so it's good to do logging there (instead of stderr, see also https://github.com/kubernetes-sigs/descheduler/issues/676).

I've tried something similar to https://github.com/kubernetes-sigs/descheduler/pull/680, but it caused error messages to be repeated several times in stdout, and I don't know why.

$ bin/linux_amd64/ip-masq-agent --v=2 --logtostderr=false 2>/dev/null
I1023 23:16:56.236933  814463 ip-masq-agent.go:148] ip-masq-agent version: v2.9.2-57-ga046124-dirty
I1023 23:16:56.237033  814463 ip-masq-agent.go:151] FLAG: --add_dir_header="false"
I1023 23:16:56.237040  814463 ip-masq-agent.go:151] FLAG: --alsologtostderr="false"
I1023 23:16:56.237051  814463 ip-masq-agent.go:151] FLAG: --enable-ipv6="false"
I1023 23:16:56.237054  814463 ip-masq-agent.go:151] FLAG: --log_backtrace_at=":0"
I1023 23:16:56.237062  814463 ip-masq-agent.go:151] FLAG: --log_dir=""
I1023 23:16:56.237066  814463 ip-masq-agent.go:151] FLAG: --log_file=""
I1023 23:16:56.237070  814463 ip-masq-agent.go:151] FLAG: --log_file_max_size="1800"
I1023 23:16:56.237076  814463 ip-masq-agent.go:151] FLAG: --logtostderr="false"
I1023 23:16:56.237080  814463 ip-masq-agent.go:151] FLAG: --masq-chain="IP-MASQ-AGENT"
I1023 23:16:56.237086  814463 ip-masq-agent.go:151] FLAG: --nomasq-all-reserved-ranges="false"
I1023 23:16:56.237090  814463 ip-masq-agent.go:151] FLAG: --one_output="false"
I1023 23:16:56.237101  814463 ip-masq-agent.go:151] FLAG: --random-fully="true"
I1023 23:16:56.237105  814463 ip-masq-agent.go:151] FLAG: --skip_headers="false"
I1023 23:16:56.237110  814463 ip-masq-agent.go:151] FLAG: --skip_log_headers="false"
I1023 23:16:56.237115  814463 ip-masq-agent.go:151] FLAG: --stderrthreshold="2"
I1023 23:16:56.237120  814463 ip-masq-agent.go:151] FLAG: --to-ports=""
I1023 23:16:56.237128  814463 ip-masq-agent.go:151] FLAG: --v="2"
I1023 23:16:56.237135  814463 ip-masq-agent.go:151] FLAG: --vmodule=""
I1023 23:16:56.241322  814463 ip-masq-agent.go:245] Config file found at "/etc/config/ip-masq-agent"
E1023 23:16:56.241385  814463 ip-masq-agent.go:183] Error syncing configuration: open /etc/config/ip-masq-agent: permission denied
E1023 23:16:56.241385  814463 ip-masq-agent.go:183] Error syncing configuration: open /etc/config/ip-masq-agent: permission denied
E1023 23:16:56.241385  814463 ip-masq-agent.go:183] Error syncing configuration: open /etc/config/ip-masq-agent: permission denied
^C
$ bin/linux_amd64/ip-masq-agent --v=2 --logtostderr=false --log_file=/dev/stdout 2>/dev/null
I1023 23:16:51.053114  814390 ip-masq-agent.go:148] ip-masq-agent version: v2.9.2-57-ga046124-dirty
I1023 23:16:51.053212  814390 ip-masq-agent.go:151] FLAG: --add_dir_header="false"
I1023 23:16:51.053218  814390 ip-masq-agent.go:151] FLAG: --alsologtostderr="false"
I1023 23:16:51.053223  814390 ip-masq-agent.go:151] FLAG: --enable-ipv6="false"
I1023 23:16:51.053227  814390 ip-masq-agent.go:151] FLAG: --log_backtrace_at=":0"
I1023 23:16:51.053241  814390 ip-masq-agent.go:151] FLAG: --log_dir=""
I1023 23:16:51.053250  814390 ip-masq-agent.go:151] FLAG: --log_file="/dev/stdout"
I1023 23:16:51.053254  814390 ip-masq-agent.go:151] FLAG: --log_file_max_size="1800"
I1023 23:16:51.053258  814390 ip-masq-agent.go:151] FLAG: --logtostderr="false"
I1023 23:16:51.053262  814390 ip-masq-agent.go:151] FLAG: --masq-chain="IP-MASQ-AGENT"
I1023 23:16:51.053266  814390 ip-masq-agent.go:151] FLAG: --nomasq-all-reserved-ranges="false"
I1023 23:16:51.053272  814390 ip-masq-agent.go:151] FLAG: --one_output="false"
I1023 23:16:51.053276  814390 ip-masq-agent.go:151] FLAG: --random-fully="true"
I1023 23:16:51.053280  814390 ip-masq-agent.go:151] FLAG: --skip_headers="false"
I1023 23:16:51.053286  814390 ip-masq-agent.go:151] FLAG: --skip_log_headers="false"
I1023 23:16:51.053291  814390 ip-masq-agent.go:151] FLAG: --stderrthreshold="2"
I1023 23:16:51.053300  814390 ip-masq-agent.go:151] FLAG: --to-ports=""
I1023 23:16:51.053320  814390 ip-masq-agent.go:151] FLAG: --v="2"
I1023 23:16:51.053327  814390 ip-masq-agent.go:151] FLAG: --vmodule=""
I1023 23:16:51.057615  814390 ip-masq-agent.go:245] Config file found at "/etc/config/ip-masq-agent"
E1023 23:16:51.057654  814390 ip-masq-agent.go:183] Error syncing configuration: open /etc/config/ip-masq-agent: permission denied
^C

In the meantime, users can manually set output to stdout and it doesn't cause the same issue, as shown above.