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
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion lib/pharos/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ def self.format_exception(exc, severity = "ERROR")
backtrace = "\n #{exc.backtrace.join("\n ")}"
end

"Error: #{exc.message.strip}#{backtrace}"
if exc.is_a?(Excon::Errors::CertificateError)
"Error: #{exc.message.lines.first[/(.+?\))/, 1]}#{backtrace}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really safe? Does excon always have (something) in place that we can use for search?

else
"Error: #{exc.message.strip}#{backtrace}"
end
end

def self.log_level
Expand Down
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