The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,096 other followers

VMware ESXi 6.5: “Failed – An error occurred during host configuration.” when starting the NTP service

Posted by jpluimers on 2020/08/10

I tried repeating VMware KB: Configuring Network Time Protocol (NTP) on ESX/ESXi hosts using the vSphere Client in ESXi 6.5 using the web-client (the steps are very similar, see [WayBack] How to configure ESXi 6.5 Network Time Protocol (NTP) via Host Client? | ESX Virtualization).

It failed with the non-descriptive “Failed – An error occurred during host configuration.”:

Viewing the details isn’t of much help as you do not get extra information:

Start Service
Key haTask-ha-host-vim.host.ServiceSystem.start-139845177
Description Starts the service
State Failed – An error occurred during host configuration.
Errors

The /var/log/hostd.log did not get me further either:

2018-04-28T11:31:48.159Z info hostd[B881B70] [Originator@6876 sub=Vimsvc.TaskManager opID=4a8dc318 user=root] Task Created : haTask-ha-host-vim.host.ServiceSystem.start-139845360
2018-04-28T11:31:48.160Z verbose hostd[B881B70] [Originator@6876 sub=PropertyProvider opID=4a8dc318 user=root] RecordOp ADD: recentTask["haTask-ha-host-vim.host.ServiceSystem.start-139845360"], ha-host. Sent notification immediately.
2018-04-28T11:31:48.160Z verbose hostd[B881B70] [Originator@6876 sub=PropertyProvider opID=4a8dc318 user=root] RecordOp ADD: recentTask["haTask-ha-host-vim.host.ServiceSystem.start-139845360"], ha-taskmgr. Applied change to temp map.
2018-04-28T11:31:48.160Z verbose hostd[B881B70] [Originator@6876 sub=PropertyProvider opID=4a8dc318 user=root] RecordOp ASSIGN: info, haTask-ha-host-vim.host.ServiceSystem.start-139845360. Applied change to temp map.
2018-04-28T11:31:48.160Z info hostd[B881B70] [Originator@6876 sub=SysCommandPosix opID=4a8dc318 user=root] ForkExec(/etc/init.d/ntpd) 205307
2018-04-28T11:31:48.213Z info hostd[B881B70] [Originator@6876 sub=SysCommandPosix opID=4a8dc318 user=root] ForkExec(/etc/init.d/ntpd) 205309
2018-04-28T11:31:48.265Z info hostd[B881B70] [Originator@6876 sub=Default opID=4a8dc318 user=root] AdapterServer caught exception: vim.fault.PlatformConfigFault
2018-04-28T11:31:48.266Z info hostd[B881B70] [Originator@6876 sub=Vimsvc.TaskManager opID=4a8dc318 user=root] Task Completed : haTask-ha-host-vim.host.ServiceSystem.start-139845360 Status error
2018-04-28T11:31:48.266Z verbose hostd[B881B70] [Originator@6876 sub=PropertyProvider opID=4a8dc318 user=root] RecordOp ASSIGN: info, haTask-ha-host-vim.host.ServiceSystem.start-139845360. Applied change to temp map.
2018-04-28T11:31:48.266Z info hostd[B881B70] [Originator@6876 sub=Solo.Vmomi opID=4a8dc318 user=root] Activation [N5Vmomi10ActivationE:0x0c012328] : Invoke done [start] on [vim.host.ServiceSystem:serviceSystem]
2018-04-28T11:31:48.266Z verbose hostd[B881B70] [Originator@6876 sub=Solo.Vmomi opID=4a8dc318 user=root] Arg id:
--> "ntpd"
2018-04-28T11:31:48.266Z info hostd[B881B70] [Originator@6876 sub=Solo.Vmomi opID=4a8dc318 user=root] Throw vim.fault.PlatformConfigFault
2018-04-28T11:31:48.266Z info hostd[B881B70] [Originator@6876 sub=Solo.Vmomi opID=4a8dc318 user=root] Result:
--> (vim.fault.PlatformConfigFault) {
--> faultCause = (vmodl.MethodFault) null,
--> faultMessage = <unset>,
--> text = ""
--> msg = ""
--> }

This did not reveal any more information, so I started digging:

    1. In /etc/init.d/ntpd, via NTPD_CONFIG="/etc/ntp.conf" the /etc/ntp.confis queried:
      ntp_servers=`awk '
                   /^server[ \t]*127.127/ {next}
                   /^(server|peer)/       {
                      if ($2 ~/^-/)       {printf "%s " $3}
                      else                {printf "%s " $2}}
                   ' < ${NTPD_CONFIG}`
    2. This file did not have any servers configured:
      # cat /etc/ntp.conf
      restrict default kod nomodify notrap nopeer noquery
      restrict 127.0.0.1
      driftfile /etc/ntp.drift
      

So it appeared that copy/paste this in the web-environment had not been persisted correctly:

0.pool.ntp.org
1.pool.ntp.org
2.pool.ntp.org
3.pool.ntp.org

I re-did the configuration by typing the correct data in stead of pasting and now everything worked fine: the service started and the config file has servers:

# cat /etc/ntp.conf
restrict default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
server 0.pool.ntp.org
1.pool.ntp.org
2.pool.ntp.org
3.pool.ntp.org
driftfile /etc/ntp.drift

It would be so nice if /etc/init.d/ntpd would show why it performs return 1 and the service start mechanism would reflect that in the errors part of the failure message.

Verifying ntpd got the client information

Two steps:

  1. Check if ntpd is running

    Bad response (ensure the service is started, and starts with the host, see How to configure ESXi 6.5 Network Time Protocol (NTP) via Host Client? | ESX Virtualization):

    [root@ESXi-X10SRH-CF:~] /etc/init.d/ntpd status
    ntpd is not running

    Good response:

    [root@ESXi-X10SRH-CF:~] /etc/init.d/ntpd status
    ntpd is not running
  2. Check if the ntpq can query the ntpd client status. It is is not running, then see step 1. If it is not initialising, then you might have a network problem

    Bad response:

    [root@ESXi-X10SRH-CF:~] ntpq -pn
    ntpq: read: Connection refused

    Response while waiting for an ntp refresh:

    [root@ESXi-X10SRH-CF:~] ntpq -pn
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
     149.210.199.182 .INIT.          16 u    -   64    0    0.000    0.000   0.001

    Good response:

    [root@ESXi-X10SRH-CF:~] ntpq -pn
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
     149.210.199.182 193.79.237.14    2 u   61   64    1    3.423   -0.296   0.001

–jeroen

#!/bin/sh
#
# Copyright 2007 VMware, Inc. All rights reserved.
#
# ntpd:
# Start and stop the NTP daemon
#
# chkconfig: – 10 90
# description: Network Time Protocol (NTP) daemon.
#
SNTP="/sbin/sntp"
NTPD="/sbin/ntpd"
NTPD_CONFIG="/etc/ntp.conf"
NTPD_OPTS="-g -n -c ${NTPD_CONFIG} -f /etc/ntp.drift"
NTPD_RP="ntpd"
NTPD_TAG="ntpd"
export PATH=/bin:/sbin
#
# Sanity check
#
[ -x "${NTPD}" -a -f "${NTPD_CONFIG}" ] || exit 0
#
# Log action
#
ntpd_log() {
echo "${1}"
logger ntpd "${1}"
}
#
# Start ntpd
#
ntpd_start() {
ntp_servers=`awk '
/^server[ \t]*127.127/ {next}
/^(server|peer)/ {
if ($2 ~/^-/) {printf "%s " $3}
else {printf "%s " $2}}
' < ${NTPD_CONFIG}`
if [ -n "$(pidof -xs "${NTPD}")" ] ; then
return 1
fi
# if the service is configured, start it
if [ -n "$ntp_servers" ]; then
ntpd_log "Starting ntpd"
"${SNTP}" ++memreliable,group=${NTPD_RP} -K /dev/null -S $ntp_servers >/dev/null 2>&1
/sbin/watchdog.sh ++memreliable,group=${NTPD_RP} -d -t 100 -s "${NTPD_TAG}" "${NTPD}" ${NTPD_OPTS} >/dev/null 2>&1
else
return 1
fi
}
#
# Stop ntpd
#
ntpd_stop() {
if [ -n "$(pidof -xs ${NTPD})" ] ; then
ntpd_log "Stopping ntpd"
# This only stops the watchdog process.
/sbin/watchdog.sh -k "${NTPD_TAG}"
if [ -n "$(pidof -xs "${NTPD}")" ]; then
pkill -HUP "${NTPD}"
while [ -n "$(pidof -xs ${NTPD})" ] ; do
pkill -HUP "${NTPD}"
sleep 1
done
fi
else
return 0
fi
}
#
# Process comand line options
#
case "${1}" in
start)
ntpd_start
retCode=$?
if [ $retCode -eq 0 ] ; then
# wait for ntpd to start (for a max of 5 seconds)
sleepCount=0
while [ -z "$(pidof -xs "${NTPD}")" ] && [ $sleepCount -lt 5 ] ; do
sleep 1
let "sleepCount+=1"
done
fi
exit $retCode
;;
stop)
ntpd_stop
;;
status)
if [ -n "$(pidof -xs "${NTPD}")" ] ; then
echo "ntpd is running"
exit 0
else
echo "ntpd is not running"
exit 3
fi
;;
restart)
ntpd_stop
ntpd_start
;;
*)
echo "Usage: $(basename "$0") {start|stop|status|restart}"
exit 1
;;
esac

view raw
ntpd.sh
hosted with ❤ by GitHub

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: