[BUG] Symlink problems, ephemeral-disk-warning service and script issues #3248
Description
Describe the bug: A clear and concise description of what the bug is.
I found this issue while running the LISA tests (https://github.com/microsoft/lisa). The test that fails is found here: https://github.com/microsoft/lisa/blob/717e7c400be694bc2d34a6ce0ce102e8e93cb569/microsoft/testsuites/core/azure_image_standard.py#L1086C3-L1111C6
There is no "DATALOSS_WARNING_README.txt" file being written to the temporary disk, which is /mnt/ in this case. This file is created to warn users that they are accessing a temporary disk and data will be lost. I believe this issue originates, or has something to do with, an incorrect symlink being generated from this file from the WALinuxAgent: /etc/udev/rules.d/66-azure-storage.rules. There is a systemd unit called ephemeral-disk-warning.service that is responsible for running a script (/etc/sbin/ephemeral-disk-warning) that creates the DATALOSS_WARNING_README file. The script tries to resolve an incorrect symlink, and as a result, the file is never written to the target location.
To recreate:
Provision a VM in Azure with the following attributes:
- Image: canonical ubuntuserver 18_04-lts-gen2 18.04.202106220
- VM Size: Standard_NV12s_v3
Check the rules: cat /etc/udev/rules.d/66-azure-storage.rules
Check symlinks: udevadm info --query=all --name=/dev/disk/azure/<device_name>
Check systemd unit ephemeral-disk-warning: systemctl edit --full ephemeral-disk-warning.service
Check ephemeral-disk-warning script: cat /usr/sbin/ephemeral-disk-warning
Distro and WALinuxAgent details (please complete the following information):
- Distro and Version: canonical ubuntuserver 18_04-lts-gen2 18.04.202106220
- WALinuxAgent version: WALinuxAgent-2.2.45 running on ubuntu 18.04
Additional context
Add any other context about the problem here.