salt icon indicating copy to clipboard operation
salt copied to clipboard

[feature] mdadm module should filter assume-clean from kwargs when invoking mdadm in assemble mode

Open csnook opened this issue 8 years ago • 4 comments

Description of Issue/Question

There are several circumstances in which it is desirable to pass the --assume-clean option to mdadm when building RAID 1 and RAID 10 arrays. (It is meaningless for RAID 0, and extremely dangerous for parity RAID.) Unfortunately, this option is meaningless when assembling an existing array, and mdadm made a design decision a long time ago to error out when passed arguments that don't make sense for the chosen mode. That means that specifying assume-clean: true in your mdadm.present spec will work the first time when creating the array, but fail to assemble a detected array on subsequent boots.

To be precise, --assume-clean is valid in build, create, and grow modes.

There may also be other options that might make sense to filter in certain modes.

Setup

This is only a problem if you have no persistent mdadm.conf, common in immutable infrastructure setups.

The only configuration needed is to add - assume-clean: true to a raid.present definition:

/dev/md/stuff:
  raid.present:
    - level: 1
    - devices:
      - /dev/sda
      - /dev/sdb
    - assume-clean: true
    - run: true

This will be passed to mdadm as --assume-clean, regardless of the mode that mdadm is invoked in.

Steps to Reproduce Issue

  1. Set up a machine with at least 2 devices that are blank or have had headers wiped with wipefs
  2. Create a raid array with the raid.present state and assume-clean: true
  3. Reboot and watch mdadm complain that --assume-clean is not valid in assemble mode.

Versions Report

No filtering for assume-clean in latest development version or any I've looked at.

csnook avatar May 24 '18 23:05 csnook

Would you mind submitting a PR to implement this?

We rely a lot on the community to lend their expertise for stuff like this.

Here is our contributing guide https://docs.saltstack.com/en/latest/topics/development/contributing.html

Thanks! Daniel

gtmanfred avatar May 25 '18 03:05 gtmanfred

I'd be happy to implement this, but before I do, I'd like to know if you would prefer I implement only a filter for this parameter, which I can easily test, or if you'd rather I implement it for all mode-specific parameters for mdadm, which I can't easily test. The list of parameters that are accepted in each mode is well-documented:

https://linux.die.net/man/8/mdadm

It's probably not much more work to implement mode filtering for all of them than to implement mode filtering for this one parameter, but testing all combinations of mode-specific options will be prohibitively cumbersome.

Since raid.present currently implements no mode filtering, any configuration that would be broken by a bug in the filtering would probably already be broken under some circumstances.

csnook avatar Jun 08 '18 00:06 csnook

I would say implement all of them, and tests the ones that are easy to test.

gtmanfred avatar Jun 08 '18 13:06 gtmanfred

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] avatar Sep 21 '19 14:09 stale[bot]