Description of problem:
When we create a VM base on a specialized image, the /etc/resolv.conf file will be removed and cannot be generated only if restart network or reboot.
Version-Release number of selected component (if applicable):
WALinuxAgent-2.2.12-1
RHEL Version:
RHEL-7.4/6.9
How reproducible:
100%
Steps to Reproduce:
1. Prepare a running VM in Azure. Capture it as a specialized image.
2. Create a VM base on this image.
3. Check /etc/resolv.conf
4. Check /var/log/waagent.log and /var/log/messages
Actual results:
The /etc/resolv.conf doesn't exist.
Expected results:
The /erc/resolv.conf exists.
/var/log/messages:
Jun 8 13:25:26 wala74fips python: 2017/06/08 13:25:26.019325 WARNING VM is provisioned, but the VM unique identifier has changed -- clearing cached state
Jun 8 13:25:26 wala74fips python: WARNING! Cached DHCP leases will be deleted.
Jun 8 13:25:26 wala74fips python: WARNING! /etc/resolv.conf will be deleted.
Additional info:
1. Root cause is when creating a VM and the /var/lib/waagent/provisioned file exists, wala runs "deprovision_handler.run_changed_unique_id()", it calls "del_resolv"(Line#212 in pa/deprovision/default.py), which will delete the /etc/resolv.conf.
In my opinion, when we create a new VM, the /etc/resolv.conf will be regenerated my dhclient script or NetworkManager.
2. The WARNING logs "WARNING! Cached DHCP leases will be deleted.", "WARNING! /etc/resolv.conf will be deleted." are only printed in /var/log/messages but not in /var/log/waagent.log. We'd better also print them in /var/log/waagent.log.
Verify in WALinuxAgent-2.2.14-1.el7
RHEL version: RHEL-7.4-20170621.0
Result: Issue 1(remove /etc/resolv.conf issue) is passed.
Issue 2(print WARNING logs into /var/log/waagent.log) is failed
Steps:
1. Prepare a running VM in Azure. Capture it as a specialized image.
2. Create a VM base on this image.
3. Check /etc/resolv.conf
4. Check /var/log/waagent.log and /var/log/messages
Actual result:
1. /etc/resolv.conf is not removed.
2. The "WARNING! Cached DHCP leases will be deleted." message only exists in /var/log/messages but not in /var/log/waagent.log
Description of problem: When we create a VM base on a specialized image, the /etc/resolv.conf file will be removed and cannot be generated only if restart network or reboot. Version-Release number of selected component (if applicable): WALinuxAgent-2.2.12-1 RHEL Version: RHEL-7.4/6.9 How reproducible: 100% Steps to Reproduce: 1. Prepare a running VM in Azure. Capture it as a specialized image. 2. Create a VM base on this image. 3. Check /etc/resolv.conf 4. Check /var/log/waagent.log and /var/log/messages Actual results: The /etc/resolv.conf doesn't exist. Expected results: The /erc/resolv.conf exists. /var/log/messages: Jun 8 13:25:26 wala74fips python: 2017/06/08 13:25:26.019325 WARNING VM is provisioned, but the VM unique identifier has changed -- clearing cached state Jun 8 13:25:26 wala74fips python: WARNING! Cached DHCP leases will be deleted. Jun 8 13:25:26 wala74fips python: WARNING! /etc/resolv.conf will be deleted. Additional info: 1. Root cause is when creating a VM and the /var/lib/waagent/provisioned file exists, wala runs "deprovision_handler.run_changed_unique_id()", it calls "del_resolv"(Line#212 in pa/deprovision/default.py), which will delete the /etc/resolv.conf. In my opinion, when we create a new VM, the /etc/resolv.conf will be regenerated my dhclient script or NetworkManager. 2. The WARNING logs "WARNING! Cached DHCP leases will be deleted.", "WARNING! /etc/resolv.conf will be deleted." are only printed in /var/log/messages but not in /var/log/waagent.log. We'd better also print them in /var/log/waagent.log.