Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fcos: add s390x boot_device sugar #484

Merged
merged 1 commit into from
Nov 2, 2023
Merged

Conversation

madhu-pillai
Copy link
Contributor

Hi,

I've closed the earlier pr 483 due to some errors. Here is the new PR.

As per the GitHub issue [https://github.com//issues/453#issuecomment-1655441505]. The PR contains following conditional changes exclusively for s390x.

  1. Added layout specific to s390x .
  • s390x-zfcp s390x-eckd and s390x-virt .

  1. Added boot_device.luks.device specifically for s390x-zfcp s390x-eckd and forbidden for other arch including s390x-virt.

  2. The configuration will generate only with boot_device.luks and it fails if mirror boot_device.mirror configuration is specified for s390x-eckd and s390x-zfcp .

Copy link
Collaborator

@prestist prestist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a high level code review, I will come back for a more in-depth one once I understand the issue better.

We prob want to change the commit message to be something like

"fcos: add s390x boot_device sugar"

Additionally in the future if working on an issue its customary to address issues raised in the PR rather then closing and re-making them. It makes it more easy to review and know what is changed.

edit: structurally regarding the issue this is attempting to solve I am a bit confused, trying to formulate questions as I go.

config/common/errors.go Outdated Show resolved Hide resolved
@@ -133,6 +135,13 @@ func (c Config) processBootDevice(config *types.Config, ts *translate.Translatio
wantEFIPart = true
case *layout == "ppc64le":
wantPRePPart = true
case *layout == "s390x-eckd":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since s390x-zfcp is the same as s390x-eckd, we could have both cases fall into the same logic
IE

case x:
case y:
       dowork = true

Copy link
Contributor Author

@madhu-pillai madhu-pillai Aug 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes logically it does not do anything with two different layout with one input.
But the plan was user to force use /dev/dasd[a-z] for eckd and /dev/sd[a-z] so that during the layout preference it set appropriate root device; let say for dasd /dev/dasda2. But , I was not able to achieve that under translate.go. I tried with regexp. Somehow it was crashing with memory error. I thought once created the PR will add the device arch once it is discuss within PR.. That's why made it open.

1,  imported regexp.
2. then did `diskRe = regexp.MustCompile("(/dev/dasd[a-z]$|/dev/sd[a-z]$)")
3. diskRe.FindString(*c.BootDevice.Luks.Device)
 while validating with appropriate layouts getting panic on memory error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the following conditions?

In translate.go will have one logic as you corrected


case s390x-zfcp:
case s390x-eckd:
         wantS390X = true


below condition in validate.go to fix , so that user force to use either dasd[a-z] or sd[a-z]. If not then it give an error.

var dasdRe = regexp.MustCompile("(/dev/dasd[a-z]$)")
var sdRe = regexp.MustCompile("(/dev/sd[a-z]$)")

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)
		}
	}

var luksDevice string
var device_s390x string
switch {
case wantMBR:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what is the difference between the work done in the wantMBR case and the wantDasd case? to my eye they are doing the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've explained above...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we provide only one condition common to both layouts under switch statement.

var device_S390x string
switch {
case wantS390x:
         device_s390x = *c.BootDevice.Luks.Device
         luksDevice = device_s390x + "2"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For more readability I made the changes as follows.

	case *layout == "s390x-eckd":
		wantS390x = true
	case *layout == "s390x-zfcp":
		wantS390x = true
// encrypted root partition
	if wantLuks {
		var luksDevice string
		var device_s390x string
		switch {
		case wantS390x:
			//Luks Device for dasd and zFCP-scsi
			device_s390x = *c.BootDevice.Luks.Device
			luksDevice = device_s390x + "2"

config/fcos/v1_6_exp/validate.go Outdated Show resolved Hide resolved
docs/config-fcos-v1_6-exp.md Outdated Show resolved Hide resolved
@@ -32,6 +32,7 @@ type BootDevice struct {

type BootDeviceLuks struct {
Discard *bool `yaml:"discard"`
Device *string `yaml:"device-s390x"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we adding a new field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if am wrong.
I added the Device for s390x disk as new field. So that when user generate ignition from butane config they must provide s390x device like /dev/dasda or /dev/sda. Else it use the label which we do not expect for s390x.

@madhu-pillai madhu-pillai changed the title Added s390 layout feature fcos: add s390x boot_device sugar Aug 15, 2023
@madhu-pillai
Copy link
Contributor Author

Hi @prestist , Can you please review the comments?

config/fcos/v1_6_exp/validate.go Outdated Show resolved Hide resolved
config/fcos/v1_6_exp/validate.go Outdated Show resolved Hide resolved
config/fcos/v1_6_exp/validate.go Outdated Show resolved Hide resolved
@madhu-pillai
Copy link
Contributor Author

Hi Team,

Would you please check if the patch can be approved? or further review required?

Thanks
Madhu

@cgwalters
Copy link
Member

I'm not really a maintainer here and I don't know the code involved, but in case it's useful I can say this looks superficially sane to me at least!

@cgwalters
Copy link
Member

I'd recommend squashing your changes into one commit (and avoid merge commits back from main) etc.

@travier
Copy link
Member

travier commented Sep 22, 2023

This will need a full rebase on top of #491 once it lands.

@madhu-pillai
Copy link
Contributor Author

Hi,
Changes have been done as suggested. Kindly review.

@nikita-dubrovskii
Copy link
Contributor

@madhu-pillai sorry, by mistake instead of suggestion i've committed a change on top of yours. One question: FCP disks have /dev/sda3 as BOOT and /dev/sda4 as ROOT , so using 2 for partition is only valid for ECKD disks, isn't it?

@@ -32,6 +32,7 @@ type BootDevice struct {

type BootDeviceLuks struct {
Discard *bool `yaml:"discard"`
Device *string `yaml:"s390x-device"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Device *string `yaml:"s390x-device"`
Device *string `yaml:"blockdev"`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is prefix s390x- help in identifying what layout the user trying to use and avoid confusion on device parameter from other arch?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion is to keep this as device and document that it's only valid on the s390x-eckd and s390x-zfcp layouts. Having the s390x- prefix makes it feel less integrated than other arches.

* **_luks_** (object): describes the clevis configuration for encrypting the root filesystem.
* **s390x-device** (string): describes device specific to s390x `dasd[a-z]` or `sd[a-z]`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* **s390x-device** (string): describes device specific to s390x `dasd[a-z]` or `sd[a-z]`.
* **s390x-device** (string): underlying block device`dasd[a-z]` or `sd[a-z]`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially i was using device naming device however steven perstist reviewed and suggest to prefix s390x -device.

@madhu-pillai
Copy link
Contributor Author

@madhu-pillai sorry, by mistake instead of suggestion i've committed a change on top of yours. One question: FCP disks have /dev/sda3 as BOOT and /dev/sda4 as ROOT , so using 2 for partition is only valid for ECKD disks, isn't it?

That is right... 2 is only valid for dasd disk

@madhu-pillai
Copy link
Contributor Author

Accidently click on close PR. Kindly ignore..

@nikita-dubrovskii
Copy link
Contributor

Almost LGTM.
@prestist what's about renaming s390x-device to blockdevice or blockdev? There is only DASD which is s390x specific

@madhu-pillai
Copy link
Contributor Author

Have fixed the doc and translate and validate version check.

@madhu-pillai
Copy link
Contributor Author

Hi, Could you help me how to run the test similar to the CI?
As I am getting different test logs when i run from Mac and fedora?

I just running ./test from the butane directory.

@madhu-pillai
Copy link
Contributor Author

Looks like the version of the fcos and OpenShift causing the failure. Now I have fixed and run the unit test worked Ok.

@nikita-dubrovskii
Copy link
Contributor

/cc @prestist

@prestist
Copy link
Collaborator

Sorry for the delay; I plan on taking a look at this today.

Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall approach LGTM. Mostly minor things and one concern re. BIOS/EFI.

@@ -32,6 +32,7 @@ type BootDevice struct {

type BootDeviceLuks struct {
Discard *bool `yaml:"discard"`
Device *string `yaml:"s390x-device"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion is to keep this as device and document that it's only valid on the s390x-eckd and s390x-zfcp layouts. Having the s390x- prefix makes it feel less integrated than other arches.

Comment on lines 136 to 138
case *layout == "s390x-virt":
wantBIOSPart = true
wantEFIPart = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right; we don't have BIOS or EFI partitions on s390x. Why is this there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I think I added this because Benjamin suggested that KVM Virt does not need /dev/vda as /dev/disk/by-partlabel similar to x86. I'll correct by removing this case statement and append following case statement.

case *layout == "s390x-eckd" || *layout == "s390x-zfcp" || *layout == "s390x-virt"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially I used device but Steve suggested something specific to s390x that's why I added s390x-device. I'll correct that to device.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll correct by removing this case statement and append following case statement.

Yes, that makes sense to me.

Initially I used device but Steve suggested something specific to s390x that's why I added s390x-device. I'll correct that to device.

Yeah, I think it's debatable either way but I would lean towards device. Having to repeat "s390x" in both the layout name and this field's name is a bit awkward.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah; 100% thinking about it again and having talked to @jlebon I agree device is certainly better.

config/common/errors.go Outdated Show resolved Hide resolved
docs/examples.md Outdated Show resolved Hide resolved
docs/examples.md Outdated Show resolved Hide resolved
### Mirrored boot disk

This example uses the shortcut `boot_device` syntax to configure an encrypted root filesystem in s390x KVM unlocked with a network Tang server.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this example down to be the last of this subsection and keep the more common scenarios as first?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, That is right. I'll move that to the last subsection.

docs/release-notes.md Outdated Show resolved Hide resolved
@@ -63,6 +64,7 @@ key](https://getfedora.org/security/).
- Document `key_file` `compression` field _(openshift 4.8.0 - 4.9.0)_
- Document support for special mode bits and `arn` URLs _(r4e 1.1.0+)_
- Improve rendering of spec docs on docs site
- Document `luks.s390x-device` spec _(fcos, openshift 4.14.0+)_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we need this given that it's a new feature. I think this section is more for doc changes for pre-existing features.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I shall remove this.

- name: s390x-device
transforms:
- regex: $
replacement: the whole-disk device (not partitions), referenced by their absolute path. One device must be specified with s390x-* layout except s390x-virt.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mention the expected prefixes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean change to - name: device ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean mention that on s390x-eckd, it should start with /dev/dasd and similarly for the other layout.

But yes, the field name itself will also need to be updated when we rename it.

Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments, but LGTM overall!

Were you able to do a final test on this with all three layouts?

internal/doc/butane.yaml Outdated Show resolved Hide resolved
internal/doc/butane.yaml Show resolved Hide resolved
Copy link
Collaborator

@prestist prestist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @madhu-pillai and @nikita-dubrovskii LGTM; I am deferring my approval to @jlebon's

I have two small nits;

No big deal but would be nice to fix.

Thank you again for all your work.

Comment on lines 136 to 138
case *layout == "s390x-virt":
wantBIOSPart = true
wantEFIPart = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah; 100% thinking about it again and having talked to @jlebon I agree device is certainly better.

docs/release-notes.md Outdated Show resolved Hide resolved
docs/release-notes.md Outdated Show resolved Hide resolved
Co-authored-by: Nikita Dubrovski <[email protected]>
Co-authored-by: Jonathan Lebon <[email protected]>
Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just did a small tweak to the transform regex bits.
Nice work! Thanks for working through all the comments.

@jlebon jlebon enabled auto-merge November 2, 2023 16:03
@jlebon jlebon merged commit 3c0589f into coreos:main Nov 2, 2023
8 checks passed
travier added a commit to travier/butane that referenced this pull request Feb 20, 2024
travier added a commit to travier/butane that referenced this pull request Feb 20, 2024
yasminvalim pushed a commit to yasminvalim/butane that referenced this pull request Mar 15, 2024
travier added a commit to madhu-pillai/butane that referenced this pull request Nov 21, 2024
- Use "layout" in the context path for errors related to the layout
  entry in the boot_device  configuration.
- Add tests for those error cases.
- Refactor mirror boot_device check for s390x.

Fixes: coreos#484
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants