mdadm should use -x or --spare-devices when spare-devices is set non-zero
Description of Issue/Question
The mdadm module attempts to honor a spare-devices setting by decrementing the number of raid_devices passed to mdadm. Unfortunately, it does not actually pass anything with the -x or --spare-devices parameter, and mdadm will happily add the extra devices passed on the command line into the array. This is probably also a bug in the mdadm utility as well, but fixing that would just make it break rather than silently build an array without spares, so it also needs to be fixed in salt.
https://github.com/saltstack/salt/blob/3b81c37a531c48ff54a2332c4ea9c0d108ce0e74/salt/modules/mdadm.py#L238
This is probably trivial to fix by unconditionally adding -x to the command parameters a few lines below, and setting its argument to the value of spare-devices, or zero if unset.
Setup
Still working on a suitably generic setup.
Steps to Reproduce Issue
- Configure a raid array with spare-devices set to something non-zero
- Run the state
- Watch it build an array using all the disks you supplied, with none of them set aside as spares.
Versions Report
Master: salt 2016.11.1 (Carbon) Minion: salt-call 2016.3.5 (Boron)
The code to handle the -x or --spare-devices parameter is missing from the latest version in git, so I do not expect upgrading to fix anything.
Hrm, having difficulty reproducing. The implicit kwargs handling of spare-devices seems to be doing the right thing when I run it manually. Still trying to figure out why it doesn't do that when running the disks state on boot.
Sorry for the noise. This was caused by an intermediate state not passing through arbitrary arguments to the module, and I didn't understand that the code was relying on kwargs to set the command line flag. Might be good to add a comment there to save someone else from my confusion.
If you wouldn't mind writing up the docs, we would love a PR with this information.
Thanks! Daniel
I'm still trying to figure out the right way to do it. One of the problems is that --spare-devices is allowed in create mode, but not assemble mode. The same is also true of --chunk. We may need some special handling for parameters that are okay to pass through to create but not assemble.
Check out how the lvm module handles this stuff, could be useful to model after On Tue, Apr 4, 2017 at 5:08 PM Chris Snook [email protected] wrote:
I'm still trying to figure out the right way to do it. One of the problems is that --spare-devices is allowed in create mode, but not assemble mode. The same is also true of --chunk. We may need some special handling for parameters that are okay to pass through to create but not assemble.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/saltstack/salt/issues/40402#issuecomment-291646706, or mute the thread https://github.com/notifications/unsubscribe-auth/AAssoRWBJXsWInNIkK9_YG_JtEGOCxrIks5rsr9kgaJpZM4Mtbtr .