Skip to content

fix: Allow small size differences to match the device min size#526

Merged
vojtechtrefny merged 2 commits intolinux-system-roles:mainfrom
vojtechtrefny:main_resize-idempotency-fix
May 16, 2025
Merged

fix: Allow small size differences to match the device min size#526
vojtechtrefny merged 2 commits intolinux-system-roles:mainfrom
vojtechtrefny:main_resize-idempotency-fix

Conversation

@vojtechtrefny
Copy link
Copy Markdown
Collaborator

@vojtechtrefny vojtechtrefny commented May 7, 2025

Cause: We are currently allowing up to 2 % size difference from requested size when creating or resizing volumes to fit them into pool free space (see #199). This applies the same logic for device minimum size limits when resizing.

Consequence: The sizes do not match when running the role again, causing the role to think something has changed.

Fix: Ensure that a small size difference does not cause the role to think the size has changed.

Result: The role is idempotent.

Resolves: https://issues.redhat.com/browse/RHEL-82825

Summary by Sourcery

Allow minor size variations around device minimum limits when resizing volumes to prevent idempotency issues and mirror existing max size tolerance

Bug Fixes:

  • Prevent the role from detecting false changes by tolerating small discrepancies (up to ~2%) at device minimum size limits

Enhancements:

  • Extend blivet resizing logic to adjust sizes slightly below the device's min_size when within the MAX_TRIM_PERCENT tolerance, mirroring the max_size adjustment

Tests:

  • Add test cases for acceptable size differences (+1.5% and –1.5%) for both LVM and XFS volumes to verify correct resizing behavior and idempotency

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2025

Codecov Report

Attention: Patch coverage is 0% with 16 lines in your changes missing coverage. Please review.

Project coverage is 10.67%. Comparing base (59fd1c6) to head (8efa482).
Report is 58 commits behind head on main.

Files with missing lines Patch % Lines
library/blivet.py 0.00% 16 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (59fd1c6) and HEAD (8efa482). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (59fd1c6) HEAD (8efa482)
sanity 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #526      +/-   ##
==========================================
- Coverage   16.54%   10.67%   -5.88%     
==========================================
  Files           2        8       +6     
  Lines         284     1958    +1674     
  Branches       79        0      -79     
==========================================
+ Hits           47      209     +162     
- Misses        237     1749    +1512     
Flag Coverage Δ
sanity ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

We are currently allowing up to 2 % size difference from requested
size when creating or resizing volumes to fit them into pool free
space (see linux-system-roles#199). This applies the same logic for device minimum
size limits when resizing.

Resolves: RHEL-82825
@vojtechtrefny vojtechtrefny force-pushed the main_resize-idempotency-fix branch from 108d354 to 09bcef6 Compare May 7, 2025 12:32
Comment thread tests/tests_resize.yml
- name: Test xfs
block:
- name: Run test on supported platforms
when: ((is_fedora and blivet_pkg_version is version("3.12.1-3", ">=")) or
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This version is not yet available, keeping the PR as draft for now.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

python-blivet-3.12.1-3 is now available in rawhide and should be available in F42 repos soon.

Comment thread tests/tests_resize.yml Outdated
@vojtechtrefny vojtechtrefny force-pushed the main_resize-idempotency-fix branch from 09bcef6 to 8efa482 Compare May 12, 2025 12:44
@vojtechtrefny vojtechtrefny marked this pull request as ready for review May 12, 2025 12:45
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 12, 2025

Reviewer's Guide

This PR updates the resize implementation to tolerate small deviations from device size limits by snapping targets within a 2% threshold to min_size as well as max_size, and adds new tests for both Ext4 and XFS scenarios to verify idempotency when resizing slightly above max and below min limits.

File-Level Changes

Change Details Files
Enhance blivet resize logic to adjust for small undersize differences
  • Add branch for size < current to compute trim_percent against min_size
  • Adjust target size up to device.min_size when within MAX_TRIM_PERCENT
  • Retain early return if adjusted size equals current
library/blivet.py
Introduce tests for acceptable small over/undersize resizing
  • Define acc_large_size and acc_small_size variables
  • Add Ext4 test block for +1.5% resize tolerance and idempotency
  • Add XFS test block including -1.5% shrink tolerance and cleanup
tests/tests_resize.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@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 @vojtechtrefny - I've reviewed your changes - here's some feedback:

  • The new resize logic for up‐ and down‐sizing in blivet.py is almost identical—consider extracting the common trim_percent calculation and adjustment into a helper to reduce duplication.
  • The resize tests in tests/tests_resize.yml repeat the same blocks for ext4 and XFS—factor out the common steps into a reusable include or loop to DRY up the file and make it easier to maintain.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Review instructions: all looks good
  • 🟢 Testing: 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 and I'll use the feedback to improve your reviews.

@richm
Copy link
Copy Markdown
Contributor

richm commented May 12, 2025

[citest]

@richm
Copy link
Copy Markdown
Contributor

richm commented May 13, 2025

[citest_bad]

@richm
Copy link
Copy Markdown
Contributor

richm commented May 13, 2025

@vojtechtrefny ready to merge?

@vojtechtrefny
Copy link
Copy Markdown
Collaborator Author

@vojtechtrefny ready to merge?

Yes, sorry, I forgot about this. The fixed version of blivet is now available in both rawhide and f42 so this can be merged.

@vojtechtrefny vojtechtrefny merged commit 556dcda into linux-system-roles:main May 16, 2025
41 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants