Bug 1460592

Summary: [WALA] /etc/resolv.conf is removed while create a VM base on a specialized image
Product: Red Hat Enterprise Linux 7 Reporter: Yuxin Sun <yuxisun>
Component: WALinuxAgentAssignee: Vitaly Kuznetsov <vkuznets>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.4CC: ailan, borisb, brendand, danis, hkrijger, jopoulso, leiwang, mmorsy, stephen.zarkos, wshi, yujiang, yuxisun
Target Milestone: rcKeywords: Extras
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1460616 (view as bug list) Environment:
Last Closed: 2017-07-24 09:32:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1451172    
Bug Blocks: 1460616    

Description Yuxin Sun 2017-06-12 06:38:34 UTC
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.

Comment 2 Mohammed Gamal 2017-06-22 11:39:00 UTC
Fixed upstream. Not yet released
See: https://github.com/Azure/WALinuxAgent/pull/776

Comment 3 Mohammed Gamal 2017-06-23 08:43:25 UTC
v2.2.14 now released containing the fix
https://github.com/Azure/WALinuxAgent/releases/tag/v2.2.14

Comment 4 Yuxin Sun 2017-06-26 09:21:47 UTC
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

Comment 5 Yuxin Sun 2017-07-24 09:32:06 UTC
Close this issue because WALinuxAgent-2.2.14-1.el7/6 has shipped.