-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Azure: Support for VMs without ephemeral resource disks. (#800)
Changes: * Only merge in default Azure cloud ephemeral disk configs during DataSourceAzure._get_data() if the ephemeral disk exists. * DataSourceAzure.address_ephemeral_resize() (which is invoked in DataSourceAzure.activate() should only set up the ephemeral disk if the disk exists. Azure VMs may or may not come with ephemeral resource disks depending on the VM SKU. For VM SKUs that come with ephemeral resource disks, the Azure platform guarantees that the ephemeral resource disk is attached to the VM before the VM is booted. For VM SKUs that do not come with ephemeral resource disks, cloud-init currently attempts to wait and set up a non-existent ephemeral resource disk, which wastes boot time. It also causes disk setup modules to fail (due to non-existent references to the ephemeral resource disk). udevadm settle is invoked by cloud-init very early in boot. udevadm settle is invoked very early, before DataSourceAzure's _get_data() and activate() methods. Within DataSourceAzure's _get_data() and activate() methods, the ephemeral resource disk path should exist if the VM SKU comes with an ephemeral resource disk. The ephemeral resource disk path should not exist if the VM SKU does not come with an ephemeral resource disk. LP: #1901011
- Loading branch information
1 parent
e384a54
commit a64b738
Showing
4 changed files
with
130 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# PyPI requirements for cloud-init integration testing | ||
# https://cloudinit.readthedocs.io/en/latest/topics/integration_tests.html | ||
# | ||
pycloudlib @ git+https://github.com/canonical/pycloudlib.git@3a6c668fed769f00d83d1e6bea7d68953787cc38 | ||
pycloudlib @ git+https://github.com/canonical/pycloudlib.git@da8445325875674394ffd85aaefaa3d2d0e0020d | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""Integration test for LP: #1901011 | ||
Ensure an ephemeral disk exists after boot. | ||
See https://github.com/canonical/cloud-init/pull/800 | ||
""" | ||
import pytest | ||
|
||
from tests.integration_tests.clouds import IntegrationCloud | ||
|
||
|
||
@pytest.mark.azure | ||
@pytest.mark.parametrize('instance_type,is_ephemeral', [ | ||
('Standard_DS1_v2', True), | ||
('Standard_D2s_v4', False), | ||
]) | ||
def test_ephemeral(instance_type, is_ephemeral, | ||
session_cloud: IntegrationCloud, setup_image): | ||
if is_ephemeral: | ||
expected_log = ( | ||
"Ephemeral resource disk '/dev/disk/cloud/azure_resource' exists. " | ||
"Merging default Azure cloud ephemeral disk configs." | ||
) | ||
else: | ||
expected_log = ( | ||
"Ephemeral resource disk '/dev/disk/cloud/azure_resource' does " | ||
"not exist. Not merging default Azure cloud ephemeral disk " | ||
"configs." | ||
) | ||
|
||
with session_cloud.launch( | ||
launch_kwargs={'instance_type': instance_type} | ||
) as client: | ||
# Verify log file | ||
log = client.read_from_file('/var/log/cloud-init.log') | ||
assert expected_log in log | ||
|
||
# Verify devices | ||
dev_links = client.execute('ls /dev/disk/cloud') | ||
assert 'azure_root' in dev_links | ||
assert 'azure_root-part1' in dev_links | ||
if is_ephemeral: | ||
assert 'azure_resource' in dev_links | ||
assert 'azure_resource-part1' in dev_links | ||
|
||
# Verify mounts | ||
blks = client.execute('lsblk -pPo NAME,TYPE,MOUNTPOINT') | ||
root_device = client.execute( | ||
'realpath /dev/disk/cloud/azure_root-part1' | ||
) | ||
assert 'NAME="{}" TYPE="part" MOUNTPOINT="/"'.format( | ||
root_device) in blks | ||
if is_ephemeral: | ||
ephemeral_device = client.execute( | ||
'realpath /dev/disk/cloud/azure_resource-part1' | ||
) | ||
assert 'NAME="{}" TYPE="part" MOUNTPOINT="/mnt"'.format( | ||
ephemeral_device) in blks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters