Skip to content

Commit

Permalink
config/fcos: warn if partition number for root isn't correct
Browse files Browse the repository at this point in the history
Fixes coreos#243

This change warns if the partition number for the root label is not
specified or wrongly mentioned.
  • Loading branch information
sohankunkerkar committed Sep 13, 2021
1 parent dcc128a commit b91fa5e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/common/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ var (
ErrUnknownBootDeviceLayout = errors.New("layout must be one of: aarch64, ppc64le, x86_64")
ErrTooFewMirrorDevices = errors.New("mirroring requires at least two devices")

// partition
ErrWrongPartitionNumberForRoot = errors.New("new partition using reserved label \"root\"")

// MachineConfigs
ErrFieldElided = errors.New("field ignored in raw mode")
ErrNameRequired = errors.New("metadata.name is required")
Expand Down
7 changes: 7 additions & 0 deletions config/fcos/v1_3/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ func (c Config) ToIgn3_2Unvalidated(options common.TranslateOptions) (types.Conf
return types.Config{}, translate.TranslationSet{}, r
}
r.Merge(c.processBootDevice(&ret, &ts, options))
for _, disk := range ret.Storage.Disks {
for _, partition := range disk.Partitions {
if *partition.Label == "root" && partition.Number != 4 {
r.AddOnWarn(path.New("yaml", "fcos", "partition"), common.ErrWrongPartitionNumberForRoot)
}
}
}
return ret, ts, r
}

Expand Down
7 changes: 7 additions & 0 deletions config/fcos/v1_4/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ func (c Config) ToIgn3_3Unvalidated(options common.TranslateOptions) (types.Conf
return types.Config{}, translate.TranslationSet{}, r
}
r.Merge(c.processBootDevice(&ret, &ts, options))
for _, disk := range ret.Storage.Disks {
for _, partition := range disk.Partitions {
if *partition.Label == "root" && partition.Number != 4 {
r.AddOnWarn(path.New("yaml", "fcos", "partition"), common.ErrWrongPartitionNumberForRoot)
}
}
}
return ret, ts, r
}

Expand Down
7 changes: 7 additions & 0 deletions config/fcos/v1_5_exp/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ func (c Config) ToIgn3_4Unvalidated(options common.TranslateOptions) (types.Conf
return types.Config{}, translate.TranslationSet{}, r
}
r.Merge(c.processBootDevice(&ret, &ts, options))
for _, disk := range ret.Storage.Disks {
for _, partition := range disk.Partitions {
if *partition.Label == "root" && partition.Number != 4 {
r.AddOnWarn(path.New("yaml", "fcos", "partition"), common.ErrWrongPartitionNumberForRoot)
}
}
}
return ret, ts, r
}

Expand Down

0 comments on commit b91fa5e

Please sign in to comment.