Skip to content

Commit

Permalink
Fix issue when checking guest IP of the VM with docker running
Browse files Browse the repository at this point in the history
When docker daemon runs in the VM, there will be a nic created by
docker and usually has IP like 172.x.x.x. When VM is booting up,
VM Tools sometimes reports this IP to vCenter, although the real IP
of the non-docker nic will be reported later.
So we add a check for this case and filter out the docker IP.
  • Loading branch information
jessehu committed Feb 20, 2019
1 parent 798fd54 commit fe6930d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/chef/provisioning/vsphere_driver/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,7 @@ def wait_until_ready(action_handler, machine_spec, machine_options, vm)
if vm.guest.toolsRunningStatus != "guestToolsRunning"
if action_handler.should_perform_actions
action_handler.report_progress "waiting for #{machine_spec.name} (#{vm.config.instanceUuid} on #{driver_url}) to be ready ..."
until remaining_wait_time(machine_spec, machine_options) < 0 ||
(vm.guest.toolsRunningStatus == "guestToolsRunning" && vm.guest.ipAddress && !vm.guest.ipAddress.empty?)
until remaining_wait_time(machine_spec, machine_options) < 0 || vm_guest_ip?(vm)
print "."
sleep 5
end
Expand Down Expand Up @@ -948,7 +947,9 @@ def wait_for_ipv4(timeout_seconds, vm)
#
# @param [Object] vm The VM object from Chef-Provisioning
def vm_guest_ip?(vm)
vm.guest.guestState == "running" && vm.guest.toolsRunningStatus == "guestToolsRunning" && !vm.guest.ipAddress.nil?
# The docker interface usually has IP like 172.x.x.x, so need to filter it out.
vm.guest.guestState == "running" && vm.guest.toolsRunningStatus == "guestToolsRunning" &&
!vm.guest.ipAddress.nil? && !vm.guest.ipAddress.empty? && !vm.guest.ipAddress.start_with?("172")
end
end
end

0 comments on commit fe6930d

Please sign in to comment.