Skip to content

Commit f56d0a9

Browse files
committed
Use InactiveExitTimestamp instead of ActiveEnterTimestamp for cooldown
period in health check monitor.
1 parent 061e977 commit f56d0a9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/healthchecker/health_checker.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ func NewHealthChecker(hco *options.HealthCheckerOptions) (types.HealthChecker, e
5959
// getUptimeFunc returns the time for which the given service has been running.
6060
func getUptimeFunc(service string) func() (time.Duration, error) {
6161
return func() (time.Duration, error) {
62-
out, err := execCommand(types.CmdTimeout, "systemctl", "show", service, "--property=ActiveEnterTimestamp")
62+
// Using InactiveExitTimestamp to capture the exact time when systemd tried starting the service. The service will
63+
// transition from inactive -> activating and the timestamp is captured.
64+
// Source : https://www.freedesktop.org/wiki/Software/systemd/dbus/
65+
// Using ActiveEnterTimestamp resulted in race condition where the service was repeatedly killed by plugin when
66+
// RestartSec of systemd and invoke interval of plugin got in sync. The service was repeatedly killed in
67+
// activating state and hence ActiveEnterTimestamp was never updated.
68+
out, err := execCommand(types.CmdTimeout, "systemctl", "show", service, "--property=InactiveExitTimestamp")
6369
if err != nil {
6470
return time.Duration(0), err
6571
}

0 commit comments

Comments
 (0)