Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1093119

Summary: image-download fails - causes terminal text to gibberish
Product: Red Hat OpenStack Reporter: Tzach Shefi <tshefi>
Component: python-glanceclientAssignee: CIndy Pallares <cpallare>
Status: CLOSED UPSTREAM QA Contact: Dafna Ron <dron>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.0CC: cpallare, eglynn, fpercoco, jruzicka, sclewis, scohen, sgotliv, yeylon
Target Milestone: ---Keywords: Reopened, ZStream
Target Release: 5.0 (RHEL 7)   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-25 09:25:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Glance api.log none

Description Tzach Shefi 2014-04-30 16:16:58 UTC
Created attachment 891227 [details]
Glance api.log

Description of problem:  

Glance image-download fails causing ssh terminal text to gibberish. 
Tested using ssh directly to Glance server, as well as ssh to cloud controller (separate server). Tested from two different remote hosts running two different terminal clients, not a host/ssh/terminal issue.

Version-Release number of selected component (if applicable):
RHEL 6.5
openstack-glance-2013.2.3-2.el6ost.noarch
python-glanceclient-0.12.0-2.el6ost.noarch
python-glance-2013.2.3-2.el6ost.noarch


How reproducible:
Every time

Steps to Reproduce:
1. Upload an image     (Glance backend is Gluster based)
2. # glance image-download <image_ID>
3. After a short delay a few seconds terminal text turn to gibberish. 

Actual results:
After a few seconds of delay the screen fills with: 
                              
@2o�xw��4�emuu�s�R���S!����Q�P��. ��▒��[b3�p7b�!X;��ԌĎɡ-u�q�%����Mao�1E�.1�x▒��=�ؽ��@)�~� ���   �����-��t���؏)���w��W�[▒���ߕ�o▒�F��OlR/��1b��x%�#F�|��0�1���U#ң֍�tc��zF���� �▒Ȕq��I�J�sP)���ʸJ▒8m�"a߰�4��0�"*��}$▒J#��\:T2z�J▒�S�c&p�3$o2n7i��t.Ob�����6q%����I�����*X��_jl|H4���q[d�e��le��ѿ�,YJ���}˄cM��������                          
�/{ˌ���,k��p�_▒���|� IA�z�g��w��:Ȼ  �B�3��d�'�u��▒����qj�vP�&��T�ȄL0<�.��������S�ßU                                 

                                           
Expected results:

Image should download successfully without gibberishing ssh session.

Additional info:

Comment 2 Flavio Percoco 2014-05-05 09:25:17 UTC
This is the expected behavior and it has nothing to do with ssh. `image-download` default's output is stdout. In order to avoid 'gibberishing' the terminal, you should redirect the output to a file.

Unfortunately, we can't do anything about the terminal being completely messed up after the image is dumped to stdout, AFAIK.

Comment 3 Dafna Ron 2014-05-07 09:15:47 UTC
Flavio, this looks really bad and no where in the cli help does it say that we need to specify a file. 

can we add --file from optional to positional argument? add a default location for the stdout under /tmp in case none is supplied? or at least add a warning to the cli help?

usage: glance image-download [--file <FILE>] [--progress] <IMAGE>

Download a specific image.

Positional arguments:
  <IMAGE>        Name or ID of image to download.

Optional arguments:
  --file <FILE>  Local file to save downloaded image data to. If this is not
                 specified the image data will be written to stdout.
  --progress     Show download progress bar.
[root@puma32 ~(keystone_admin)]#

Comment 5 Flavio Percoco 2014-05-22 22:23:35 UTC
Making `--file` a positional argument wouldn't allow the user to pipe the output, so would adding a default value for `--file`

I'll investigate whether detecting a unix pipe is possible / worth it.

I don't think this is really bad. It's *always* been like this and people is/should be used to it already. That doesn't mean we can't make it better, though.

Comment 6 Flavio Percoco 2014-05-23 05:08:46 UTC
Another solution would be to add an `--stdout` CLI arg and make the client to require either that parameter or `--file`

This would be a major change in the API and I'd like to get the community feedback here first.

Comment 7 Flavio Percoco 2014-05-23 10:23:34 UTC
I should stop commenting on bugs at 1am. So, it's obviously possible to know whether the output is being redirected or not. Here's a proposal for this fix:

1. If the output is not being redirect and `--file` is not set, require `--stdout` to be passed.
2. Keep redirection behavior as-is for backwards compatibility
3. If the output is being redirected, print a warning saying that `--stdout` should be passed.
4. In future versions *always* require one of both options.

In order to know whether the output is being redirected or not, it's enough to check if `stdout` is a tty,

```
import sys

sys.stdout.isatty()
```

@Cindy, any chance you can also tackle this?

Comment 8 CIndy Pallares 2014-06-09 14:52:28 UTC
(In reply to Flavio Percoco from comment #7)
> I should stop commenting on bugs at 1am. So, it's obviously possible to know
> whether the output is being redirected or not. Here's a proposal for this
> fix:
> 
> 1. If the output is not being redirect and `--file` is not set, require
> `--stdout` to be passed.
> 2. Keep redirection behavior as-is for backwards compatibility
> 3. If the output is being redirected, print a warning saying that `--stdout`
> should be passed.
> 4. In future versions *always* require one of both options.
> 
> In order to know whether the output is being redirected or not, it's enough
> to check if `stdout` is a tty,
> 
> ```
> import sys
> 
> sys.stdout.isatty()
> ```
> 
> @Cindy, any chance you can also tackle this?

I'll look into this one.

Comment 10 Flavio Percoco 2015-08-25 09:25:50 UTC
This has been fixed upstream and I don't think it's a high-prio bug that we should dedicate any more resources on.