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

az container exec. pipe command result to file fails [Errno 25] Inappropriate ioctl for device #28553

Closed
programista-zacny opened this issue Mar 13, 2024 · 14 comments
Labels
Auto-Assign Auto assign by bot Auto-Resolve Auto resolve by bot bug This issue requires a change to an existing behavior in the product in order to be resolved. Container Instances az container ContainerApp customer-reported Issues that are reported by GitHub users external to the Azure organization. Possible-Solution Service Attention This issue is responsible by Azure service team. Similar-Issue

Comments

@programista-zacny
Copy link

Describe the bug

I'm trying to
az containerapp exec --subscription subscription -g group -n name --command "cat /etc/hosts" >> test.log and it fails...

Exception in thread Thread-1 (read_ssh):
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "/opt/homebrew/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/homebrew/Cellar/azure-cli/2.58.0/libexec/lib/python3.11/site-packages/azure/cli/command_modules/containerapp/_ssh_utils.py", line 123, in read_ssh
    _resize_terminal(connection)
  File "/opt/homebrew/Cellar/azure-cli/2.58.0/libexec/lib/python3.11/site-packages/azure/cli/command_modules/containerapp/_ssh_utils.py", line 154, in _resize_terminal
    size = os.get_terminal_size()
           ^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 25] Inappropriate ioctl for device

Related command

az containerapp exec --subscription subscription -g group -n name --command "cat /etc/hosts" >> test.log

Errors

Exception in thread Thread-1 (read_ssh):
Traceback (most recent call last):
File "/opt/homebrew/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
self.run()
File "/opt/homebrew/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 982, in run
self._target(*self._args, **self._kwargs)
File "/opt/homebrew/Cellar/azure-cli/2.58.0/libexec/lib/python3.11/site-packages/azure/cli/command_modules/containerapp/_ssh_utils.py", line 123, in read_ssh
_resize_terminal(connection)
File "/opt/homebrew/Cellar/azure-cli/2.58.0/libexec/lib/python3.11/site-packages/azure/cli/command_modules/containerapp/_ssh_utils.py", line 154, in _resize_terminal
size = os.get_terminal_size()
^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 25] Inappropriate ioctl for device

Issue script & Debug output

.

Expected behavior

Pipe result to file.

Environment Summary

{
"azure-cli": "2.58.0",
"azure-cli-core": "2.58.0",
"azure-cli-telemetry": "1.1.0",
"extensions": {}
}

Additional context

No response

@programista-zacny programista-zacny added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Mar 13, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. Auto-Assign Auto assign by bot Container Instances az container labels Mar 13, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented Mar 13, 2024

Thank you for opening this issue, we will look into it.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Service Attention This issue is responsible by Azure service team. label Mar 13, 2024
Copy link

Hi @programista-zacny
Find similar issue #13352.

Issue title az container exec in azure devops throws (25, 'Inappropriate ioctl for device')
Create time 2020-05-06
Comment number 21

Possible solution:
The error message "Inappropriate ioctl for device" is thrown when trying to use az container exec in Azure DevOps Pipelines. One solution to this issue is to emulate tty using the following command:

script --return --quiet -c "az container exec --resource-group myRG --name myImageName --exec-command ./run.sh'" /dev/null

This should allow you to display the output of the container and pipe the result to a file.


Please confirm if this resolves your issue.

Copy link
Contributor

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @dkkapur.

Copy link
Contributor

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @calvinsID.

Copy link
Contributor

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @dkkapur.

Copy link
Contributor

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @calvinsID.

1 similar comment
Copy link
Contributor

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @calvinsID.

Copy link
Contributor

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @dkkapur.

Copy link
Contributor

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @calvinsID.

@Greedygre
Copy link
Contributor

Hi @programista-zacny

Thanks for reporting this issue.
May I ask what is the device and scenario for executing the command?
OSError: [Errno 25] Inappropriate ioctl for device

Thanks.

@programista-zacny
Copy link
Author

MacOS Sonoma 14 on MacBook Air M2.

@Greedygre
Copy link
Contributor

Greedygre commented Apr 16, 2024

MacOS Sonoma 14 on MacBook Air M2.
Hi @programista-zacny

Can you help me to double confirm the result of the execution of these python code on MacOS Sonoma 14 on MacBook Air M2?

from shutil import get_terminal_size
size = get_terminal_size()
print(size) 

Thanks.

@programista-zacny
Copy link
Author

Result: os.terminal_size(columns=200, lines=50)
I run this on iTerm.

@Greedygre
Copy link
Contributor

Result: os.terminal_size(columns=200, lines=50) I run this on iTerm.

Thanks.
The fix has been merged and will be released in Azure CLI version: 2.60.0.
https://github.com/Azure/azure-cli/milestone/141

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot Auto-Resolve Auto resolve by bot bug This issue requires a change to an existing behavior in the product in order to be resolved. Container Instances az container ContainerApp customer-reported Issues that are reported by GitHub users external to the Azure organization. Possible-Solution Service Attention This issue is responsible by Azure service team. Similar-Issue
Projects
None yet
Development

No branches or pull requests

3 participants