Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for cooldown time in health checker plugin #444

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/healthchecker/health_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ func NewHealthChecker(hco *options.HealthCheckerOptions) (types.HealthChecker, e
// getUptimeFunc returns the time for which the given service has been running.
func getUptimeFunc(service string) func() (time.Duration, error) {
return func() (time.Duration, error) {
out, err := execCommand(types.CmdTimeout, "systemctl", "show", service, "--property=ActiveEnterTimestamp")
// Using InactiveExitTimestamp to capture the exact time when systemd tried starting the service. The service will
// transition from inactive -> activating and the timestamp is captured.
// Source : https://www.freedesktop.org/wiki/Software/systemd/dbus/
// Using ActiveEnterTimestamp resulted in race condition where the service was repeatedly killed by plugin when
// RestartSec of systemd and invoke interval of plugin got in sync. The service was repeatedly killed in
// activating state and hence ActiveEnterTimestamp was never updated.
out, err := execCommand(types.CmdTimeout, "systemctl", "show", service, "--property=InactiveExitTimestamp")
if err != nil {
return time.Duration(0), err
}
Expand Down