From 323df1d61593d55a072560e3f471d8133a108ce2 Mon Sep 17 00:00:00 2001 From: Joshua Ferguson Date: Mon, 24 Aug 2026 11:30:27 -0400 Subject: [PATCH] butane/ */translate: fix root partition constraint check to only examine subsequent partitions --- butane/config/fcos/v1_3/translate.go | 5 +-- butane/config/fcos/v1_3/translate_test.go | 31 +++++++++++++++++++ butane/config/fcos/v1_4/translate.go | 5 +-- butane/config/fcos/v1_4/translate_test.go | 31 +++++++++++++++++++ butane/config/fcos/v1_5/translate.go | 5 +-- butane/config/fcos/v1_5/translate_test.go | 31 +++++++++++++++++++ butane/config/fcos/v1_6/translate.go | 5 +-- butane/config/fcos/v1_6/translate_test.go | 31 +++++++++++++++++++ butane/config/fcos/v1_7/translate.go | 5 +-- butane/config/fcos/v1_7/translate_test.go | 31 +++++++++++++++++++ butane/config/fcos/v1_8_exp/translate.go | 5 +-- butane/config/fcos/v1_8_exp/translate_test.go | 31 +++++++++++++++++++ docs/release-notes.md | 1 + 13 files changed, 193 insertions(+), 24 deletions(-) diff --git a/butane/config/fcos/v1_3/translate.go b/butane/config/fcos/v1_3/translate.go index dce129640..bc17d347a 100644 --- a/butane/config/fcos/v1_3/translate.go +++ b/butane/config/fcos/v1_3/translate.go @@ -75,10 +75,7 @@ func (c Config) ToIgn3_2Unvalidated(options common.TranslateOptions) (types.Conf if partition.Label != nil { if *partition.Label == "root" { if partition.SizeMiB == nil || *partition.SizeMiB == 0 { - for idx := range disk.Partitions { - if idx == p { - continue - } + for idx := p + 1; idx < len(disk.Partitions); idx++ { if disk.Partitions[idx].StartMiB == nil || *disk.Partitions[idx].StartMiB == 0 { r.AddOnWarn(path.New("json", "storage", "disks", i, "partitions", p, "label"), common.ErrRootConstrained) break diff --git a/butane/config/fcos/v1_3/translate_test.go b/butane/config/fcos/v1_3/translate_test.go index f83842b92..da147e280 100644 --- a/butane/config/fcos/v1_3/translate_test.go +++ b/butane/config/fcos/v1_3/translate_test.go @@ -1652,6 +1652,37 @@ func TestRootPartitionConstraints(t *testing.T) { }, }, }, + { + name: "root last with sized partitions before", + in: Config{ + Config: base.Config{ + Storage: base.Storage{ + Disks: []base.Disk{ + { + Device: "/dev/vda", + Partitions: []base.Partition{ + { + Label: util.StrToPtr("bios"), + Number: 1, + SizeMiB: util.IntToPtr(1), + }, + { + Label: util.StrToPtr("boot"), + Number: 3, + SizeMiB: util.IntToPtr(2048), + }, + { + Label: util.StrToPtr("root"), + Number: 4, + }, + }, + }, + }, + }, + }, + }, + report: report.Report{}, // no warning expected + }, } for _, test := range tests { diff --git a/butane/config/fcos/v1_4/translate.go b/butane/config/fcos/v1_4/translate.go index 10f6885ef..357b326f0 100644 --- a/butane/config/fcos/v1_4/translate.go +++ b/butane/config/fcos/v1_4/translate.go @@ -75,10 +75,7 @@ func (c Config) ToIgn3_3Unvalidated(options common.TranslateOptions) (types.Conf if partition.Label != nil { if *partition.Label == "root" { if partition.SizeMiB == nil || *partition.SizeMiB == 0 { - for idx := range disk.Partitions { - if idx == p { - continue - } + for idx := p + 1; idx < len(disk.Partitions); idx++ { if disk.Partitions[idx].StartMiB == nil || *disk.Partitions[idx].StartMiB == 0 { r.AddOnWarn(path.New("json", "storage", "disks", i, "partitions", p, "label"), common.ErrRootConstrained) break diff --git a/butane/config/fcos/v1_4/translate_test.go b/butane/config/fcos/v1_4/translate_test.go index 5dcf332a1..6ee9f27ef 100644 --- a/butane/config/fcos/v1_4/translate_test.go +++ b/butane/config/fcos/v1_4/translate_test.go @@ -1652,6 +1652,37 @@ func TestRootPartitionConstraints(t *testing.T) { }, }, }, + { + name: "root last with sized partitions before", + in: Config{ + Config: base.Config{ + Storage: base.Storage{ + Disks: []base.Disk{ + { + Device: "/dev/vda", + Partitions: []base.Partition{ + { + Label: util.StrToPtr("bios"), + Number: 1, + SizeMiB: util.IntToPtr(1), + }, + { + Label: util.StrToPtr("boot"), + Number: 3, + SizeMiB: util.IntToPtr(2048), + }, + { + Label: util.StrToPtr("root"), + Number: 4, + }, + }, + }, + }, + }, + }, + }, + report: report.Report{}, // no warning expected + }, } for _, test := range tests { diff --git a/butane/config/fcos/v1_5/translate.go b/butane/config/fcos/v1_5/translate.go index 973432577..c2ee380ca 100644 --- a/butane/config/fcos/v1_5/translate.go +++ b/butane/config/fcos/v1_5/translate.go @@ -76,10 +76,7 @@ func (c Config) ToIgn3_4Unvalidated(options common.TranslateOptions) (types.Conf if partition.Label != nil { if *partition.Label == "root" { if partition.SizeMiB == nil || *partition.SizeMiB == 0 { - for idx := range disk.Partitions { - if idx == p { - continue - } + for idx := p + 1; idx < len(disk.Partitions); idx++ { if disk.Partitions[idx].StartMiB == nil || *disk.Partitions[idx].StartMiB == 0 { r.AddOnWarn(path.New("json", "storage", "disks", i, "partitions", p, "label"), common.ErrRootConstrained) break diff --git a/butane/config/fcos/v1_5/translate_test.go b/butane/config/fcos/v1_5/translate_test.go index 88a277381..179ec0c88 100644 --- a/butane/config/fcos/v1_5/translate_test.go +++ b/butane/config/fcos/v1_5/translate_test.go @@ -1734,6 +1734,37 @@ func TestRootPartitionConstraints(t *testing.T) { }, }, }, + { + name: "root last with sized partitions before", + in: Config{ + Config: base.Config{ + Storage: base.Storage{ + Disks: []base.Disk{ + { + Device: "/dev/vda", + Partitions: []base.Partition{ + { + Label: util.StrToPtr("bios"), + Number: 1, + SizeMiB: util.IntToPtr(1), + }, + { + Label: util.StrToPtr("boot"), + Number: 3, + SizeMiB: util.IntToPtr(2048), + }, + { + Label: util.StrToPtr("root"), + Number: 4, + }, + }, + }, + }, + }, + }, + }, + report: report.Report{}, // no warning expected + }, } for _, test := range tests { diff --git a/butane/config/fcos/v1_6/translate.go b/butane/config/fcos/v1_6/translate.go index 504c25441..ff0d40368 100644 --- a/butane/config/fcos/v1_6/translate.go +++ b/butane/config/fcos/v1_6/translate.go @@ -76,10 +76,7 @@ func (c Config) ToIgn3_5Unvalidated(options common.TranslateOptions) (types.Conf if partition.Label != nil { if *partition.Label == "root" { if partition.SizeMiB == nil || *partition.SizeMiB == 0 { - for idx := range disk.Partitions { - if idx == p { - continue - } + for idx := p + 1; idx < len(disk.Partitions); idx++ { if disk.Partitions[idx].StartMiB == nil || *disk.Partitions[idx].StartMiB == 0 { r.AddOnWarn(path.New("json", "storage", "disks", i, "partitions", p, "label"), common.ErrRootConstrained) break diff --git a/butane/config/fcos/v1_6/translate_test.go b/butane/config/fcos/v1_6/translate_test.go index 1891f254d..0816aa5ec 100644 --- a/butane/config/fcos/v1_6/translate_test.go +++ b/butane/config/fcos/v1_6/translate_test.go @@ -1734,6 +1734,37 @@ func TestRootPartitionConstraints(t *testing.T) { }, }, }, + { + name: "root last with sized partitions before", + in: Config{ + Config: base.Config{ + Storage: base.Storage{ + Disks: []base.Disk{ + { + Device: "/dev/vda", + Partitions: []base.Partition{ + { + Label: util.StrToPtr("bios"), + Number: 1, + SizeMiB: util.IntToPtr(1), + }, + { + Label: util.StrToPtr("boot"), + Number: 3, + SizeMiB: util.IntToPtr(2048), + }, + { + Label: util.StrToPtr("root"), + Number: 4, + }, + }, + }, + }, + }, + }, + }, + report: report.Report{}, // no warning expected + }, } for _, test := range tests { diff --git a/butane/config/fcos/v1_7/translate.go b/butane/config/fcos/v1_7/translate.go index 51d50e86d..e5034f49f 100644 --- a/butane/config/fcos/v1_7/translate.go +++ b/butane/config/fcos/v1_7/translate.go @@ -76,10 +76,7 @@ func (c Config) ToIgn3_6Unvalidated(options common.TranslateOptions) (types.Conf if partition.Label != nil { if *partition.Label == "root" { if partition.SizeMiB == nil || *partition.SizeMiB == 0 { - for idx := range disk.Partitions { - if idx == p { - continue - } + for idx := p + 1; idx < len(disk.Partitions); idx++ { if disk.Partitions[idx].StartMiB == nil || *disk.Partitions[idx].StartMiB == 0 { r.AddOnWarn(path.New("json", "storage", "disks", i, "partitions", p, "label"), common.ErrRootConstrained) break diff --git a/butane/config/fcos/v1_7/translate_test.go b/butane/config/fcos/v1_7/translate_test.go index 8b35f70b4..c79f37d98 100644 --- a/butane/config/fcos/v1_7/translate_test.go +++ b/butane/config/fcos/v1_7/translate_test.go @@ -1735,6 +1735,37 @@ func TestRootPartitionConstraints(t *testing.T) { }, }, }, + { + name: "root last with sized partitions before", + in: Config{ + Config: base.Config{ + Storage: base.Storage{ + Disks: []base.Disk{ + { + Device: "/dev/vda", + Partitions: []base.Partition{ + { + Label: util.StrToPtr("bios"), + Number: 1, + SizeMiB: util.IntToPtr(1), + }, + { + Label: util.StrToPtr("boot"), + Number: 3, + SizeMiB: util.IntToPtr(2048), + }, + { + Label: util.StrToPtr("root"), + Number: 4, + }, + }, + }, + }, + }, + }, + }, + report: report.Report{}, // no warning expected + }, } for _, test := range tests { diff --git a/butane/config/fcos/v1_8_exp/translate.go b/butane/config/fcos/v1_8_exp/translate.go index bdbc202e8..bf99eaf2c 100644 --- a/butane/config/fcos/v1_8_exp/translate.go +++ b/butane/config/fcos/v1_8_exp/translate.go @@ -76,10 +76,7 @@ func (c Config) ToIgn3_7Unvalidated(options common.TranslateOptions) (types.Conf if partition.Label != nil { if *partition.Label == "root" { if partition.SizeMiB == nil || *partition.SizeMiB == 0 { - for idx := range disk.Partitions { - if idx == p { - continue - } + for idx := p + 1; idx < len(disk.Partitions); idx++ { if disk.Partitions[idx].StartMiB == nil || *disk.Partitions[idx].StartMiB == 0 { r.AddOnWarn(path.New("json", "storage", "disks", i, "partitions", p, "label"), common.ErrRootConstrained) break diff --git a/butane/config/fcos/v1_8_exp/translate_test.go b/butane/config/fcos/v1_8_exp/translate_test.go index fceab29d9..916d5aa34 100644 --- a/butane/config/fcos/v1_8_exp/translate_test.go +++ b/butane/config/fcos/v1_8_exp/translate_test.go @@ -1881,6 +1881,37 @@ func TestRootPartitionConstraints(t *testing.T) { }, }, }, + { + name: "root last with sized partitions before", + in: Config{ + Config: base.Config{ + Storage: base.Storage{ + Disks: []base.Disk{ + { + Device: "/dev/vda", + Partitions: []base.Partition{ + { + Label: util.StrToPtr("bios"), + Number: 1, + SizeMiB: util.IntToPtr(1), + }, + { + Label: util.StrToPtr("boot"), + Number: 3, + SizeMiB: util.IntToPtr(2048), + }, + { + Label: util.StrToPtr("root"), + Number: 4, + }, + }, + }, + }, + }, + }, + }, + report: report.Report{}, // no warning expected + }, } for _, test := range tests { diff --git a/docs/release-notes.md b/docs/release-notes.md index 2107a55b9..d49272028 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -22,6 +22,7 @@ nav_order: 9 - Resolve intermediate symlinks in relabel paths, fixing SELinux relabeling failures for users with `home_dir` on OSTree platforms after policycoreutils 3.11 ([#2316](https://github.com/coreos/ignition/pull/2316)) - Fix Butane rendering large `sizeMiB`/`startMiB` values in scientific notation when generating OpenShift MachineConfig YAML ([#2310](https://github.com/coreos/ignition/pull/2310)) +- Fix the Butane root partition constraint check to only examine subsequent partitions ([#2304](https://github.com/coreos/ignition/pull/2304)) ## Ignition 2.27.0 (2026-08-26)