Skip to content

Config.Validate() produces false positive ErrReuseByLabel warnings for boot_device.mirror disks #710

Description

@dustymabe

Disclaimer: Issue generated by AI with guidance from @dustymabe

Description

When a Butane config uses boot_device.mirror and also specifies storage.disks entries for the same devices (e.g., to override partition sizes or add extra partitions), Config.Validate() warns:

warning at $.storage.disks.0.partitions.0.number: 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

These warnings are false positives. processBootDevice() in translate.go auto-generates wipe_table: true for mirror disks, but Config.Validate() runs before translation, so it doesn't see the auto-generated wipe_table. The user can't reasonably suppress this – adding explicit wipe_table: true is redundant, and adding explicit partition number fields would break the label-based merge with the auto-generated mirror partitions.

Reproducer

variant: fcos
version: 1.7.0
boot_device:
  layout: x86_64
  luks:
    tpm2: true
  mirror:
    devices:
      - /dev/sda
      - /dev/sdb
storage:
  disks:
    - device: /dev/sda
      partitions:
        - label: root-1
          size_mib: 10240
        - label: var-1
    - device: /dev/sdb
      partitions:
        - label: root-2
          size_mib: 10240
        - label: var-2
  raid:
    - name: md-var
      level: raid1
      devices:
        - /dev/disk/by-partlabel/var-1
        - /dev/disk/by-partlabel/var-2
  luks:
    - name: var
      device: /dev/md/md-var
  filesystems:
    - device: /dev/mapper/var
      path: /var
      label: var
      format: xfs
      wipe_filesystem: true
      with_mount_unit: true

This is the "Encrypted mirrored boot disk with separate /var" example from the FCOS storage docs (with layout: x86_64 added for the separate v1.7 requirement).

Proposed fix

In Config.Validate() (affects v1_6, v1_7, v1_8_exp), skip the ErrReuseByLabel check for disks that are listed in boot_device.mirror.devices, since processBootDevice() will set wipe_table: true for them:

func (conf Config) Validate(c path.ContextPath) (r report.Report) {
	mirrorDevices := make(map[string]bool)
	for _, dev := range conf.BootDevice.Mirror.Devices {
		mirrorDevices[dev] = true
	}

	for i, disk := range conf.Storage.Disks {
		if disk.Device != rootDevice && !util.IsTrue(disk.WipeTable) && !mirrorDevices[disk.Device] {
			for p, partition := range disk.Partitions {
				if partition.Number == 0 && partition.Label != nil {
					r.AddOnWarn(c.Append("storage", "disks", i, "partitions", p, "number"), common.ErrReuseByLabel)
				}
			}
		}
	}
	// ...

Context

Reported via coreos/fedora-coreos-docs#808

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions