Bug 1668763

Summary: oc rsh modifies output by inserting CRLF
Product: OpenShift Container Platform Reporter: Brendan Mchugh <bmchugh>
Component: ocAssignee: Juan Vallejo <jvallejo>
Status: CLOSED NOTABUG QA Contact: Xingxing Xia <xxia>
Severity: low Docs Contact:
Priority: medium    
Version: 3.10.0CC: aos-bugs, bmchugh, jokerman, mmccomas
Target Milestone: ---   
Target Release: 4.1.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-01-24 18:07:04 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:

Description Brendan Mchugh 2019-01-23 14:31:43 UTC
Description of problem:
When piping output from "oc rsh", CRLF characters are inserted changing the original output.
"oc exec" does not modify the output.

Version-Release number of selected component (if applicable):
oc v3.10.89
openshift v3.10.89
kubernetes v1.10.0+b81c8f8


How reproducible:
Always

Steps to Reproduce:
1. oc project <some_project>
2. oc exec <podname> cat somefile > outfile.exec
3. oc rsh <podname> cat somefile  > outfile.rsh

Actual results:
[root@test ~]# oc project default
Already on project "default" on server "https://test.example.com:8443".

[root@test ~]# oc exec router-1-4w5w5 cat haproxy-config.template > haproxy-config.template.exec
[root@test ~]# oc rsh router-1-4w5w5 cat haproxy-config.template > haproxy-config.template.rsh

[root@test ~]# ls -la haproxy-config.template.*
-rw-r--r--. 1 root root 28002 Jan 23 14:30 haproxy-config.template.exec
-rw-r--r--. 1 root root 28558 Jan 23 14:30 haproxy-config.template.rsh


[root@test ~]# file haproxy-config.template.exec
haproxy-config.template.exec: ASCII text, with very long lines

[root@test ~]# file haproxy-config.template.rsh
haproxy-config.template.rsh: ASCII text, with very long lines, with CRLF line terminators


md5sum within running container.
sh-4.2$ md5sum haproxy-config.template 
6fb15bc4f46c731054f05fa988579d2e  haproxy-config.template

md5sum of output files.
[root@test ~]# md5sum haproxy-config.template.*
6fb15bc4f46c731054f05fa988579d2e  haproxy-config.template.exec
491b27fbeb8ef13b5e5027fcea1a7af4  haproxy-config.template.rsh


Expected results:
Output should not be modified.

Additional info:

Comment 1 Juan Vallejo 2019-01-23 16:45:39 UTC
`oc rsh` attaches a tty by default. Do you still see extra chars inserted in your output after running `oc rsh --no-tty=true ...` ?

This could be a possible duplicate of https://bugzilla.redhat.com/show_bug.cgi?id=1638447

Comment 2 Brendan Mchugh 2019-01-24 07:54:37 UTC
Thank you for the clarification.

With 'oc rsh --no-tty=true' the output matches that of the file inside the container.


I will file a separate docs bug against the "bare" oc rsh usage we advise for copying the haproxy configuartion files in the customizing haproxy section of the docs as that is where this issue has come up and in the linked bz 1638447. [1]
We should probably be recommending either 'oc exec' or 'oc cp' usage rather than 'oc rsh'.

[1] https://docs.openshift.com/container-platform/3.10/install_config/router/customized_haproxy_router.html#obtaining-router-configuration-template

Comment 3 Juan Vallejo 2019-01-24 18:07:04 UTC
> We should probably be recommending either 'oc exec' or 'oc cp' usage rather than 'oc rsh'.

Yes, I definitely agree.

Thanks for confirming `oc rsh --no-tty` matches the desired output. Closing this as NOTABUG.