Skip to content

Commit

Permalink
fcos translate.go: add warn on small or constrained root partition
Browse files Browse the repository at this point in the history
  • Loading branch information
prestist committed Aug 22, 2022
1 parent f8d7a46 commit b95add4
Show file tree
Hide file tree
Showing 4 changed files with 1,689 additions and 1,378 deletions.
2 changes: 2 additions & 0 deletions config/common/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ var (
ErrNodeExists = errors.New("matching filesystem node has existing contents or different type")
ErrNoFilesDir = errors.New("local file paths are relative to a files directory that must be specified with -d/--files-dir")
ErrTreeNotDirectory = errors.New("root of tree must be a directory")
ErrRootTooSmall = errors.New("root should have 8GiB of space assigned")
ErrRootConstrained = errors.New("root is configured too small, and has no room to expand")
ErrTreeNoLocal = errors.New("local is required")

// filesystem nodes
Expand Down
31 changes: 24 additions & 7 deletions config/fcos/v1_5_exp/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,34 @@ func (c Config) ToIgn3_4Unvalidated(options common.TranslateOptions) (types.Conf
return types.Config{}, translate.TranslationSet{}, r
}
r.Merge(c.processBootDevice(&ret, &ts, options))

for i, disk := range ret.Storage.Disks {
// In the boot_device.mirror case, nothing specifies partition numbers
// so match existing partitions only when `wipeTable` is false
if !util.IsTrue(disk.WipeTable) {
for j, partition := range disk.Partitions {
// check for reserved partlabels
if partition.Label != nil {
for p, partition := range disk.Partitions {
//if the partition is not nil and is root
if partition.Label != nil {
if *partition.Label == "root" {
if partition.SizeMiB == nil || *partition.SizeMiB == 0 {
for _, ap := range disk.Partitions {
if ap.Number == partition.Number+1 {
if ap.StartMiB == nil || *ap.StartMiB == 0 {
r.AddOnWarn(path.New("json", "storage", "disks", i, "partitions", p, "number"), common.ErrRootConstrained)
}
}
}
} else if *partition.SizeMiB < 8192 {
r.AddOnWarn(path.New("json", "storage", "disks", i, "partitions", p, "size_mib"), common.ErrRootTooSmall)
}
}

// In the boot_device.mirror case, nothing specifies partition numbers
// so match existing partitions only when `wipeTable` is false
if !util.IsTrue(disk.WipeTable) {
// check for reseved partlabels
if (*partition.Label == "BIOS-BOOT" && partition.Number != 1) || (*partition.Label == "PowerPC-PReP-boot" && partition.Number != 1) || (*partition.Label == "EFI-SYSTEM" && partition.Number != 2) || (*partition.Label == "boot" && partition.Number != 3) || (*partition.Label == "root" && partition.Number != 4) {
r.AddOnWarn(path.New("json", "storage", "disks", i, "partitions", j, "label"), common.ErrWrongPartitionNumber)
r.AddOnWarn(path.New("json", "storage", "disks", i, "partitions", p, "label"), common.ErrWrongPartitionNumber)
}
}

}
}
}
Expand Down
Loading

0 comments on commit b95add4

Please sign in to comment.