chef-boneyard / chef-provisioning-vsphere

DEPRECATED: A chef-provisioning provisioner for VMware vSphere
MIT License
17 stars 15 forks source link

chef-client failed when docker interface IP is returned by vm.guest.ipAddress #92

Open jessehu opened 6 years ago

jessehu commented 6 years ago

Versions:

Platform Details

Scenario:

In my Ubuntu 16.04.2 VM created by chef-provisioning-vsphere, there is a network interface 'docker0' created for docker. Its IP 172.17.0.1 will be displayed on vSphere Client and returned by vm.guest.ipAddress.

$ ifconfig
docker0   Link encap:Ethernet  HWaddr 02:42:b7:b2:67:04  
          inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.0.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ens192    Link encap:Ethernet  HWaddr 00:50:56:b7:97:ad  
          inet addr:10.192.73.189  Bcast:10.192.95.255  Mask:255.255.224.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:102675064 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3118171 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:27109757101 (27.1 GB)  TX bytes:20799244852 (20.7 GB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:176 errors:0 dropped:0 overruns:0 frame:0
          TX packets:176 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:16409 (16.4 KB)  TX bytes:16409 (16.4 KB)

After adding the following configuration in /etc/vmware-tools/tools.conf, the vSphere Client will not display docker0 IP, but only the expected ens192 IP. However, when powering on the VM, there is still a few seconds that vSphere Client gets docker0 IP and displays it, and it's captured by chef-provisioning-vsphere's vm.guest.ipAddress call. Then chef-provisioning-vsphere still use 172.17.0.1 to connect to the VM. If stop the stuck chef-client and run again, chef-client will get the expected IP of ens192.

[guestinfo]
exclude-nics=docker*,veth*

In order to bypass this issue, I changed this line https://github.com/chef-partners/chef-provisioning-vsphere/blob/master/lib/chef/provisioning/vsphere_driver/driver.rb#L651 to:

(vm.guest.toolsRunningStatus == "guestToolsRunning" && vm.guest.ipAddress && !vm.guest.ipAddress.start_with?("172") && !vm.guest.ipAddress.empty?)