Page MenuHomeVyOS Platform

op-mode: add raid member fails with a misleading PermissionError right after "format disk ... like ..."
Closed, ResolvedPublicBUG

Description

Summary

The RAID1 smoketest (make testraid) replaces the first disk with an empty one, re-partitions it with format by-id disk drive-hd1 like drive-hd2 and then immediately runs add raid md0 by-id member drive-hd1-part3. The add step fails:

PermissionError: [Errno 1] failed to run command: mdadm --add /dev/md0 /dev/sda3
returned:
exit code: 1

Analysis

  • This is not a permissions problem. Op-mode commands already run as root. cmdl() raises OSError(exit_code, ...), and Python turns errno 1 into PermissionError. All we know is that mdadm exited with 1.
  • mdadm's actual error message is lost. cmdl() captures stderr separately and leaves it out of the exception text, so returned: is empty. The message is only in the journal.
  • Likely cause (not confirmed yet): format disk returns as soon as sfdisk exits, while udev is still processing the new partition table. add raid runs right after it and can hand mdadm a partition that isn't ready yet. Other possibilities: md0 is not running degraded, or the partition is too small.
  • The CLI shows a Python traceback instead of an error message.
  • The harness doesn't notice the failure. It moves on and polls /proc/mdstat for up to 15 minutes waiting for a resync that never starts, close to the 20-minute CI job limit.

Proposed fix

vyos-1x
  • Wait for udev (udevadm settle) after format disk writes the partition table, and again before add raid uses the member partition.
  • Include mdadm / grub-install stderr in the error message.
  • Report failures from add raid / delete raid as op-mode errors instead of tracebacks.
vyos-build
  • Wait for the confirmation prompt before answering yes.
  • Detect an error after format and add raid, collect diagnostics (/proc/mdstat, lsblk, mdadm --detail, mdadm journal lines) and fail straight away instead of waiting for the resync timeout.

How to reproduce

  • make testraid (timing-dependent, not every run)
  • Error output, every time: add raid md0 member <partition that is too small>, or add raid on a partition another process holds open with O_EXCL. Either way the CLI shows a traceback with an empty returned:.

Details

Version
rolling, 1.5.1
Is it a breaking change?
Perfectly compatible
Issue type
Bug (incorrect behavior)

Event Timeline

c-po changed the task status from Open to In progress.
c-po claimed this task.
c-po triaged this task as Normal priority.
c-po changed Is it a breaking change? from Unspecified (possibly destroys the router) to Perfectly compatible.