schema doesn't match gpt partition types for cc_disk_setup

Bug #2004599 reported by Ross Vandegrift
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

I tried using cc_disk_setup to build a host with a discoverable partition. `cloud-init schema --system` says:

> Cloud config schema errors: disk_setup./dev/disk/by-id/google-home: Additional properties are not allowed (disk_setup./dev/disk/by-id/google-home.layout: [[100, '933AC7E1-2EB4-4F13-B844-0E14E2AEF915']] is not valid under any of the given schemas.

The schema requires partition types to be integers here: https://github.com/canonical/cloud-init/blob/main/cloudinit/config/schemas/schema-cloud-config-v1.json#L1144-L1151

Sample input:
```
disk_setup:
  /dev/disk/by-id/google-home:
    table_type: gpt
    layout:
      - - 100
        - 933AC7E1-2EB4-4F13-B844-0E14E2AEF915 # Linux home
```

Revision history for this message
Brett Holman (holmanb) wrote :

I see a couple issues with the sample input:

1. Note that a list nested in another list is also not valid (note the two "-"s before the "100").

2. 933AC7E1-2EB4-4F13-B844-0E14E2AEF915 is not a valid partition type, see here[1] for a list of valid options.

From the docs[2]:

> Partitions can be specified by providing a list to layout, where each entry in the list is either
> a size or a list containing a size and the numerical value for a partition type. The size for
> partitions is specified in percentage of disk space, not in bytes (e.g. a size of 33 would take
> up 1/3 of the disk space). The partition type defaults to ‘83’ (Linux partition), for other types
> of partition, such as Linux swap, the type must be passed as part of a list along with the size.

See the examples[3] page for more info:

[1] https://tldp.org/HOWTO/Partition-Mass-Storage-Definitions-Naming-HOWTO/x190.html
[2] https://cloudinit.readthedocs.io/en/latest/reference/modules.html#disk-setup
[3] https://cloudinit.readthedocs.io/en/latest/reference/examples.html#disk-setup

Changed in cloud-init (Ubuntu):
status: New → Invalid
Revision history for this message
Ross Vandegrift (ross-kallisti) wrote :

Hi Brett,

This config is accepted by cloud-init and it works. So if the schema is right, cc_disk_setup.py is buggy. But I don't think that's the case - please reopen.

The modules reference you quoted is actually where I found the idea for that config:
> Partitions can be specified by providing a list to layout, where each entry in the list is either a size or a list containing a size and the numerical value for a partition type.
It says layout list items can themselves be lists, containing a size and type. The docs say type is an integer, but the code in cc_disk_setup.py accepts strings - so I think the doc just needs to be corrected.

933AC7E1-2EB4-4F13-B844-0E14E2AEF915 is a valid GPT partition type, but not a valid DOS type. See [1] and [2]. The tldp doc you referenced is about DOS disk labels.

Thanks,
Ross

[1] - https://en.wikipedia.org/wiki/GUID_Partition_Table
[2] - https://uapi-group.org/specifications/specs/discoverable_partitions_specification/

Revision history for this message
Brett Holman (holmanb) wrote (last edit ):

Thanks for the additional info. I see the problem now.

Changed in cloud-init (Ubuntu):
status: Invalid → New
Brett Holman (holmanb)
Changed in cloud-init (Ubuntu):
status: New → In Progress
Revision history for this message
Brett Holman (holmanb) wrote :
Changed in cloud-init (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Chad Smith (chad.smith) wrote :

This is believed to be fix released in cloud-init 23.1. If it is still a problem, please re-open this bug.

Changed in cloud-init (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.