[BUG] SWAP is not enabled when ADE is used
- Dominant language
- Python
- Stars
- 581
- Forks
- 397
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 9
Description
Hi,
If Azure Disk Encryption is used to encrypt the resource disk the swap will not be enabled.
The problem is that ADE will set ResourceDisk.Format=n because it needs to encrypt and format the disk itself. However, in daemon/resourcedisk/default.py the swap activation is directly tied to ResourceDisk.Format option:
```
def run(self):
mount_point = None
if conf.get_resourcedisk_format():
mount_point = self.activate_resource_disk()
if mount_point is not None and \
conf.get_resourcedisk_enable_swap():
self.enable_swap(mount_point)
```
If one were to set ResourceDisk.Format=y then mounting will fail:
```
2020/06/21 09:00:27.114820 INFO Daemon Mount resource disk [mount /dev/sdb1 /mnt/resource]
2020/06/21 09:00:27.125156 WARNING Daemon Failed to mount resource disk. Retry mounting after re-reading partition info.
2020/06/21 09:00:27.141536 WARNING Daemon Failed to mount resource disk. Attempting to format and retry mount. [mount: unknown filesystem type 'crypto_LUKS'
]
2020/06/21 09:00:27.150997 ERROR Daemon Command: [mkfs.ext4 -F /dev/sdb1], return code: [1], result: [mke2fs 1.42.9 (28-Dec-2013)
/dev/sdb1 is apparently in use by the system; will not make a filesystem here!
]
2020/06/21 09:00:27.158012 ERROR Daemon Command: [mount /dev/sdb1 /mnt/resource], return code: [32], result: [mount: unknown filesystem type 'crypto_LUKS'
]
2020/06/21 09:00:27.158552 ERROR Daemon Failed to mount resource disk [ResourceDiskError] Could not mount /dev/sdb1 after syncing partition table: [32] mount: unknown filesystem type 'crypto
_LUKS'
2020/06/21 09:00:27.159052 ERROR Daemon Event: name=WALinuxAgent, op=ActivateResourceDisk, message=[ResourceDiskError] Could not mount /dev/sdb1 after syncing partition table: [32] mount: un
known filesystem type 'crypto_LUKS'
, duration=0
```
because the code tries to directly format and mount /dev/sdb1.
Testing done on Centos 7.8.
See also #1220 which was closed without resolution.
Swap activation should support scenarios where resource disk is activated and mounted by ADE and enable swap if so configured.
Contributor guide
Research direction
Start in daemon/resourcedisk/default.py by reading run(), activate_resource_disk(), and enable_swap(), then trace how an ADE-mounted resource disk reaches this entry point. Done means swap is enabled when the disk has been activated and mounted by ADE and swap is configured, without trying to format the encrypted device directly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, python
- Domain
- cloud, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100