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

Warn if local clock and host clock are out of sync #1448

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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
11 changes: 11 additions & 0 deletions lib/pharos/phases/validate_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class ValidateHost < Pharos::Phase
title "Validate hosts"

def call
logger.info { "Validating localhost and host clock sync ..." }
check_clock
logger.info { "Validating current role matches ..." }
check_role
logger.info { "Validating distro and version ..." }
Expand All @@ -22,6 +24,15 @@ def call
validate_peer_address
end

def check_clock
local_time = Time.now.to_i
server_time = transport.exec!('date +%s').to_i

return if (server_time - local_time).abs < 60

logger.warn "Clock drift #{(server_time - local_time).abs} seconds - certificate validation may fail"
end

def check_distro_version
return if host_configurer

Expand Down