-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨Allow diskSetup to include partition layout #11634
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Miltiadis Alexis <alexmiltiadis@gmail.com>
This PR is currently missing an area label, which is used to identify the modified component when generating release notes. Area labels can be added by org members by writing Please see the labels list for possible areas. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @miltalex! |
Hi @miltalex. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Signed-off-by: Miltiadis Alexis <alexmiltiadis@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial thoughts on the API changes within this PR
// Percentage of disk that partition will take (1-100) | ||
// +kubebuilder:validation:Minimum=1 | ||
// +kubebuilder:validation:Maximum=100 | ||
Percentage int32 `json:"percentage"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should include a required marker to show explicitly that this is required
|
||
// PartitionType is the numerical value of the partition type (optional) | ||
// +optional | ||
PartitionType *int32 `json:"partitionType,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the valid values for this value? And how would I, as an end user, understand those?
Is there a limit on this? Is 0
a valid value? Are negative values valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I can use a string here to reflect the correct linux partition types. It was an attempt to purely map the disk layout as described in the cloud init docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a choice to make here. Either you can allow all of the valid values there, in which case this should be a 2 character lowercase hex value. Or, you can allow specific, common types, and do that by creating an Enum here and creating PascalCase aliases to the formats we actually want to support.
IMO, the latter provides a better UX
@@ -675,19 +675,42 @@ type DiskSetup struct { | |||
Filesystems []Filesystem `json:"filesystems,omitempty"` | |||
} | |||
|
|||
// DiskLayout represents an array of partition specifications | |||
type DiskLayout []PartitionSpec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid a type alias to a slice, it makes it harder to understand the API when looking at the go types (it looks like a struct for example if I look at the Partition
usage)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will convert it to a struct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just meant you could inline this slice, rather than using an alias, I don't think it needs to be a struct does it?
|
||
// PartitionSpec defines the size and optional type for a partition | ||
type PartitionSpec struct { | ||
// Percentage of disk that partition will take (1-100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Godoc must start with the serialised version of the field name
// Percentage of disk that partition will take (1-100) | |
// percentage of disk that partition will take (1-100) |
// +kubebuilder:validation:Maximum=100 | ||
Percentage int32 `json:"percentage"` | ||
|
||
// PartitionType is the numerical value of the partition type (optional) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// PartitionType is the numerical value of the partition type (optional) | |
// partitionType is the numerical value of the partition type (optional) |
// layout specifies the device layout. | ||
// If it is true, a single partition will be created for the entire device. | ||
// When layout is false, it means don't partition or ignore existing partitioning. | ||
Layout bool `json:"layout"` | ||
|
||
// diskLayout specifies the percentage of disk space and partition types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this list ordered?
Can you validate that the percentages sum to 100? Are they allowed to sum to less than 100?
Signed-off-by: Miltiadis Alexis <alexmiltiadis@gmail.com>
What this PR does / why we need it:
This PR enhances disk partitioning capabilities by introducing support for custom partition layouts through the new
DiskLayout
field. Previously, disk partitioning was limited to a boolean option that could only create a single partition for the entire device. This enhancement allows users to define multiple partitions with specific size percentages and partition types.The changes align with cloud_init logic's disk setup specification, which supports both boolean and list-based partition layouts. The existing
layout
boolean field is maintained for backward compatibility, while the newdiskLayout
field provides advanced partitioning capabilities when needed.Examples
Before (Single Partition):
After (Multiple Partitions):
Generated cloud-init output:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #8524