Azure / Azure/WALinuxAgent

[BUG] "waagent -deprovision+user" does not remove /var/lib/hyperv/, resulting in stale kvp_pool files in a new VM

Open
#3,276 1 comment 0 reactions 1 assignee Claimed by @longlimsft View on GitHub
RDMA
Dominant language
Python
Stars
581
Forks
397
Avg merge
2d 15h
Merged PRs (30d)
9

Description

When preparing a Linux VHD image for Azure, we usually run "sudo waagent -deprovision+user" (see https://learn.microsoft.com/en-us/azure/virtual-machines/generalize) and assume that the VHD won't contain any stale info from the previous VM.

It turns out this assumption is not true because walinuxagent doesn't remove the folder /var/lib/hyperv/, resulting in stale kvp_pool files in a new VM:
/var/lib/hyperv/.kvp_pool_0 /var/lib/hyperv/.kvp_pool_1 /var/lib/hyperv/.kvp_pool_2 /var/lib/hyperv/.kvp_pool_3 /var/lib/hyperv/.kvp_pool_4

Some of the pool files may contain stale and incorrect info, e.g. /var/lib/hyperv/.kvp_pool_3 contains the Windows host name. It looks like under some condition the KVP daemon fails to update the host name in /var/lib/hyperv/.kvp_pool_3 before the VM's first reboot (the root cause is still unclear yet, but it's a different issue); when this happens, a user may be concerned as the host name may be used to implement some kind of load balancing, and an unexpected incorrect host name in the kvp pool file can mislead the load balancing code.

The request is: "waagent -deprovision+user" should remove /var/lib/hyperv/.

Steps to reproduce the behavior:
1. Start a Linux VM of any Linux distro on Azure or a local Hyper-V host, e.g. Ubutnu/RHEL/SLES. Make sure the KVP daemon is running, and you see the files "ls /var/lib/hyperv/.kvp_pool_*".
2. Run "sudo waagent -deprovision+user".
3. "ls /var/lib/hyperv/.kvp_pool_*" still shows the kvp pool files.

This behavior exists in all versions of WALinuxAgent.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.