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

Function 'remove_lvm_physical_volume' passing invalid input #634

Closed
lmlg opened this issue Aug 25, 2021 · 0 comments · Fixed by #636
Closed

Function 'remove_lvm_physical_volume' passing invalid input #634

lmlg opened this issue Aug 25, 2021 · 0 comments · Fixed by #636

Comments

@lmlg
Copy link
Contributor

lmlg commented Aug 25, 2021

Hello,
The function charmhelpers.contrib.storage.linux.lvm.remove_lvm_physical_volume is passing an erroneous argument to the method communicate of the standard Popen class.

Here: https://github.com/juju/charm-helpers/blob/master/charmhelpers/contrib/storage/linux/lvm.py#L63

we can see that it's being passed a string, but after using it in the cinder-lvm charm, I get the following traceback:

  File "lib/charm/openstack/cinder_lvm.py", line 265, in prepare_volume
    clean_storage(device)
  File "lib/charm/openstack/cinder_lvm.py", line 293, in clean_storage
    remove_lvm_physical_volume(block_device)
  File "/var/lib/juju/agents/unit-cinder-lvm-0/.venv/lib/python3.6/site-packages/charmhelpers/contrib/storage/linux/lvm.py", line 63, in remove_lvm_physical_volume
    p.communicate(input='y\n')
  File "/usr/lib/python3.6/subprocess.py", line 848, in communicate
    self._stdin_write(input)
  File "/usr/lib/python3.6/subprocess.py", line 801, in _stdin_write
    self.stdin.write(input)
TypeError: a bytes-like object is required, not 'str'

A simple fix would be to use the bytes equivalent: b'y\n'.

@wolsen wolsen linked a pull request Aug 31, 2021 that will close this issue
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 a pull request may close this issue.

1 participant