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/butane/docs/release-notes.md b/butane/docs/release-notes.md index 8306efae5..bc9cec68d 100644 --- a/butane/docs/release-notes.md +++ b/butane/docs/release-notes.md @@ -21,6 +21,7 @@ Butane 0.29.0 is the last release from this standalone repository. Butane has be ### Bug fixes + ### Misc. changes - Add support for pretty error reporting, can be controlled through diff --git a/docs/release-notes.md b/docs/release-notes.md index b9020a1e8..a6f6b0206 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -19,6 +19,7 @@ nav_order: 9 ### Bug fixes +- fix butane root partition constraint check to only examine subsequent partitions ## Upcoming Ignition 2.27.0 (unreleased)