-
Notifications
You must be signed in to change notification settings - Fork 325
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
feat(node): Add time synchronization check to setupOS #3433
base: master
Are you sure you want to change the base?
Conversation
function check_ntp() { | ||
echo "* Checking Chrony status..." | ||
|
||
systemctl is-active --quiet chrony | ||
log_and_halt_installation_on_error "$?" "Chrony service not running or not active." | ||
|
||
retries=0 | ||
max_retries=30 | ||
while [ "$(timedatectl show -p NTPSynchronized --value)" != "yes" ]; do | ||
if [ $retries -ge $max_retries ]; then | ||
local service_logs=$(journalctl -u chrony.service --no-pager) | ||
local log_message="System clock is not synchronized.\n\nChrony service logs:\n${service_logs}" | ||
log_and_halt_installation_on_error 1 "${log_message}" | ||
fi | ||
|
||
echo "* Chrony not yet synchronized. Waiting 2 seconds before retry..." | ||
sleep 2 | ||
((retries++)) | ||
done | ||
|
||
echo "* Chrony is running and time is in sync." | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reran installation a number of times on bare metal, and here are the number of chrony retries each installation took:
- 0
- 12 (24 seconds)
- 12 (24 seconds)
- 12 (24 seconds)
- 0
- 12 (24 seconds)
- 12 (24 seconds)
- 11 (22 seconds)
Is this acceptable to us? We could just roll this out and if it ever causes a false negative, roll it back. I'm not sure this is worth more of a time investment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one quick change, but otherwise looks OK to me
set_hwclock_utc | ||
check_ntp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to sync ntp first, then update the hardware clock.
NODE-1504