Skip to content
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

Improve error handling for ZFS pool creation in workspace function #202

Merged
merged 1 commit into from
Sep 9, 2024

Conversation

vimanuelt
Copy link
Contributor

@vimanuelt vimanuelt commented Sep 9, 2024

Commit summary:

  • Enhanced error handling for zpool create in the workspace() function.

  • Replaced indirect exit code check with a direct check using if !.

  • Added detailed error messages to make debugging easier when pool creation fails.

  • Implemented cleanup steps to remove any partially created resources (e.g., ZFS pool, memory disk, pool image) on failure.

  • Ensured that the system remains in a clean state when an error occurs.

  • Improved readability and robustness of the workspace() function by refactoring redundant checks.

Summary by Sourcery

Enhance error handling and robustness in the workspace() function by directly checking the zpool create command's success, adding detailed error messages, and implementing cleanup steps to ensure the system remains in a clean state on failure.

Enhancements:

  • Improve error handling in the workspace() function by directly checking the success of the zpool create command.
  • Add detailed error messages to aid in debugging when ZFS pool creation fails.
  • Implement cleanup steps to remove partially created resources such as ZFS pool, memory disk, and pool image on failure.
  • Refactor the workspace() function to enhance readability and robustness by removing redundant checks.

Commit summary:

- Enhanced error handling for zpool create in the workspace() function.

- Replaced indirect exit code check with a direct check using if !.
    
- Added detailed error messages to make debugging easier when pool creation fails.
    
- Implemented cleanup steps to remove any partially created resources (e.g., ZFS pool, memory disk, pool image) on failure.
    
- Ensured that the system remains in a clean state when an error occurs.
    
- Improved readability and robustness of the workspace() function by refactoring redundant checks.
@vimanuelt vimanuelt requested review from a team as code owners September 9, 2024 22:31
Copy link
Contributor

sourcery-ai bot commented Sep 9, 2024

Reviewer's Guide by Sourcery

This pull request improves error handling and resource management in the workspace() function of the build.sh script. The changes focus on enhancing the ZFS pool creation process, providing more detailed error messages, and implementing a robust cleanup mechanism in case of failures.

File-Level Changes

Change Details Files
Enhanced error handling for ZFS pool creation
  • Replaced indirect exit code check with a direct check using 'if !'
  • Added detailed error message when pool creation fails
  • Implemented cleanup steps to remove partially created resources on failure
  • Added comments to explain each step of the process
build.sh
Improved resource management and cleanup
  • Added cleanup steps at the beginning of the function to ensure a clean state
  • Implemented removal of old build directory if it exists
  • Added step to detach memory device if previously attached
  • Included removal of old pool image if it exists
build.sh
Refactored workspace() function for better readability and robustness
  • Grouped related operations together with comments
  • Improved error handling for zpool destroy and mdconfig commands
  • Added error suppression for cleanup operations to prevent unnecessary error messages
build.sh

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @vimanuelt - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

build.sh Show resolved Hide resolved
Copy link
Member

@ericbsd ericbsd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ericbsd ericbsd merged commit c674c73 into ghostbsd:master Sep 9, 2024
2 checks passed
@ericbsd ericbsd assigned ericbsd and vimanuelt and unassigned ericbsd Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants