cloud-init
cloud-init copied to clipboard
[enhancement]: disk_setup support for gpt partitions when sgdisk util is not present
Enhancement
Allow disk_setup of gpt partitions in minimal images where sgdisk utility is not present. Fallback to sfdisk if necessary for handling GPT partition inspection and creation.
Steps to reproduce
- Launch an ubuntu cloud image, with sgdisk removed , providing
disk_setup:in cloud-config which defines a gpt partition table type - Expect tracebacks on inability to find sgdisk file or directory
test procedure
- apply the following diff to tip of main
diff --git a/tests/integration_tests/conftest.py b/tests/integration_tests/conftest.py
index b62dae82a..de922735d 100644
--- a/tests/integration_tests/conftest.py
+++ b/tests/integration_tests/conftest.py
@@ -136,6 +136,7 @@ def setup_image(session_cloud: IntegrationCloud, request):
if source.installs_new_version():
log.info("Installing cloud-init from %s", source.name)
client.install_new_cloud_init(source)
+ client.execute("rm /usr/sbin/sgdisk")
if (
integration_settings.INCLUDE_PROFILE
and integration_settings.INCLUDE_COVERAGE
diff --git a/tests/integration_tests/modules/test_disk_setup.py b/tests/integration_tests/modules/test_disk_setup.py
index 27a70d32f..8f8f8b3ec 100644
--- a/tests/integration_tests/modules/test_disk_setup.py
+++ b/tests/integration_tests/modules/test_disk_setup.py
@@ -36,7 +36,7 @@ device_aliases:
my_alias: /dev/sdb
disk_setup:
my_alias:
- table_type: mbr
+ table_type: gpt
layout: [50, 50]
overwrite: True
fs_setup:
- run integration test, keeping the instance around after test completion
CLOUD_INIT_KEEP_INSTANCE=1 CLOUD_INIT_PLATFORM=lxd_vm CLOUD_INIT_CLOUD_INIT_SOURCE=ppa:cloud-init-dev/daily CLOUD_INIT_OS_IMAGE=jammy tox -e integration-tests -- tests/integration_tests/modules/test_disk_setup.py::TestDeviceAliases
- See warnings about disk setup failing due to missing utilities:
root@cloudinit-1008-135436hv703bwv:~# cloud-init status --format=yaml
---
_schema_version: '1'
boot_status_code: enabled-by-generator
datasource: lxd
detail: DataSourceLXD
errors: []
extended_status: degraded done
init:
errors: []
finished: 3.98
recoverable_errors:
WARNING:
- 'Failed partitioning operation
Error running partition command on /dev/sdb
Unexpected error while running command.
Command: [''sgdisk'', ''-p'', ''/dev/sdb'']
Exit code: -
Reason: [Errno 2] No such file or directory: b''sgdisk''
Stdout: -
Stderr: -'
- Path %s does not exist or is not a block device
- Path %s does not exist or is not a block device
start: 3.31
init-local:
errors: []
finished: 2.05
recoverable_errors: {}
start: 1.94
last_update: Thu, 01 Jan 1970 00:00:06 +0000
modules-config:
errors: []
finished: 5.8
recoverable_errors: {}
start: 5.55
modules-final:
errors: []
finished: 6.04
recoverable_errors: {}
start: 5.97
recoverable_errors:
WARNING:
- 'Failed partitioning operation
Error running partition command on /dev/sdb
Unexpected error while running command.
Command: [''sgdisk'', ''-p'', ''/dev/sdb'']
Exit code: -
Reason: [Errno 2] No such file or directory: b''sgdisk''
Stdout: -
Stderr: -'
- Path %s does not exist or is not a block device
- Path %s does not exist or is not a block device
At RH we are eager to see a solution for this.