diff --git a/config/fcos/v1_6_exp/validate.go b/config/fcos/v1_6_exp/validate.go index 481e3d84..ed705607 100644 --- a/config/fcos/v1_6_exp/validate.go +++ b/config/fcos/v1_6_exp/validate.go @@ -16,6 +16,7 @@ package v1_6_exp import ( "regexp" + "strings" "github.com/coreos/butane/config/common" "github.com/coreos/ignition/v2/config/util" @@ -56,25 +57,24 @@ func (d BootDevice) Validate(c path.ContextPath) (r report.Report) { case "aarch64", "ppc64le", "x86_64": case "s390x-eckd": if util.NilOrEmpty(d.Luks.Device) { - r.AddOnError(c.Append(*d.Layout), common.ErrNoLuksBootDevice) + r.AddOnError(c.Append("layout"), common.ErrNoLuksBootDevice) } else if !dasdRe.MatchString(*d.Luks.Device) { - r.AddOnError(c.Append(*d.Layout), common.ErrLuksBootDeviceBadName) + r.AddOnError(c.Append("layout"), common.ErrLuksBootDeviceBadName) } case "s390x-zfcp": if util.NilOrEmpty(d.Luks.Device) { - r.AddOnError(c.Append(*d.Layout), common.ErrNoLuksBootDevice) + r.AddOnError(c.Append("layout"), common.ErrNoLuksBootDevice) } else if !sdRe.MatchString(*d.Luks.Device) { - r.AddOnError(c.Append(*d.Layout), common.ErrLuksBootDeviceBadName) + r.AddOnError(c.Append("layout"), common.ErrLuksBootDeviceBadName) } case "s390x-virt": default: r.AddOnError(c.Append("layout"), common.ErrUnknownBootDeviceLayout) } - if *d.Layout == "s390x-eckd" || *d.Layout == "s390x-zfcp" || *d.Layout == "s390x-virt" { - if len(d.Mirror.Devices) > 0 { - r.AddOnError(c.Append(*d.Layout), common.ErrMirrorNotSupport) - } + // Mirroring the boot disk is not supported on s390x + if strings.HasPrefix(*d.Layout, "s390x") && len(d.Mirror.Devices) > 0 { + r.AddOnError(c.Append("layout"), common.ErrMirrorNotSupport) } } r.Merge(d.Mirror.Validate(c.Append("mirror"))) diff --git a/config/fcos/v1_6_exp/validate_test.go b/config/fcos/v1_6_exp/validate_test.go index 2c850580..acd302d9 100644 --- a/config/fcos/v1_6_exp/validate_test.go +++ b/config/fcos/v1_6_exp/validate_test.go @@ -179,6 +179,56 @@ func TestValidateBootDevice(t *testing.T) { common.ErrTooFewMirrorDevices, path.New("yaml", "mirror", "devices"), }, + // s390x-eckd/s390x-zfcp layouts require a boot device with luks + { + BootDevice{ + Layout: util.StrToPtr("s390x-eckd"), + }, + common.ErrNoLuksBootDevice, + path.New("yaml", "layout"), + }, + // s390x-eckd/s390x-zfcp layouts do not support mirroring + { + BootDevice{ + Layout: util.StrToPtr("s390x-zfcp"), + Luks: BootDeviceLuks{ + Device: util.StrToPtr("/dev/sda"), + Tpm2: util.BoolToPtr(true), + }, + Mirror: BootDeviceMirror{ + Devices: []string{ + "/dev/sda", + "/dev/sdb", + }, + }, + }, + common.ErrMirrorNotSupport, + path.New("yaml", "layout"), + }, + // s390x-eckd devices must start with /dev/dasd + { + BootDevice{ + Layout: util.StrToPtr("s390x-eckd"), + Luks: BootDeviceLuks{ + Device: util.StrToPtr("/dev/sda"), + Tpm2: util.BoolToPtr(true), + }, + }, + common.ErrLuksBootDeviceBadName, + path.New("yaml", "layout"), + }, + // s390x-zfcp devices must start with /dev/sd + { + BootDevice{ + Layout: util.StrToPtr("s390x-eckd"), + Luks: BootDeviceLuks{ + Device: util.StrToPtr("/dev/dasd"), + Tpm2: util.BoolToPtr(true), + }, + }, + common.ErrLuksBootDeviceBadName, + path.New("yaml", "layout"), + }, } for i, test := range tests {