caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
55.45k stars 3.91k forks source link

Active health check logs on every check instead of state change #6415

Open klaxa opened 1 week ago

klaxa commented 1 week ago

Hello, first of all thanks for caddy, I enjoy using it!

I recently updated from 2.7.6 to 2.8.4, because I required the behavior of not following HTTP redirects on active health checks and noticed that, as opposed to 2.7.6, the newer version logs the host status on every active check when the host is up instead of only when the state changes from down to up.

I investigated the source and found that the logic was changed between the versions. In 2.7.6 the log was written when the event was emitted (https://github.com/caddyserver/caddy/blob/v2.7.6/modules/caddyhttp/reverseproxy/healthchecks.go#L443) while in 2.8.4 the emitting of the event was refactored into markHealthy() with the logging being moved to a higher level (https://github.com/caddyserver/caddy/blob/v2.8.4/modules/caddyhttp/reverseproxy/healthchecks.go#L495)

I am not sure this is the intended behavior as it fills the log quickly with identical messages (except for the timestamp of course).

I think the simplest solution would be to move the logging of "host is up" (L495) into markHealthy() (after L428) because it checks for the previous state before emitting the event.

Thank you and best regards!

klaxa commented 15 hours ago

Ping?