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

gadget: add a Size method to Volume #14561

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

upils
Copy link
Contributor

@upils upils commented Sep 30, 2024

This method is needed to determine the size of the disk image to create in ubuntu-image.

Copy link

codecov bot commented Sep 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.87%. Comparing base (ac897ee) to head (78a5b21).
Report is 43 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #14561      +/-   ##
==========================================
+ Coverage   78.85%   78.87%   +0.01%     
==========================================
  Files        1079     1082       +3     
  Lines      145615   145969     +354     
==========================================
+ Hits       114828   115127     +299     
- Misses      23601    23643      +42     
- Partials     7186     7199      +13     
Flag Coverage Δ
unittests 78.87% <100.00%> (+0.01%) ⬆️

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.

@alfonsosanchezbeato alfonsosanchezbeato changed the title gadget: Add a MaxSize method to Volume gadget: add a MaxSize method to Volume Sep 30, 2024
Copy link
Member

@alfonsosanchezbeato alfonsosanchezbeato left a comment

Choose a reason for hiding this comment

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

Thanks for this! Couple of minor comments.

gadget/gadget.go Outdated Show resolved Hide resolved
gadget/gadget_test.go Outdated Show resolved Hide resolved
@upils upils force-pushed the add-volume-max-size branch 2 times, most recently from 827356c to 78a5b21 Compare October 1, 2024 06:15
Copy link
Member

@alfonsosanchezbeato alfonsosanchezbeato left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the changes

gadget/gadget.go Outdated
}

// MaxSize returns the maximum size required by a volume.
func (v *Volume) MaxSize() quantity.Size {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about simply Size(), or DefaultSize() (to highlight that the volume can be expanded at install time)?

It's an odd choice for u-i to be using MinSize() really. AFAIU MinSize is there only for compatibility check during remodel/update.

Made a similar remark in the u-i PR canonical/ubuntu-image#251

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was more than an odd choice, it was a bug!

I do not know if the gadget info is updated when the volume is expanded at install time, so I do not know if DefaultSize() would make sense or not (because if the gadget info is updated, then the value returned by DefaultSize() would not be the default anymore once the volume is expanded). But I think renaming this method to Size() makes sense.

@alfonsosanchezbeato any opinion on that?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe DefaultImageSize() as it would be the default size of a flashable image?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed it Size() because this method could be used for other purposes than giving the "Image" size, and the returned value will change if the Volume was updated so I find it confusing to use Default in the name.

@upils upils changed the title gadget: add a MaxSize method to Volume gadget: add a DefaultImageSize method to Volume Oct 3, 2024
This method is needed to determine the size of the disk image to create in ubuntu-image.

Signed-off-by: Paul Mars <[email protected]>
@upils upils changed the title gadget: add a DefaultImageSize method to Volume gadget: add a Size method to Volume Oct 3, 2024
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.

3 participants