Skip to content
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

Merged
merged 12 commits into from May 31, 2018
Merged

Conversation

ajeddeloh
Copy link
Contributor

@ajeddeloh ajeddeloh commented May 16, 2018

Supercedes #442

Add filesystem-reuse-like semantics for partitions. This allows for

  • Backwards compatibility with the current implementation
  • Resizing and otherwise modifying existing partitions
  • Matching partitions to avoid recreation when possible
  • The ability to match on the start/size 0 (as interpreted by sgdisk)

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

@ajeddeloh
Copy link
Contributor Author

retest this please

@cgwalters
Copy link
Member

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?

@cgwalters
Copy link
Member

Nevermind I saw coreos/bugs#2388

}

func NotThereAndDoesNotMatchNoWipeEntry() types.Test {
name := "Partition does not match and wipePartitionEntry is false but the first partition matches"
Copy link
Contributor

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

Copy link
Contributor Author

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

}

func Partition9DoesNotStartCorrectly() types.Test {
name := "Partition 9 is does not start at the largest chunk"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/is //g

)

func init() {
// Everything and the kitchen sunk
Copy link
Contributor

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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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"
Copy link
Contributor

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?

Copy link
Contributor Author

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"
Copy link
Contributor

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

}

func PartitionStartNumber0() types.Test {
name := "Create a partition with size and start 0"
Copy link
Contributor

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

Copy link
Contributor Author

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"
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Member

@cgwalters cgwalters left a 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"`
Copy link
Member

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)

Copy link
Contributor Author

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
Copy link
Member

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?

Copy link
Contributor Author

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)


blkid_parttable table = blkid_partlist_get_table(list);
if (!table) {
blkid_free_probe(pr);
Copy link
Member

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++).

Copy link
Contributor Author

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?

Copy link
Member

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)

// 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) {
Copy link
Member

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?

Copy link
Contributor Author

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.

@ajeddeloh
Copy link
Contributor Author

@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.

@ajeddeloh
Copy link
Contributor Author

@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.

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.
Copy link
Contributor

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.

Copy link
Contributor

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 as false and wipePartitionEntry as true, and another partition is specified to be created with number as 0, it will get partition number 9

Copy link
Contributor

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.

Copy link
Contributor Author

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

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.
Copy link
Contributor

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" ?

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.
Copy link
Contributor

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?

Copy link
Contributor

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.

}

// 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/its/it/

// Returns:
// RESULT_LOOKUP_FAILED if src is null
// RESULT_OVERFLOW if src is too big
// 0 on success
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Ans/And/

Copy link
Contributor

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) {
Copy link
Contributor

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.
Copy link
Contributor

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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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,
Copy link
Contributor

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?

}

func VerifyUnspecifiedIsDoNotCare() types.Test {
name := "Verify the ROOT partition to fills the default disk"
Copy link
Contributor

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

@ajeddeloh ajeddeloh force-pushed the parition-230-2 branch 2 times, most recently from c67e52b to 0b9854a Compare May 21, 2018 22:18
@ajeddeloh
Copy link
Contributor Author

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.

Copy link
Contributor

@arithx arithx left a 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 {
Copy link
Contributor

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"
Copy link
Contributor

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"
Copy link
Contributor

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"`
Copy link
Contributor

@lucab lucab May 23, 2018

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 ints) is really a uint. Does schematyper support specifying that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, which is unfortunate.

Copy link
Contributor

@cgonyeo cgonyeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, pending nits


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
Copy link
Contributor

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

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.
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/and/an/

Andrew Jeddeloh added 12 commits May 31, 2018 13:31
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.
@ajeddeloh ajeddeloh merged commit 2d7f17c into coreos:master May 31, 2018
Copy link
Contributor

@bgilbert bgilbert left a 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.
Copy link
Contributor

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.

Copy link
Contributor Author

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`).
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.

Rahuls0720 pushed a commit to Rahuls0720/ignition that referenced this pull request Jun 13, 2018
jlebon added a commit to jlebon/ignition that referenced this pull request Oct 25, 2023
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
jlebon added a commit to jlebon/ignition that referenced this pull request Oct 25, 2023
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
jlebon added a commit to jlebon/ignition that referenced this pull request Oct 25, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants