-
Notifications
You must be signed in to change notification settings - Fork 61
fix: Show better error when trying to create RAID without enough disks #545
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
fix: Show better error when trying to create RAID without enough disks #545
Conversation
Reviewer's GuideAdds explicit validation and clearer error messages when creating RAID arrays by checking for invalid RAID levels and insufficient disks, refactors new_mdarray to utilize these checks, removes legacy device count processing, and introduces tests for these failure cases. Sequence diagram for RAID array creation with improved error handlingsequenceDiagram
participant User
participant BlivetAnsible
participant BlivetLibs
participant RaidLib
User->>BlivetAnsible: Request to create RAID array
BlivetAnsible->>BlivetLibs: _new_mdarray(members, raid_name)
BlivetLibs->>RaidLib: get_raid_level(raid_level)
alt Invalid RAID level
RaidLib-->>BlivetLibs: Raise RaidError
BlivetLibs-->>BlivetAnsible: Raise BlivetAnsibleError (invalid RAID level)
BlivetAnsible-->>User: Error: not a valid RAID level
else Valid RAID level
RaidLib-->>BlivetLibs: blivet_level
BlivetLibs->>BlivetLibs: Check len(members) < blivet_level.min_members
alt Not enough disks
BlivetLibs-->>BlivetAnsible: Raise BlivetAnsibleError (not enough disks)
BlivetAnsible-->>User: Error: not enough disks selected
else Enough disks
BlivetLibs->>BlivetLibs: Proceed with RAID creation
BlivetLibs-->>BlivetAnsible: RAID array created
BlivetAnsible-->>User: RAID array created successfully
end
end
Class diagram for updated RAID error handling and validationclassDiagram
class BlivetAnsibleError
class RaidError
class BlivetLibs {
+_new_mdarray(members, raid_name="")
}
class devicelibs.raid {
+get_raid_level(raid_level)
}
class blivet_level {
+min_members
}
BlivetLibs --> devicelibs.raid : uses
devicelibs.raid --> RaidError : raises
BlivetLibs --> BlivetAnsibleError : raises
devicelibs.raid --> blivet_level : returns
BlivetLibs ..> blivet_level : checks min_members
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @vojtechtrefny - I've reviewed your changes and they look great!
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #545 +/- ##
==========================================
- Coverage 16.54% 10.66% -5.89%
==========================================
Files 2 8 +6
Lines 284 1960 +1676
Branches 79 0 -79
==========================================
+ Hits 47 209 +162
- Misses 237 1751 +1514
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9b93b33 to
51adc52
Compare
|
@vojtechtrefny you'll also need to change the error message in tests_fatals_raid_volume.yml: |
Resolves: RHEL-95757
The check was previously moved to '_new_mdarray'
51adc52 to
44f8e2d
Compare
Thank you, fixed. |
|
[citest] |
1 similar comment
|
[citest] |
|
[citest] |
Summary by Sourcery
Validate RAID parameters before array creation, improve error messages and remove obsolete logic
Bug Fixes:
Enhancements:
Tests: