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
mdraid member status not updated and transition to multi use Disk.role field. Fixes #1214 #1314
mdraid member status not updated and transition to multi use Disk.role field. Fixes #1214 #1314
Conversation
Previously we only alterred the mdraid member flag to a disks role when it's fstype, as reported by scan_disks, indicated the need. However this was done within a conditional that precluded examining a 'None' fstype which is what scan_disks translates an empty string into. Hence we never updated a role db entry for a previous mdraid member once that member no longer returned an fstype. Resolved by moving the role label logic outside the previous conditional such that it now applies to all disks even if they return no fstype from scan_disks.
We need now to prove this works as expected so add additional logging to help.
Previously envisioned as space separated values, update to reflect proposed (by @suman) json format for this field.
Also add beginnings of accounting for roles other than mdraid member. Note this element is incomplete here. N.B. provision is included for dealing with existing legacy db entries so that they may be updated to the new json format for this role field.
Note that as previous db entries may have non json format we account for this as before and test for json format before querying mdraid property existence in role field.
As the role field was previously used only as an mdraid member flag mechanism it would wipe all other roles, this was improved in the case mdriad members having additional roles but all roles would still be lost on non mdraid members. This is the initial patch to address roles retention in non mdraid members.
In order to prove that existing roles are maintained while mdraid role info is added / removed the following testing was carried out. It was necessary to 'hand' modify the db role field to mimic elements of Rockstor that do no yet exist, ie facilities that add or remove role labels. As currently scan_disks() and _update_disk_state() only cater for mdraid member status as the truth of this can be had from each scan_disks() run via the FSTYPE field of lsblk. vda vdb test drives on a kvm.
Setup mdraid mirror of vda and vdb - both drives labelled as mdraid and existing role on one of the now mdraid members was maintained:
and db contents checked via:
Remove the raid member with no other role (stopping the md0 first to allow this)
Then remove the other raid member’s superblock:-
Successfully left in place existing role on vdb.
and then after Rescan of disks:
Mdraid role added to both members with one retaining it’s original example ‘backup-task’ role. Added another drive vdc (virtio with serial=’serial-13’) and gave it a role:
so the db now contains for this serial='serial-13' disk:
Removed the device, rescan, and we have:
Re-attach device, and rescan:
So previous role retained and proves disconnection / reconnection persistence of non system disk role info in db. Test to convert from non json format in role field to json format:-
Apply patch, re-scan (after restart):-
So old plain string role format updated to json format for the same. Rockstor version 3.8-13.09 - applied patch and successfully changed from legacy to json format.
Also confirmed expected function on existing partitioned drives eg with ext4 fs on, ie cog in webUI. Testing on bios raid install, ie rockstor installed on 2x80GB bios raid disks:
Apply patch and afterwards we have:
So successful bios raid plain string to json format in role field. In all cases the WebUI Disks page displayed the expected icons. |
@schakrava patch set ready for review. |
Thanks for explaining test scenarios in detail @phillxnet . Nicely done as always! |
@schakrava Cheers. |
The initial commit in this pr addresses the issue of prior mdraid member's db entries being updated once they are no longer mdraid members. The rest of the pr is concerned with migrating the 'role' Disk field in the db to use the json format and to open it up to alternative purposes than simply as an mdraid member labelling systems.. Previously it was expected to contain either null (db default) or one of the following strings 'isw_raid_member' and 'linux_raid_member'. This pr prepares the role field for future use such as labelling drives for special purposes eg as backup or import devices where a role will be needed to label devices appropriately. So far the mdraid member status is fully maintained as this can be assessed via the current (and unchanged) scan_disks method by way of it's FSTYPE probe but provision has been made to preserve existing role entries, along side those of mdraid, over re-scans and device disconnect / reconnect cycles.
I will specify the testing employed to prove this mechanism in a separate post on this pr.