Skip to content

Commit 98397ca

Browse files
committed
fcos translate.go: add warn on small or constrained root partition
Fixes #211 , add warning for under allocation of root partition. additionally add warning when root partition's expansion is constrained
1 parent f8d7a46 commit 98397ca

File tree

4 files changed

+1689
-1378
lines changed

4 files changed

+1689
-1378
lines changed

config/common/errors.go

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ var (
3737
ErrNodeExists = errors.New("matching filesystem node has existing contents or different type")
3838
ErrNoFilesDir = errors.New("local file paths are relative to a files directory that must be specified with -d/--files-dir")
3939
ErrTreeNotDirectory = errors.New("root of tree must be a directory")
40+
ErrRootTooSmall = errors.New("root should have 8GiB of space assigned")
41+
ErrRootConstrained = errors.New("root is configured too small, and has no room to expand")
4042
ErrTreeNoLocal = errors.New("local is required")
4143

4244
// filesystem nodes

config/fcos/v1_5_exp/translate.go

+24-7
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,34 @@ func (c Config) ToIgn3_4Unvalidated(options common.TranslateOptions) (types.Conf
6868
return types.Config{}, translate.TranslationSet{}, r
6969
}
7070
r.Merge(c.processBootDevice(&ret, &ts, options))
71+
7172
for i, disk := range ret.Storage.Disks {
72-
// In the boot_device.mirror case, nothing specifies partition numbers
73-
// so match existing partitions only when `wipeTable` is false
74-
if !util.IsTrue(disk.WipeTable) {
75-
for j, partition := range disk.Partitions {
76-
// check for reserved partlabels
77-
if partition.Label != nil {
73+
for p, partition := range disk.Partitions {
74+
//if the partition is not nil and is root
75+
if partition.Label != nil {
76+
if *partition.Label == "root" {
77+
if partition.SizeMiB == nil || *partition.SizeMiB == 0 {
78+
for _, ap := range disk.Partitions {
79+
if ap.Number == partition.Number+1 {
80+
if ap.StartMiB == nil || *ap.StartMiB == 0 {
81+
r.AddOnWarn(path.New("json", "storage", "disks", i, "partitions", p, "number"), common.ErrRootConstrained)
82+
}
83+
}
84+
}
85+
} else if *partition.SizeMiB < 8192 {
86+
r.AddOnWarn(path.New("json", "storage", "disks", i, "partitions", p, "size_mib"), common.ErrRootTooSmall)
87+
}
88+
}
89+
90+
// In the boot_device.mirror case, nothing specifies partition numbers
91+
// so match existing partitions only when `wipeTable` is false
92+
if !util.IsTrue(disk.WipeTable) {
93+
// check for reseved partlabels
7894
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) {
79-
r.AddOnWarn(path.New("json", "storage", "disks", i, "partitions", j, "label"), common.ErrWrongPartitionNumber)
95+
r.AddOnWarn(path.New("json", "storage", "disks", i, "partitions", p, "label"), common.ErrWrongPartitionNumber)
8096
}
8197
}
98+
8299
}
83100
}
84101
}

0 commit comments

Comments
 (0)