Skip to content

Commit

Permalink
Added the
Browse files Browse the repository at this point in the history
                    - fcos/validate.go s390x device identification with regex along with mirror check.
                    - docs/config-openshift-v4_14-exp.md:  updated the docs.
                    - fcos/schema.go: renamed luks.device to luks.s390x-device.
                    - fcos/translate.go: updated only one wantS390x condition to identify for device identification.
                    - common/error.go: fixed the space issue it error.go.
  • Loading branch information
madhu-pillai committed Aug 28, 2023
1 parent e055b2a commit 0bc6fdd
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions config/common/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ var (
// boot device
ErrUnknownBootDeviceLayout = errors.New("layout must be one of: aarch64, ppc64le, x86_64")
ErrTooFewMirrorDevices = errors.New("mirroring requires at least two devices")
ErrNoLuksBootDevice = errors.New("device-s390x is required if layout: s390x-eckd && device-s390x: /dev/dasd[a-z] or s390x-zfcp && device: /dev/sd[a-z]")
ErrMirrorNotSupport = errors.New("layout: s390x-zfcp or s390x-eckd does not support mirror")
ErrNoLuksBootDevice = errors.New("s390x-device is required if layout: s390x-eckd && s390x-device: /dev/dasd[a-z] or s390x-zfcp && s390x-device: /dev/sd[a-z]")
ErrMirrorNotSupport = errors.New("layout: s390x-zfcp or s390x-eckd does not support mirror")

// partition
ErrReuseByLabel = errors.New("partitions cannot be reused by label; number must be specified except on boot disk (/dev/disk/by-id/coreos-boot-disk) or when wipe_table is true")
Expand Down
2 changes: 1 addition & 1 deletion config/fcos/v1_6_exp/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type BootDevice struct {

type BootDeviceLuks struct {
Discard *bool `yaml:"discard"`
Device *string `yaml:"device-s390x"`
Device *string `yaml:"s390x-device"`
Tang []base.Tang `yaml:"tang"`
Threshold *int `yaml:"threshold"`
Tpm2 *bool `yaml:"tpm2"`
Expand Down
17 changes: 6 additions & 11 deletions config/fcos/v1_6_exp/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ func (c Config) processBootDevice(config *types.Config, ts *translate.Translatio
var wantBIOSPart bool
var wantEFIPart bool
var wantPRePPart bool
var wantMBR bool
var wantDasd bool
var wantS390x bool
layout := c.BootDevice.Layout
switch {
case layout == nil || *layout == "x86_64":
Expand All @@ -136,12 +135,12 @@ func (c Config) processBootDevice(config *types.Config, ts *translate.Translatio
case *layout == "ppc64le":
wantPRePPart = true
case *layout == "s390x-eckd":
wantDasd = true
wantS390x = true
case *layout == "s390x-zfcp":
wantS390x = true
case *layout == "s390x-virt":
wantBIOSPart = true
wantEFIPart = true
case *layout == "s390x-zfcp":
wantMBR = true
default:
// should have failed validation
panic("unknown layout")
Expand Down Expand Up @@ -251,12 +250,8 @@ func (c Config) processBootDevice(config *types.Config, ts *translate.Translatio
var luksDevice string
var device_s390x string
switch {
case wantMBR:
//Luks Device for zFCP-scsi
device_s390x = *c.BootDevice.Luks.Device
luksDevice = device_s390x + "2"
case wantDasd:
//Luks Device for Dasd
case wantS390x:
//Luks Device for dasd and zFCP-scsi
device_s390x = *c.BootDevice.Luks.Device
luksDevice = device_s390x + "2"
case wantMirror:
Expand Down
27 changes: 16 additions & 11 deletions config/fcos/v1_6_exp/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import (
const rootDevice = "/dev/disk/by-id/coreos-boot-disk"

var allowedMountpoints = regexp.MustCompile(`^/(etc|var)(/|$)`)
var s390xLayout []string
var dasdRe = regexp.MustCompile("(/dev/dasd[a-z]$)")
var sdRe = regexp.MustCompile("(/dev/sd[a-z]$)")

// We can't define a Validate function directly on Disk because that's defined in base,
// so we use a Validate function on the top-level Config instead.
Expand Down Expand Up @@ -57,17 +58,21 @@ func (d BootDevice) Validate(c path.ContextPath) (r report.Report) {
r.AddOnError(c.Append("layout"), common.ErrUnknownBootDeviceLayout)
}
}
//Validate s390x layout device specific luks.device-s390x.
//Validate s390x layout device specific luks.s390x-device.
//s390x layout does not support Mirror.
if d.Layout != nil {
s390xLayout = []string{"s390x-zfcp", "s390x-eckd"}
for _, zlayout := range s390xLayout {
switch {
case *d.Layout == zlayout && util.NilOrEmpty(d.Luks.Device):
r.AddOnError(c.Append(zlayout), common.ErrNoLuksBootDevice)
case *d.Layout == zlayout && len(d.Mirror.Devices) > 0:
r.AddOnError(c.Append(zlayout), common.ErrMirrorNotSupport)
}
//Validate the s390x layout specific device
if d.Layout != nil && (*d.Layout == "s390x-zfcp" || *d.Layout == "s390x-eckd") {
if util.NilOrEmpty(d.Luks.Device) {
r.AddOnError(c.Append(*d.Layout), common.ErrNoLuksBootDevice)
}
if len(d.Mirror.Devices) > 0 {
r.AddOnError(c.Append(*d.Layout), common.ErrMirrorNotSupport)
}
if *d.Layout == "s390x-zfcp" && util.NotEmpty(d.Luks.Device) && !sdRe.MatchString(*d.Luks.Device) {
r.AddOnError(c.Append(*d.Layout), common.ErrNoLuksBootDevice)
}
if *d.Layout == "s390x-eckd" && util.NotEmpty(d.Luks.Device) && !dasdRe.MatchString(*d.Luks.Device) {
r.AddOnError(c.Append(*d.Layout), common.ErrNoLuksBootDevice)
}
}
r.Merge(d.Mirror.Validate(c.Append("mirror")))
Expand Down
2 changes: 1 addition & 1 deletion docs/config-fcos-v1_6-exp.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ The Fedora CoreOS configuration is a YAML document conforming to the following s
* **_boot_device_** (object): describes the desired boot device configuration. At least one of `luks` or `mirror` must be specified.
* **_layout_** (string): the disk layout of the target OS image. Supported values are `aarch64`, `ppc64le`, `s390x-eckd`, `s390x-virt`, `s390x-zfcp` and `x86_64`. Defaults to `x86_64`.
* **_luks_** (object): describes the clevis configuration for encrypting the root filesystem.
* **device-s390x** (string): describes device specific to s390x `dasd[a-z]` or `sd[a-z]`.
* **s390x-device** (string): describes device specific to s390x `dasd[a-z]` or `sd[a-z]`.
* **_tang_** (list of objects): describes a tang server. Every server must have a unique `url`.
* **url** (string): url of the tang server.
* **thumbprint** (string): thumbprint of a trusted signing key.
Expand Down
2 changes: 1 addition & 1 deletion docs/config-openshift-v4_14-exp.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ The OpenShift configuration is a YAML document conforming to the following speci
* **_boot_device_** (object): describes the desired boot device configuration. At least one of `luks` or `mirror` must be specified.
* **_layout_** (string): the disk layout of the target OS image. Supported values are `aarch64`, `ppc64le`, `s390x-eckd`, `s390x-virt`, `s390x-zfcp` and `x86_64`. Defaults to `x86_64`.
* **_luks_** (object): describes the clevis configuration for encrypting the root filesystem.
* **device-s390x** (string): describes device specific to s390x `dasd[a-z]` or `sd[a-z]`.
* **s390x-device** (string): describes device specific to s390x `dasd[a-z]` or `sd[a-z]`.
* **_tang_** (list of objects): describes a tang server. Every server must have a unique `url`.
* **url** (string): url of the tang server.
* **thumbprint** (string): thumbprint of a trusted signing key.
Expand Down
4 changes: 2 additions & 2 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ version: 1.6.0
boot_device:
layout: s390x-eckd
luks:
device-s390x: /dev/dasda
s390x-device: /dev/dasda
tang:
- url: https://tang.example.com
thumbprint: REPLACE-THIS-WITH-YOUR-TANG-THUMBPRINT
Expand All @@ -320,7 +320,7 @@ version: 1.6.0
boot_device:
layout: s390x-zfcp
luks:
device-s390x: /dev/sdb
s390x-device: /dev/sdb
tang:
- url: https://tang.example.com
thumbprint: REPLACE-THIS-WITH-YOUR-TANG-THUMBPRINT
Expand Down

0 comments on commit 0bc6fdd

Please sign in to comment.