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

ceph-disk: include output of failed command in exception #20497

Merged
merged 1 commit into from
Feb 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ceph-disk/ceph_disk/main.py
Expand Up @@ -1251,7 +1251,7 @@ def get_conf_with_default(cluster, variable):
except subprocess.CalledProcessError as e:
raise Error(
'getting variable from configuration failed',
e,
e, e.output,
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks OK, but what if the CalledProcessError is not coming from the modified one from _check_output and it is really coming from subprocess ? You wouldn't get the output that gets slapped there. Maybe a getattr(e, 'output', '') ?

Copy link
Contributor Author

@tchaikov tchaikov Feb 22, 2018

Choose a reason for hiding this comment

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

@alfredodeza, CalledProcessError is raised by subprocess.check_call(), subprocess.check_output() and subprocess.CompletedProcess.check_returncode(). it won't be raised by subprocess.Popen 's constructor or subprocess.Popen.communicate(). i double checked the document and the source of py2.7 and py3.6.

Copy link
Contributor

Choose a reason for hiding this comment

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

Man is this difficult to follow. You are right, the command() is calling Popen.

)

value = str(out).split('\n', 1)[0]
Expand Down