Skip to content

Commit

Permalink
(feat): Rename ShouldResize()
Browse files Browse the repository at this point in the history
  • Loading branch information
lasith-kg committed Dec 25, 2023
1 parent 26eca08 commit db7b1f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/backend/resize.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type BlockDeviceMetrics struct {
BlockDeviceSize uint64
}

func (bdm *BlockDeviceMetrics) ShouldResize(threshold float64) bool {
func (bdm *BlockDeviceMetrics) WithinThreshold(threshold float64) bool {
// Minimum File System Size (mfss)
mfss := float64(bdm.BlockDeviceSize) * (threshold / 100)
return float64(bdm.FileSystemSize) < mfss
Expand Down
4 changes: 2 additions & 2 deletions internal/layer/resize.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (fdl *ResizeDeviceLayer) Modify(c *config.Config) ([]action.Action, error)
// If the resize threshold is set to 0, let us ensure that there is always
// an attempt to resize the block device. For the currently supported file systems
// xfs and ext4, the commands to resize the block device are idempotent
if rt == 0 || metrics.ShouldResize(rt) {
if rt == 0 || metrics.WithinThreshold(rt) {
a, err := fdl.deviceResizeBackend.Resize(bd)
if err != nil {
return nil, err
Expand All @@ -65,7 +65,7 @@ func (fdl *ResizeDeviceLayer) Validate(c *config.Config) error {
rt := c.GetResizeThreshold(name)
// If the resize threshold is 0, then the device would always be resized
// Therefore, lets ignore that case from our validation checks
if rt > 0 && metrics.ShouldResize(rt) {
if rt > 0 && metrics.WithinThreshold(rt) {
return fmt.Errorf("🔴 %s: Failed to resize file system. File System=%d Block Device=%d (bytes)", name, metrics.FileSystemSize, metrics.BlockDeviceSize)
}
}
Expand Down

0 comments on commit db7b1f2

Please sign in to comment.