Commit 53990922 authored by Damian Johnson's avatar Damian Johnson
Browse files

Check for clock skew

Roger had the great suggestion that we should check for clock skew...

  https://trac.torproject.org/projects/tor/ticket/25768

Expanded stem a bit along with this to surface response headers.
parent 93c3a9b4
Loading
Loading
Loading
Loading
+10 −3
Changes for consensus_health_checker.py: 10 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -927,7 +927,7 @@ def get_votes():


def _get_documents(label, resource):
  documents, times_taken, issues = {}, {}, []
  documents, times_taken, clock_skew, issues = {}, {}, {}, []

  for authority in DIRECTORY_AUTHORITIES.values():
    if authority.v3ident is None:
@@ -940,9 +940,12 @@ def _get_documents(label, resource):
    )

    try:
      start_time = time.time()
      start_time = datetime.datetime.utcnow()
      documents[authority.nickname] = query.run()[0]
      times_taken[authority.nickname] = time.time() - start_time
      response_timestamp = datetime.datetime.strptime(query.reply_headers.get('date'), '%a, %d %b %Y %H:%M:%S %Z')

      times_taken[authority.nickname] = (datetime.datetime.utcnow() - start_time).total_seconds()
      clock_skew[authority.nickname] = abs((start_time - response_timestamp).total_seconds())
    except Exception as exc:
      issues.append(Issue(Runlevel.ERROR, 'AUTHORITY_UNAVAILABLE', fetch_type = label, authority = authority.nickname, url = query.download_url, error = exc, to = [authority.nickname]))

@@ -954,6 +957,10 @@ def _get_documents(label, resource):
      if time_taken > median_time * 5:
        issues.append(Issue(Runlevel.NOTICE, 'LATENCY', authority = nickname, time_taken = '%0.1fs' % time_taken, median_time = '%0.1fs' % median_time, authority_times = authority_times, to = [nickname]))

    for nickname, difference in clock_skew.items():
      if difference > 10:
        issues.append(Issue(Runlevel.NOTICE, 'CLOCK_SKEW', authority = nickname, difference = difference, to = [nickname]))

  return documents, issues


+1 −0
Changes for data/consensus_health.cfg: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
# message templates for notifications we send

msg LATENCY => Downloading the consensus from {authority} took {time_taken}. Median download time is {median_time}: {authority_times}
msg CLOCK_SKEW => The system clock of {authority} is {difference} seconds off
msg MISSING_LATEST_CONSENSUS => The consensuses published by the following directory authorities are more than one hour old and therefore not fresh anymore: {authorities}
msg MISSING_AUTHORITY_DESC => {authority} is missing the server descriptor of {peer}
msg CONSENSUS_METHOD_UNSUPPORTED => The following directory authorities do not support the consensus method that the consensus uses: {authorities}