Skip to content

Commit

Permalink
[PLAT-15593][PLAT-15544] fixed some health check issues around clock …
Browse files Browse the repository at this point in the history
…sync.

Summary:
First there is an issue with how we get clock drift from ntpq. Fixed error in the command ran.

Second, there is an issue with how we detect if a service file exists. We also need to validate
if the command returned "Error".

Test Plan:
validated health checks pass for non-systemd universes
validated ntpq gets clock drift correctly

Reviewers: nsingh, muthu, yash.priyam, ysharmar

Reviewed By: muthu

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D38679
  • Loading branch information
shubin-yb committed Oct 7, 2024
1 parent 54eb6c4 commit 2ea2a13
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions managed/src/main/resources/health/node_health.py.template
Original file line number Diff line number Diff line change
Expand Up @@ -1880,10 +1880,10 @@ class NodeChecker():
root_out = self._check_output(root_cmd)
user_out = self._check_output(user_cmd)
success = True
if "0 unit files listed" not in root_out:
if "0 unit files listed" not in root_out and "Error" not in root_out:
if not self._check_unit_for_preexec(service, user=False):
errors.append("%s has no clock_sync script ExecStartPre" % service)
elif "0 unit files listed" not in user_out:
elif "0 unit files listed" not in user_out and "Error" not in user_out:
if not self._check_unit_for_preexec(service, user=True):
errors.append("%s has no clock_sync script ExecStartPre" % service)
else:
Expand Down Expand Up @@ -2134,7 +2134,7 @@ def _ntp_get_clock_drift_ms():
ntp_out = check_output("systemctl status ntp.service", env)
ntpd_out = check_output("systemctl status ntpd.service", env)
if "Active: active" in ntp_out or "Active: active" in ntpd_out:
out = check_output("ntpq -p | awk 'NR==3' {print $9}'", env)
out = check_output("ntpq -p | awk 'NR==3 {print $9}'", env)
if "Error" not in out:
return int(float(out)*1000) # Convert seconds to milliseconds
return "Failed to get clock drift from ntp(d)"
Expand Down

0 comments on commit 2ea2a13

Please sign in to comment.