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

Fix call to Popen.communicate #636

Merged
merged 4 commits into from
Mar 4, 2024
Merged

Conversation

lmlg
Copy link
Contributor

@lmlg lmlg commented Aug 31, 2021

The call is wrongly passing a string when only bytes-like are allowed.

@@ -60,7 +60,7 @@ def remove_lvm_physical_volume(block_device):
'''
p = Popen(['pvremove', '-ff', block_device],
stdin=PIPE)
p.communicate(input='y\n')
p.communicate(input=b'y\n')
Copy link
Contributor

Choose a reason for hiding this comment

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

Whilst I'm generally in agreement here, I'm a little worried this might be incompatible across versions of python3. e.g. the original change was 8 years ago, so it's worked up till today. I'm going to nack this from landing until we've verified that it works across py3.6 -> py3.9 (?py 3.10?).

Copy link
Collaborator

Choose a reason for hiding this comment

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

pvremove supports the -y or --yes flag from xenial through impish. That might be a better change for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that does sound better, and it's similar to what create_logical_volume does via lvcreate. What do you think, @ajkavanagh ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm +1 on passing --yes and replacing the use of Popen with subprocess.check_call.

Copy link
Contributor

@ajkavanagh ajkavanagh left a comment

Choose a reason for hiding this comment

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

Holding until it's been verified; the unit tests passing don't necessarily mean that it'll actually work in deployment. Thanks.

Copy link
Collaborator

@freyes freyes left a comment

Choose a reason for hiding this comment

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

@lmlg , do you have some CI job where this patch is being exercised?

@@ -60,7 +60,7 @@ def remove_lvm_physical_volume(block_device):
'''
p = Popen(['pvremove', '-ff', block_device],
stdin=PIPE)
p.communicate(input='y\n')
p.communicate(input=b'y\n')
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm +1 on passing --yes and replacing the use of Popen with subprocess.check_call.

@lmlg
Copy link
Contributor Author

lmlg commented Sep 3, 2021

@lmlg , do you have some CI job where this patch is being exercised?

No, but I've been using it as part of running the functional tests locally for the cinder-lvm charm.

lmlg added 4 commits March 4, 2024 10:29
The call is wrongly passing a string when only bytes-like are allowed.
This PR modified the call to no longer use 'Popen', but it was
missing the corresponding fix in the unit test for said function.
@freyes freyes force-pushed the fix-popen-communicate branch from ff66ab1 to e44a15e Compare March 4, 2024 13:30
@freyes
Copy link
Collaborator

freyes commented Mar 4, 2024

Rebased on top of master.

Copy link
Collaborator

@freyes freyes left a comment

Choose a reason for hiding this comment

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

LGTM. Changes have been addressed

@freyes freyes requested a review from ajkavanagh March 4, 2024 13:41
Copy link
Contributor

@ajkavanagh ajkavanagh left a comment

Choose a reason for hiding this comment

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

LGTM

@ajkavanagh ajkavanagh merged commit b78107d into juju:master Mar 4, 2024
4 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.

Function 'remove_lvm_physical_volume' passing invalid input
4 participants