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

lvol: extending to ' +100%FREE' calculating wrong size #2370

Closed
1 task done
dominikkaminski opened this issue Apr 28, 2021 · 8 comments · Fixed by #2369
Closed
1 task done

lvol: extending to ' +100%FREE' calculating wrong size #2370

dominikkaminski opened this issue Apr 28, 2021 · 8 comments · Fixed by #2369
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type) python3 system

Comments

@dominikkaminski
Copy link

Summary

When I try to extend lv to max free available disk space, it calculates the wrong size after upgrading from 2.5.1 to current release (3.0.0)

Error:

fatal: [vm-001]: FAILED! => {"changed": false, "msg": "Logical Volume root could not be extended. Not enough free space left (5120.0m required / 5116.0m available)"}

Possibly related to:

#1988
#2267

Issue Type

Bug Report

Component Name

lvol

Ansible Version

ansible 2.10.8
  config file = /home/dominik.kaminski/ansible/ansible.cfg
  configured module search path = ['/home/dominik.kaminski/ansible/library']
  ansible python module location = /home/dominik.kaminski/.local/lib/python3.6/site-packages/ansible
  executable location = /home/dominik.kaminski/.local/bin/ansible
  python version = 3.6.8 (default, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

Configuration

$ ansible-config dump --only-changed

OS / Environment

UCS

Steps to Reproduce

- name: "Extend logical volume to available space"
  community.general.lvol:
    vg: "{{ extend_root_lvm_volume_lvm_vg_name }}"
    lv: "{{ extend_root_lvm_volume_lvm_data_volume }}"
    resizefs: "yes"
    size: "+100%FREE"
  tags:
    - extend_root_lvm_volume_resize

Expected Results

Volumes should be extended to available free space or calculating free available size correct.

Actual Results

fatal: [vm-001]: FAILED! => {"changed": false, "msg": "Logical Volume root could not be extended. Not enough free space left (5120.0m required / 5116.0m available)"}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added affects_2.10 bug This issue/PR relates to a bug module module needs_triage plugins plugin (any type) python3 system labels Apr 28, 2021
@felixfontein
Copy link
Collaborator

@dominikkaminski can you check whether the PR #2369 fixes the issue for you?

@dominikkaminski
Copy link
Author

@felixfontein I'm sorry to say but it didn't fix my issue.

@felixfontein
Copy link
Collaborator

@dominikkaminski might have been a lucky guess :)
@zigaSRC in that case #2267 might have introduced another problem.

@zigaSRC
Copy link
Contributor

zigaSRC commented Apr 29, 2021

I just tested a few scenarios, I see I should have tested the module more...

The #2369 had no chance of fixing it since this bug is related to the calculation of the logical volume size in the module. That's the concern I mentioned when I was asking if it's smart to do the calculations inside the module and not just let the tool handle it.

Here's a version of the documentation for LVEXTEND(8) --size option which is being used in this case:

The resulting value is rounded upward. N.B. In a future release, when expressed as a percentage with PVS, VG or FREE, the number will be treated as an approximate upper limit for the total number of physical extents to be allocated (including extents used by any mirrors, for example). The code may currently allocate more space than you might otherwise expect.

As mentioned there are slight differences between versions and the documentation also differs. Given that the size is dependant on the version of the tool on the system, it's most likely preferable to do the calculation in the module for consistency's sake. We have a couple of options:

  • Round the calculated size down to the nearest extent.
  • Round up to the nearest extent like it's mentioned in the documentation but also provide an upper limit equal to the amount of free space available.
  • Leave it to the tool to decide; pass the % option through to the tool.

@jake2184
Copy link
Contributor

jake2184 commented Apr 29, 2021

For a bit of extra context, I think this is because you're trying to round up/down when you don't need to.

I create a new LV, with space +100%FREE. I then re-run the lvol module. My size_requested is calculated initially as zero as there is no free space, and my lv size (11260) is a multiple of the vg ext_size (4). See annotated code below.

lvol.py#L511

        size_requested += this_lv['size']        # 0 +=  0 + 11260.0
        size_requested += this_vg['ext_size'] - (size_requested % this_vg['ext_size'])  # 11260 += 4 - (11260 % 4)
        # Result is size_requested = 11264.

A fix could be to add a protection whereby is the size_requested is zero, simply return rather than trying to attempt rounding? Or only add the second line above if size_requested % this_vg['ext_size'] != 0

@zigaSRC
Copy link
Contributor

zigaSRC commented Apr 30, 2021

That's true. I missed that one.
Could just do the rounding in a more proper way to solve this bug: this_vg['ext_size'] * ceil(size_requested / this_vg['ext_size'])

This will still leave us with the discrepancy between the newer versions of the actual tools and the module though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type) python3 system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants