Azure / azure-cli

Azure Command-Line Interface
MIT License
4.02k stars 2.99k forks source link

piping output to other programs ('less' here) causes a "broken pipe" error #19265

Open cadeavil-msft opened 3 years ago

cadeavil-msft commented 3 years ago

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az vm boot-diagnostics get-boot-log

Errors:

The command failed with an unexpected error. Here is the traceback:
[Errno 32] Broken pipe
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 657, in execute
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 691, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/vm/custom.py", line 1645, in get_boot_log
    storage_client.get_blob_to_stream(container, blob, BootLogStreamWriter(sys.stdout), max_connections=1)
  File "/opt/az/lib/python3.6/site-packages/azure/multiapi/storage/v2018_11_09/blob/baseblobservice.py", line 2166, in get_blob_to_stream
    stream.write(blob.content)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/vm/custom.py", line 1579, in write
    self.out.write(content)
BrokenPipeError: [Errno 32] Broken pipe

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

Expected Behavior

closing the pipe by ending the program should not result in a backtrace.

Environment Summary

Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-debian-bullseye-sid
Python 3.6.10
Installer: DEB

azure-cli 2.27.1

Extensions:
vm-repair 0.3.6
ssh 0.1.5

Additional Context

yonzhan commented 3 years ago

Compute