-
Notifications
You must be signed in to change notification settings - Fork 247
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
Improve partition semantics #544
Conversation
retest this please |
Is there a high level description of the issue we're solving here? When would I want to reuse a partition? I started looking back through the issues but it wasn't immediately clear. Something to do with RAID? |
Nevermind I saw coreos/bugs#2388 |
tests/negative/partitions/simple.go
Outdated
} | ||
|
||
func NotThereAndDoesNotMatchNoWipeEntry() types.Test { | ||
name := "Partition does not match and wipePartitionEntry is false but the first partition matches" |
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.
This shares the same name as ValidAndDoesNotMatchNoWipeEntry
, is this intentional? In the test output you'll see a result for both TestIgnitionBlackBoxNegative/Partition_does_not_match_and_wipePartitionEntry_is_false_but_the_first_partition_matches
& TestIgnitionBlackBoxNegative/Partition_does_not_match_and_wipePartitionEntry_is_false_but_the_first_partition_matches#01
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.
Nope, that's a copy-paste error
tests/negative/partitions/zeroes.go
Outdated
} | ||
|
||
func Partition9DoesNotStartCorrectly() types.Test { | ||
name := "Partition 9 is does not start at the largest chunk" |
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.
s/is //g
tests/positive/partitions/complex.go
Outdated
) | ||
|
||
func init() { | ||
// Everything and the kitchen sunk |
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.
s/sunk/sink/g
@@ -183,46 +245,31 @@ func AppendPartition() types.Test { | |||
} | |||
} | |||
|
|||
func PartitionSizeStart0() types.Test { |
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.
Would there be any value in leaving this test case to test using size & start 0 in older versions of the API to ensure that we don't break the old contract?
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.
This was moved, not deleted. There should still be some tests in positive/zeros that do the same thing
// one and fail the test. | ||
config := `{ | ||
"ignition": { | ||
"version": "2.1.0" |
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.
wipePartitionEntry
doesn't exist in the 2.1.0
spec and will just throw warnings. Is this intentional?
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.
Nope, that's a typo
} | ||
|
||
func VerifyBaseDiskWithWipe() types.Test { | ||
name := "Verify the base disk does not change with a matching ignition spec" |
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.
As per the comment in tests/negative/partitions/simple.go
this matches the same test name as VerifyBaseDisk
tests/positive/partitions/zeros.go
Outdated
} | ||
|
||
func PartitionStartNumber0() types.Test { | ||
name := "Create a partition with size and start 0" |
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.
This test name implies to me that the size & start are both 0 but size is specified for each partition as 65536
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.
Oops, that's supposed to just be start 0, not size as well
out := types.GetBaseDisk() | ||
config := `{ | ||
"ignition": { | ||
"version": "2.1.0" |
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 a 2.1.0
config intentional?
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.
In this case, yes, since the config uses only old keys.
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 started on this, just a few comments so far, but I need to context switch.
Label *string `json:"label,omitempty"` | ||
Number int `json:"number,omitempty"` | ||
ShouldExist *bool `json:"shouldExist,omitempty"` | ||
Size *int `json:"size,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.
When I do things like this I add a comment like coreos/rpm-ostree#1368 (comment)
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.
This is generated from schema/ignition.json
@@ -24,11 +24,22 @@ addons: | |||
install: | |||
# since libblkid-dev:arm64 cannot be installed, spoof it |
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.
Wow...am curious about the history here. Since aarch64 isn't a CL deliverable today, maybe just nuke this?
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.
We do ship arm, just only alpha and beta (no stable)
internal/exec/util/blkid.c
Outdated
|
||
blkid_parttable table = blkid_partlist_get_table(list); | ||
if (!table) { | ||
blkid_free_probe(pr); |
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.
It probably wouldn't be hard to use attribute(cleanup) for this; it's a bit like defer
for C (or RAII in C++).
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.
While I don't think we care about MSVC, we might care about clang. Does Clang support it as well?
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.
Yep! A better link is https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization#Clang_and_GCC_%22cleanup%22_extension_for_C
It's also heavily used by systemd today, as well as ostree, etc. (And ostree's CI tests use clang in some cases)
internal/exec/util/blkid.c
Outdated
// RESULT_LOOKUP_FAILED if src is null | ||
// RESULT_OVERFLOW if src is too big | ||
// 0 on success | ||
static result_t checked_copy(char *dest, const char *src, size_t len) { |
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.
Since we're returning to golang anyways, any reason not to just pass back strdup()
'd data? I understand with partition tables we have fixed buffers from some of the formats, but it feels more annoying to deal with perhaps?
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.
Mostly because dealing with any sort of dynamically allocated data with CGO is a giant pain. We only care about gpt which is limited to 36 UTF16 characters, so the statically allocated buffers are fine.
@cgwalters To give more background: in addition to the linked bug, this allows you do things like blow away the root partition (if you want to do root on raid or something and reclaim the space for something else). Currently there's an awkward dance where you have to wipe the filesystem and just sacrafice that disk space. This is a solution to that problem built out in a generic, declarative way. |
@arithx updates to address your comments. I'll add in the cleanup macro once I get more feedback on the internals. This also passes a full kola qemu run. |
doc/operator-notes.md
Outdated
A partition matches if all of the specified attributes (`label`, `start`, `size`, `uuid`, and `typeGuid`) are the same. Specifying `uuid` or `typeGuid` as an empty string is the same as not specifying them. When 0 is specified for start or size, Ignition checks if the existing partition's start / size match what they would be if all of the partitions specified were to be deleted (if allowed by wipPartitionEntry), then recreated if `shouldExist` is true. | ||
|
||
## Partition number 0 | ||
Specifying `Number` as 0 will use the next available partition number *after* all deletions occur. This means if partition 9 is specified with `shouldExist` as `false` and `wipePartitionEntry` as `true`, and another partition is specified to be created with `number` as `0`, it will get partition number 9. Partition number 0 is disallowed on disks with partitions that specify `shouldExist` as 0. If `number` is not specified it will be treated as 0. |
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.
nit: the first number
shouldn't be capitalized.
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.
partition number 0 is disallowed on disks with partitions that specify
shouldExist
as 0
Does this mean in the following example the partition with number: 0
should have shouldExist: false
? Doesn't that mean that the partition won't be created? Or does that mean that I should not set shouldExist
at all and let it be nil
? If nil
has a different behaviour than true
and false
, can we get it added to the above table?
if partition 9 is specified with
shouldExist
asfalse
andwipePartitionEntry
astrue
, and another partition is specified to be created withnumber
as0
, it will get partition number 9
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.
also shouldExist
is a boolean and this can't be set as 0.
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.
Oops, I meant to drop this example. I realized I could just disallow the combination instead of having unexpected behavior
doc/operator-notes.md
Outdated
Specifying `Number` as 0 will use the next available partition number *after* all deletions occur. This means if partition 9 is specified with `shouldExist` as `false` and `wipePartitionEntry` as `true`, and another partition is specified to be created with `number` as `0`, it will get partition number 9. Partition number 0 is disallowed on disks with partitions that specify `shouldExist` as 0. If `number` is not specified it will be treated as 0. | ||
|
||
## Partition start 0 | ||
Specifying `start` as 0 will use the starting sector of the largest available block. It will *not* use the first available block large enough. If `start` is not specified and there is no existing partition, start will be treated as 0, otherwise it will be treated as the existing partition's starting sector. |
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.
perhaps "no existing partition with a matching number" ?
doc/operator-notes.md
Outdated
Specifying `start` as 0 will use the starting sector of the largest available block. It will *not* use the first available block large enough. If `start` is not specified and there is no existing partition, start will be treated as 0, otherwise it will be treated as the existing partition's starting sector. | ||
|
||
## Partition size 0 | ||
Specifying `size` specifies the partition should span to the end of the largest available block. If `size` is not specified and there is no existing partition, it will be treated as 0, otherwise it will be treated as the existing partition's size. |
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.
Did you mean "specifying size
as 0?
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.
nit: "Specifying size
specifies" uses the word "specify" too much.
internal/exec/util/blkid.c
Outdated
} | ||
|
||
// blkid_get_partition_list returns the partition list and the probe used to get it (so | ||
// we can free it). It also performs a sanity check and ensures its is GPT formatted. In the case |
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.
nit: s/its/it/
internal/exec/util/blkid.c
Outdated
// Returns: | ||
// RESULT_LOOKUP_FAILED if src is null | ||
// RESULT_OVERFLOW if src is too big | ||
// 0 on success |
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.
nit: RESULT_OK on success
return nil | ||
} | ||
|
||
// getReadStartAnsSize returns a map of partition numbers to a struct that contains what their real start |
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.
s/Ans/And/
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.
s/Read/Real/
size int | ||
} | ||
|
||
func parseLine(r *regexp.Regexp, line string) (int, error) { |
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.
It would be nice to have a comment on this saying what it does
// output was from running `sgdisk --pretend <commands> --info=1 --info=4 --info=5`. It assumes the the | ||
// partition labels are well behaved (i.e. contain no control characters). It returns a list of partitions | ||
// matching the partition numbers specified, but with the start and size information as determined by sgdisk. | ||
// The partition numbers need to passed in because sgdisk include them in it's output. |
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.
s/include/includes/
s/it's/its/
|
||
// partitionDisk partitions devAlias according to the spec given by dev | ||
func (s stage) partitionDisk(dev types.Disk, devAlias string) error { | ||
if dev.WipeTable { |
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's the reason to not wipe during the following operation?
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.
getPartitionMap
reads the disk and needs to see that it's empty
Start: x.Start, | ||
TypeGUID: x.TypeGUID, | ||
ShouldExist: x.ShouldExist, | ||
WipePartitionEntry: x.WipePartitionEntry, |
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.
Can you also add these fields somewhere in internal/config/translate_test.go
?
tests/positive/partitions/zeros.go
Outdated
} | ||
|
||
func VerifyUnspecifiedIsDoNotCare() types.Test { | ||
name := "Verify the ROOT partition to fills the default disk" |
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.
Same test name as VerifyRootFillsDisk
c67e52b
to
0b9854a
Compare
Updated with feedback. @cgwalters the cleanup extension stuff made the cgo so much cleaner and also fixed a few existing memory leaks I found in the process. Ran it through kola again and it passed. |
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.
Tests LGTM
} | ||
} | ||
|
||
func WipeAndCreateNewPartitions() types.Test { |
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.
Should we update the test.Name
to note the Wipe occurring?
} | ||
|
||
func VerifyBaseDiskWithWipe() types.Test { | ||
name := "Verify the base disk does not change with a matching ignition spec with wipePartitionEntry as true" |
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.
s,ignition,Ignition,g
} | ||
|
||
func VerifyBaseDisk() types.Test { | ||
name := "Verify the base disk does not change with a matching ignition spec" |
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.
s,ignition,Ignition,g
TypeGUID string `json:"typeGuid,omitempty"` | ||
GUID string `json:"guid,omitempty"` | ||
Label *string `json:"label,omitempty"` | ||
Number int `json:"number,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.
It looks like this (and most of the other int
s) is really a uint
. Does schematyper support specifying that?
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.
Nope, which is unfortunate.
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.
LGTM, pending nits
doc/operator-notes.md
Outdated
|
||
The `wipePartitionEntry` and `shouldExist` flags control what Ignition will do when it encounters an existing partition. `wipePartitionEntry` specifies whether Ignition is permitted to delete partition entries in the partition table. `shouldExist` specifies whether a partition with that number should exist or not (it is invalid to specify a partition should not exist and specify its attributes, such as `size` or `label`). | ||
|
||
The following table shows the possible combinations of `shouldExist`, `wipePartitionEntry`, whether or not a partition with the specified number is present, and the action Ignition will take |
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.
silly nit: I'd like the list of items here to follow the same ordering as the table headers
doc/operator-notes.md
Outdated
A partition matches if all of the specified attributes (`label`, `start`, `size`, `uuid`, and `typeGuid`) are the same. Specifying `uuid` or `typeGuid` as an empty string is the same as not specifying them. When 0 is specified for start or size, Ignition checks if the existing partition's start / size match what they would be if all of the partitions specified were to be deleted (if allowed by wipPartitionEntry), then recreated if `shouldExist` is true. | ||
|
||
### Partition number 0 | ||
Specifying `number` as 0 will use the next available partition number. Partition number 0 is disallowed on disks with partitions that specify `shouldExist` as 0. If `number` is not specified it will be treated as 0. |
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'm having problems following this. How can a partition specify shouldExist
as 0? shouldExist
is a boolean.
@@ -22,9 +22,14 @@ import ( | |||
"github.com/coreos/ignition/config/validate/report" | |||
) | |||
|
|||
// redfined here to avoid import cycles |
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.
nit: redefined
} | ||
|
||
// partitionMatches determines if the existing partition matches the spec given. See doc/operator notes for what | ||
// what it means for an existing partition to match the spec. spec must have non-zero Start an Size. existing must |
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.
nit: s/an/and/
|
||
// parseLine takes a regexp that captures an int and a string to match on. On success it returns | ||
// the captured int and nil. If the regexp does not match it returns -1 and nil. If it encountered | ||
// and error it returns 0 and the error. |
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.
nit: s/and/an/
Change the partitioning semantics to be more similar to the filesystem reuse semantics. Support deletion and recreation of partitions.
Add wipePartition flag to storage.disks.partitions. Add shouldExist flag to storage.disks.partitions. Make partition label, size, and start a pointer type so not specifying it is distinguishable from the go zero value.
Handle start, size, and label being nil-able.
Some fields became pointers. Update the 2.2.0 -> 2.3.0-exp translation to handle that.
Fix the disks stage to handle label, start, and size being pointers. This is be removed by later commits, but I wanted to have a testable point first.
Change the blkid probing to probe for partition information as well. Add new stub definitions to .travis.yml
- Refactor sgdisk to reuse types.Partition instead of its own struct. - Add the ability for sgdisk to delete partitions. - Add the ability for sgdisk to read partition info resulting from running in pretend mode.
The disks.go file is quite large. Refactor into multiple files for common functionality, partitioning, raid, and filesystems.
Add filesystem reuse like semantics to partitioning. This will allow partitions to be specified as non-existent, prevent them from being recreated if they already exist and a bunch of other goodies like that.
Fix partition validation to be cAsE insensitive whn comparing type guids and correctly skip blank partitions.
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.
Drive-by copyedit!
@@ -28,13 +28,16 @@ The Ignition configuration is a JSON document conforming to the following specif | |||
* **_disks_** (list of objects): the list of disks to be configured and their options. | |||
* **device** (string): the absolute path to the device. Devices are typically referenced by the `/dev/disk/by-*` symlinks. | |||
* **_wipeTable_** (boolean): whether or not the partition tables shall be wiped. When true, the partition tables are erased before any further manipulation. Otherwise, the existing entries are left intact. | |||
* **disallowUnspecifiedPartitions** (boolean): whether or not to fail if a disk has partitions not described by Ignition. Has no effect if "wipeTable" is true. |
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.
Missing italics.
I think partitions not described in the config
is what this is implying?
wipeTable
should be monospace I think.
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.
this was meant to be dropped from the docs since its not implemented yet (it was seperable from the rest). Will just drop
|
||
## Partition Reuse Semantics | ||
|
||
The `wipePartitionEntry` and `shouldExist` flags control what Ignition will do when it encounters an existing partition. `wipePartitionEntry` specifies whether Ignition is permitted to delete partition entries in the partition table. `shouldExist` specifies whether a partition with that number should exist or not (it is invalid to specify a partition should not exist and specify its attributes, such as `size` or `label`). |
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.
to specify that a partition should not exist and also to specify
|
||
The `wipePartitionEntry` and `shouldExist` flags control what Ignition will do when it encounters an existing partition. `wipePartitionEntry` specifies whether Ignition is permitted to delete partition entries in the partition table. `shouldExist` specifies whether a partition with that number should exist or not (it is invalid to specify a partition should not exist and specify its attributes, such as `size` or `label`). | ||
|
||
The following table shows the possible combinations of whether or not a partition with the specified number is present, `shouldExist`, and `wipePartitionEntry`, and the action Ignition will take |
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.
trailing colon:
* **_partitions_** (list of objects): the list of partitions and their configuration for this particular disk. | ||
* **_label_** (string): the PARTLABEL for the partition. | ||
* **_number_** (integer): the partition number, which dictates it's position in the partition table (one-indexed). If zero, use the next available partition slot. | ||
* **_size_** (integer): the size of the partition (in device logical sectors, 512 or 4096 bytes). If zero, the partition will be made as large as possible. | ||
* **_start_** (integer): the start of the partition (in device logical sectors). If zero, the partition will be positioned at the start of the largest block available. | ||
* **_typeGuid_** (string): the GPT [partition type GUID][part-types]. If omitted, the default will be 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem data). | ||
* **_guid_** (string): the GPT unique partition GUID. | ||
* **_wipePartitionEntry_** (boolean) whether or not Ignition is allowed to wipe an existing partition entry for this partition number. |
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.
This isn't very clear. I think the important point is that true
=> Ignition will clobber an existing partition if necessary to make the disk match the config; false
=> Ignition will fail instead.
* **_partitions_** (list of objects): the list of partitions and their configuration for this particular disk. | ||
* **_label_** (string): the PARTLABEL for the partition. | ||
* **_number_** (integer): the partition number, which dictates it's position in the partition table (one-indexed). If zero, use the next available partition slot. | ||
* **_size_** (integer): the size of the partition (in device logical sectors, 512 or 4096 bytes). If zero, the partition will be made as large as possible. | ||
* **_start_** (integer): the start of the partition (in device logical sectors). If zero, the partition will be positioned at the start of the largest block available. | ||
* **_typeGuid_** (string): the GPT [partition type GUID][part-types]. If omitted, the default will be 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem data). | ||
* **_guid_** (string): the GPT unique partition GUID. | ||
* **_wipePartitionEntry_** (boolean) whether or not Ignition is allowed to wipe an existing partition entry for this partition number. | ||
* **_shouldExist_** (boolean) whether or not a partition `number` should exist. If ommited, it defaults to true. If false, `number` must be specified and non-zero and `label`, `start`, `size`, `guid`, and `typeGuid` must all be omitted. |
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.
"whether or not the partition with the specified number
"
omitted
The consequences of false
are implied, but maybe should be explicit: Ignition will either delete the partition or fail, depending on wipePartitionEntry
.
Specifying `start` as 0 will use the starting sector of the largest available block. It will *not* use the first available block large enough. | ||
|
||
### Unspecified partition start | ||
If `start` is not specified and a partition with the same number exists, it will use the value of the existing partition, unless wipePartitionEntry is set. |
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.
Ignition will use the start of the existing partition
|
||
### Unspecified partition start | ||
If `start` is not specified and a partition with the same number exists, it will use the value of the existing partition, unless wipePartitionEntry is set. | ||
If `start` is not specified and there is no existing partition, or wipePartitionEntry is set, `start` act as if it were set to 0 and use the starting sector of the largest available block. |
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.
or `wipePartitionEntry` is set, Ignition will use the starting sector of the largest available block, as if `start` were set to 0.
If `start` is not specified and there is no existing partition, or wipePartitionEntry is set, `start` act as if it were set to 0 and use the starting sector of the largest available block. | ||
|
||
### Partition size 0 | ||
Specifying `size` as 0 means the partition should span to the end of the largest available block. It will *not* use the size of first available block. |
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.
Maybe something like: If `size` is specified as 0, the partition will span to the end of the largest available block. If the starting sector is not within the largest available block, Ignition will fail.
Specifying `size` as 0 means the partition should span to the end of the largest available block. It will *not* use the size of first available block. | ||
|
||
### Unspecified partition size | ||
If `size` is not specified and a partition with the same number exists, it will use the value of the existing partition, unless wipePartitionEntry is set. |
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.
Ignition will use the size of the existing partition
|
||
### Unspecified partition size | ||
If `size` is not specified and a partition with the same number exists, it will use the value of the existing partition, unless wipePartitionEntry is set. | ||
If `size` is not specified and there is no existing partition, or wipePartitionEntry is set, `size` act as if it were set to 0 and use the size of the largest block. |
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.
or `wipePartitionEntry` is set, the partition will span to the end of the largest available block, as if `size` were set to 0.
Improve partition semantics
When `wipeTable` is enabled, we run `sgdisk --zap-all`. But if the table was corrupted in the first place, `sgdisk` will exit with code 2 which then breaks boot. As a workaround, Ignition used to retry the invocation but the context around it was lost in coreos#544 and coreos#1149 and the retry was removed and the error-checking was added. So this patch effectively re-applies 94c98bc ("sgdisk: retry zap-all operation on failure"), but now with a comment and a test to make sure we don't regress again. Closes: coreos/fedora-coreos-tracker#1596
When `wipeTable` is enabled, we run `sgdisk --zap-all`. But if the table was corrupted in the first place, `sgdisk` will exit with code 2 which then breaks boot. As a workaround, Ignition used to retry the invocation but the context around it was lost in coreos#544 and coreos#1149 and the retry was removed and the error-checking was added. So this patch effectively re-applies 94c98bc ("sgdisk: retry zap-all operation on failure"), but now with a comment and a test to make sure we don't regress again. Closes: coreos/fedora-coreos-tracker#1596
When `wipeTable` is enabled, we run `sgdisk --zap-all`. But if the table was corrupted in the first place, `sgdisk` will exit with code 2 which then breaks boot. As a workaround, Ignition used to retry the invocation but the context around it was lost in coreos#544 and coreos#1149 and the retry was removed and the error-checking was added. So this patch effectively re-applies 94c98bc ("sgdisk: retry zap-all operation on failure"), but now with a comment and a test to make sure we don't regress again. Closes: coreos/fedora-coreos-tracker#1596
Supercedes #442
Add filesystem-reuse-like semantics for partitions. This allows for
Worth noting that this does not handle every possible case, since I didn't feel like Ignition should solve the bin-packing problem on first boot.
I'll push another commit to the docs with some examples, but wanted to open this up first.
cc
@dgonyeo for implemention
@bgilbert for docs clarity
@arithx for tests
@dustymabe and @cgwalters since they expressed interest in reviewing Ignition PRs
Addresses coreos/bugs#2388