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

NAS-125487 / 24.10 / Use stderr from zectl failures for CallError #12614

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions src/middlewared/middlewared/plugins/bootenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def activate(self, oid):
try:
subprocess.run([self.BE_TOOL, 'activate', oid], capture_output=True, text=True, check=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should do stdout=subprocess.PIPE, stderr=subprocess.STDOUT and check the return code because IIRC, zectl can dump errors to stdout or stderr.

except subprocess.CalledProcessError as cpe:
raise CallError(f'Failed to activate BE: {cpe.stdout.strip()}')
raise CallError(f'Failed to activate BE: {cpe.stderr.strip()}')
else:
return True

Expand Down Expand Up @@ -224,7 +224,7 @@ async def do_create(self, data):
try:
await run(args, encoding='utf8', check=True)
except subprocess.CalledProcessError as cpe:
raise CallError(f'Failed to create boot environment: {cpe.stdout}')
raise CallError(f'Failed to create boot environment: {cpe.stderr}')
return data['name']

@accepts(Str('id'), Dict(
Expand Down Expand Up @@ -274,5 +274,5 @@ async def do_delete(self, job, oid):
try:
await run(self.BE_TOOL, 'destroy', '-F', be['id'], encoding='utf8', check=True)
except subprocess.CalledProcessError as cpe:
raise CallError(f'Failed to delete boot environment: {cpe.stdout}')
raise CallError(f'Failed to delete boot environment: {cpe.stderr}')
return True