-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Container] az container exec: Fix exception when stdin is not a tty
#30397
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
Conversation
Reproduction steps:
az container exec \
--container-name "container" \
-g "$RESOURCE_GROUP" \
-n "$ACI_NAME" \
--exec-command "echo Hello" > ./stdout < /dev/null 2>./stderr
Expected behavior:
./stdout should contain "Hello"
Actual behavior:
Command crashes without running the command. Error:
ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: (25, 'Inappropriate ioctl for device')
Traceback (most recent call last):
File "/opt/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
raise ex
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/container/custom.py", line 970, in container_exec
_start_exec_pipe_linux(execContainerResponse.web_socket_uri, execContainerResponse.password)
File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/container/custom.py", line 1006, in _start_exec_pipe_linux
old_tty = termios.tcgetattr(stdin_fd)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
termios.error: (25, 'Inappropriate ioctl for device')
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
This makes the "exec" command unusable in e.g. CI environments.
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
az container exec: fix exception when stdin is not a tty
|
Could you add some tests for this code change? |
az container exec: fix exception when stdin is not a ttyaz container exec: Fix exception when stdin is not a tty
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Hi @zhoxing-ms - there is already a test for the Apologies for the late reply - just didn't manage to find time to look into this and eventually forgot. |
Reproduction steps:
Expected behavior:
./stdout should contain "Hello"
Actual behavior:
Command crashes without running the command. Error:
This makes the "exec" command unusable in e.g. CI environments.
Tested that all of the following works:
az container execnormally, starting bash, startingviand it takes the correct terminal size.az container execin our CI now worksThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.