Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.2.12] /etc/resolv.conf is removed if create a VM base on an specialized image #754

Closed
yuxisun1217 opened this issue Jun 8, 2017 · 7 comments
Milestone

Comments

@yuxisun1217
Copy link

yuxisun1217 commented Jun 8, 2017

Hi,

In WALA-2.2.12, when I create a VM base on a specialized image, the /etc/resolv.conf file is removed and cannot be generated only if I restart network or reboot.

Reproduce steps:

  1. Capture a running VM as a specialized image.
  2. Create a VM base on this image.
  3. Check /etc/resolv.conf

/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 by dhclient script or NetworkManager. Do we need to remove it? And if we have to remove it, I think we'd better restart network to regenerate it.

  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. I think we'd better also print them in /var/log/waagent.log.

  • For RHEL-6 OS, these WARNING messages cannot be written into /var/log/messages. (All the "print" messages cannot be caught.)

Thanks!

@brendandixon
Copy link
Contributor

@yuxisun1217 When the VM unique identifier changes, the VHD / image could be running anywhere, even in an entirely new region. If so, cached network state is almost certain to be invalid.

I don't believe the agent should "restart" the network in this case. That feels like distribution-related code that best belongs in a systemd unit.

However, we can make the changes necessary to ensure all messages get properly emitted to the log file.

@brendandixon brendandixon added this to the 2.2.14 milestone Jun 16, 2017
@yuxisun1217
Copy link
Author

Hi @brendandixon ,

Everytime the VM is booted, the NetworkManager(RHEL-7) or dhclient(RHEL-6) will regenerate the /etc/resolv.conf. When we create a VM base on the specialized image, the /etc/resolv.conf is a new file, not the cached one.
Besides, the dhclient(or NetworkManager) starts and then WALA removes the /etc/resolv.conf, so that if WALA remove /etc/resolv.conf, no one will regenerate it.
So I think wala doesn't have to removed the /etc/resolv.conf file.

@brendandixon
Copy link
Contributor

@yuxisun1217 I appreciate the details. I need to consider distributions other than Red Hat as well.

@brendandixon
Copy link
Contributor

Addressed by #776

@yuxisun1217
Copy link
Author

yuxisun1217 commented Jun 26, 2017

Hi @brendandixon ,

In WALA-2.2.14, it seem that the 2nd issue still exists:
The "WARNING! Cached DHCP leases will be deleted." is only printed in /var/log/messages but not in /var/log/waagent.log.
Could you please help to confirm if it will be fixed? Thank you very much!

@brendandixon
Copy link
Contributor

@yuxisun1217 That is correct. I have mixed emotions about writing the message to /var/log/waagent.log. The new code path is something of a special case. If you feel strongly about it, please open a new issue to suggest the code writes the messages to log file as well.

@yuxisun1217
Copy link
Author

@brendandixon OK, got it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants