Merge "Basic time sync if required on subcloud install"
This commit is contained in:
commit
b8f7d1ecac
@ -792,6 +792,43 @@ function parse_miniboot_network_params()
|
||||
export BOOTPARAM_DNS
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
# Name : wait_for_interface
|
||||
# Purpose : Wait for interface to settle
|
||||
# Parameter: interface name
|
||||
# Return : Nothing
|
||||
#########################################################################
|
||||
function wait_for_interface()
|
||||
{
|
||||
local ifname=\$1
|
||||
local timeout=\${2:-60}
|
||||
local operstate=
|
||||
local count_sec=0
|
||||
ilog "Waiting for interface \${ifname} to settle... [timeout: \${timeout}s]"
|
||||
while [ \${count_sec} -lt \${timeout} ]; do
|
||||
sleep 1
|
||||
if [ -e /sys/class/net/\${mgmt_dev}/operstate ]; then
|
||||
operstate=\$(cat /sys/class/net/\${mgmt_dev}/operstate)
|
||||
if [ "\$operstate" = up ]; then
|
||||
ilog "\${mgmt_dev} operstate: up"
|
||||
return
|
||||
fi
|
||||
dlog "\${mgmt_dev} operstate: \$operstate"
|
||||
fi
|
||||
count_sec=\$(( count_sec + 1 ))
|
||||
done
|
||||
case "\$operstate" in
|
||||
unknown)
|
||||
# see: https://www.kernel.org/doc/Documentation/networking/operstates.txt
|
||||
wlog "Timeout: \${mgmt_dev} operstate: unknown. Allowing boot to continue."
|
||||
return
|
||||
;;
|
||||
*)
|
||||
report_failure_with_msg "Timeout waiting for interface \${ifname} to settle; operstate: \$operstate"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Global Kickstart Constants #
|
||||
##########################################################################
|
||||
@ -1027,6 +1064,53 @@ check_execs
|
||||
# TODO: The installer does not have 'timezone'
|
||||
# Does LAT handle this ?
|
||||
wlog "timezone not set ; 'timezone --nontp --utc UTC'"
|
||||
|
||||
# We need both the system date and hwclock to be "close" to the current
|
||||
# date/time, in order to avoid cases of invalid SSL certificates during
|
||||
# interaction with the system controller. With the 'instdate'
|
||||
# boot paramter, the system clock will already be initialized by LAT.
|
||||
# If the hwclock differs from system date by a significant amount then
|
||||
# we update it here based on the current system date.
|
||||
#
|
||||
# System date initialization summary:
|
||||
# Note: NTP is not running at these early stages of install
|
||||
#
|
||||
# miniboot:
|
||||
# - The system date is initialized to 'instdate' via LAT.
|
||||
# Note that this may be several minutes out of sync with reality
|
||||
# since instdate is a snapshot at time of bootimage.iso creation.
|
||||
#
|
||||
# ostree boot (after miniboot, prior to subcloud bootstrap):
|
||||
# - The system date is initialized via hwclock.
|
||||
#
|
||||
# During miniboot we may have the case where the hwclock is more accurate
|
||||
# than the system date. We therefore only want to adjust the hwclock if
|
||||
# it is significantly different.
|
||||
if [ -n "${instdate}" ]; then
|
||||
ilog "Checking hwclock: $(hwclock), current date: $(date), instdate: $(date --date=${instdate})"
|
||||
# Only adjust if date mismatch is > 20m
|
||||
date_mismatch_threshold_secs=1200
|
||||
current_date_epoch=$(date "+%s")
|
||||
hwclock_date_epoch=$(date --date="$(hwclock --get --utc)" "+%s")
|
||||
diff_epoch=$(( current_date_epoch - hwclock_date_epoch ))
|
||||
# absolute value: strip off any '-' from front of string:
|
||||
abs_diff_epoch=${diff_epoch#-}
|
||||
if [ ${abs_diff_epoch} -gt ${date_mismatch_threshold_secs} ]; then
|
||||
if [ -e /sbin/hwclock ] ; then
|
||||
ilog "Aligning hwclock to system date"
|
||||
/sbin/hwclock --systohc --utc
|
||||
if [ $? -ne 0 ]; then
|
||||
wlog "failed hwclock command ; /sbin/hwclock --systohc --utc [rc=${rc}]"
|
||||
fi
|
||||
else
|
||||
wlog "lat initrd is missing /sbin/hwclock"
|
||||
fi
|
||||
ilog "System date is now: $(date), hwclock: $(hwclock)"
|
||||
fi
|
||||
else
|
||||
elog "bootimage.iso was constructed without instdate: subcloud date may be out of sync"
|
||||
fi
|
||||
|
||||
true
|
||||
%end
|
||||
|
||||
@ -1498,13 +1582,11 @@ if [ $mgmt_vlan -eq 0 ] ; then
|
||||
ilog "ip ${BOOTPARAM_IP_VER} address add ${BOOTPARAM_IP_ADDR} dev ${mgmt_dev}"
|
||||
ip ${BOOTPARAM_IP_VER} address add ${BOOTPARAM_IP_ADDR} dev ${mgmt_dev}
|
||||
fi
|
||||
sleep 15
|
||||
ilog "ip ${BOOTPARAM_IP_VER} link set dev ${mgmt_dev} up"
|
||||
ip ${BOOTPARAM_IP_VER} link set dev ${mgmt_dev} up
|
||||
ilog "ip ${BOOTPARAM_IP_VER} route add default ${BOOTPARAM_ROUTE_OPTIONS} dev ${mgmt_dev} ${BOOTPARAM_METRIC}"
|
||||
ip ${BOOTPARAM_IP_VER} route add default ${BOOTPARAM_ROUTE_OPTIONS} dev ${mgmt_dev} ${BOOTPARAM_METRIC}
|
||||
ilog "Wait 10s to settle interface..."
|
||||
sleep 10
|
||||
wait_for_interface ${mgmt_dev} 60
|
||||
ilog "ip addr:"
|
||||
ip addr show
|
||||
ilog "ip route:"
|
||||
|
Loading…
x
Reference in New Issue
Block a user