Bug 1323165

Summary: Handling of parameters to atomic install regressed
Product: Red Hat Enterprise Linux 7 Reporter: Jan Pazdziora (Red Hat) <jpazdziora>
Component: atomicAssignee: Brent Baude <bbaude>
Status: CLOSED ERRATA QA Contact: atomic-bugs <atomic-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.2CC: ajia, bbaude, dwalsh, jpazdziora, lsm5
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-06-23 16:21:34 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 Jan Pazdziora (Red Hat) 2016-04-01 12:27:19 UTC
Description of problem:

With atomic 1.9, parameters are no longer passed to install.sh correctly.

Version-Release number of selected component (if applicable):

atomic-1.9-4.gitff44c6a.el7.x86_64
docker-1.9.1-25.el7.x86_64

How reproducible:

Deterministic.

Steps to Reproduce:
1. Have atomic-test/Dockerfile with content

FROM rhel7
COPY install.sh /bin/
RUN chmod +x /bin/install.sh
LABEL INSTALL 'docker run --rm=true --net=host -v /:/host -e NAME=${NAME} -e IMAGE=${IMAGE} -e HOST=/host ${IMAGE} /bin/install.sh'

2. Have atomic-test/install.sh with content

#!/bin/bash
echo Parameters:
for i in "$@" ; do
	echo "  $i"
done

3. Run docker build -t atomic-test ~/atomic-test
4. Run atomic install atomic-test jezek 'asdf jkl'

Actual results:

docker run --rm=true --net=host -v /:/host -e NAME=atomic-test -e IMAGE=atomic-test -e HOST=/host atomic-test /bin/install.sh jezek 'asdf jkl'
Parameters:
  jezek
  'asdf
  jkl'

Expected results:

docker run --rm=true --net=host -v /:/host -e NAME=atomic-test -e IMAGE=atomic-test -e HOST=/host atomic-test /bin/install.sh jezek 'asdf jkl'
Parameters:
  jezek
  asdf jkl

Additional info:

The expected result comes from atomic-1.6-6.gitca1e384.el7.x86_64 / docker-1.8.2-10.el7.x86_64.

Comment 1 Jan Pazdziora (Red Hat) 2016-04-01 12:31:20 UTC
Another example:

# atomic install atomic-test 'asdf&jkl'
docker run --rm=true --net=host -v /:/host -e NAME=atomic-test -e IMAGE=atomic-test -e HOST=/host atomic-test /bin/install.sh 'asdf&jkl'
Parameters:
  'asdf&jkl'

vs. the correct

# atomic install atomic-test 'asdf&jkl'
docker run --rm=true --net=host -v /:/host -e NAME=atomic-test -e IMAGE=atomic-test -e HOST=/host atomic-test /bin/install.sh 'asdf&jkl'
Parameters:
  asdf&jkl

Comment 2 Jan Pazdziora (Red Hat) 2016-04-01 12:32:17 UTC
Also, there is regression with the non-US-ASCII character handling, compared to atomic 1.8 (see bug 1307034 command 4):

# atomic install atomic-test ježek
'ascii' codec can't decode byte 0xc5 in position 3: ordinal not in range(128)

Comment 5 Jan Pazdziora (Red Hat) 2016-04-01 12:42:47 UTC
Even just plain

LABEL INSTALL 'bash -c "echo arg1 arg2"'

seems to be broken now:

# atomic install atomic-test
bash -c "echo arg1 arg2"
arg1: -c: line 0: unexpected EOF while looking for matching `"'
arg1: -c: line 1: syntax error: unexpected end of file

vs. the original (and correct)

# atomic install atomic-test
bash -c echo arg1 arg2
arg1 arg2

with atomic-1.6-6.gitca1e384.el7.x86_64.

Comment 6 Daniel Walsh 2016-04-04 18:12:17 UTC
Jan could you check out

https://github.com/projectatomic/atomic/pull/336

Comment 7 Jan Pazdziora (Red Hat) 2016-04-21 12:58:53 UTC
(In reply to Daniel Walsh from comment #6)
> Jan could you check out
> 
> https://github.com/projectatomic/atomic/pull/336

Yes, that patch fixes cases from comment 0, comment 1, and comment 5.

The ascii codec issues from comment 2 is still present.

Comment 8 Brent Baude 2016-04-21 20:58:25 UTC
@Jan,

Would it be possible for you to pull my atomic_ascii branch and see if it passes comment #2 now?  Might also be worth checking that the other use cases are also valid.

https://github.com/baude/atomic/tree/atomic_ascii

Comment 9 Jan Pazdziora (Red Hat) 2016-04-22 06:54:10 UTC
Applying just the 7e34f5d7cd6b2a57d855d1faba22c041e02182bc on top of atomic-1.9-4.gitff44c6a.el7.x86_64 and https://github.com/projectatomic/atomic/pull/336 does not resolve the

'ascii' codec can't decode byte 0xc5 in position 3: ordinal not in range(128)

issue.

I also wonder why you specifically target UTF-8 there. While it likely is the encoding that the majority will use, atomic should not really care about the encoding at all -- just pass verbatim whatever parameters there are on the command line.

Comment 10 Daniel Walsh 2016-04-25 14:23:04 UTC
We should add this to the test suite to make sure we handle this situation.

Comment 11 Daniel Walsh 2016-04-25 14:27:12 UTC
Jan what code are you referring to exactly for "utf-8"  Could you submit a patch.

Comment 13 Daniel Walsh 2016-04-25 15:14:28 UTC
Jan please review

https://github.com/projectatomic/atomic/pull/358

Comment 14 Daniel Walsh 2016-04-25 15:58:03 UTC
Jan so you are saying there is no need for

 -        return " ".join(args)
+        return " ".join([x.decode('utf-8') for x in args])


Is this code alright?


 +    # break command into list
+    try:
         cmd = shlex.split(cmd)
+    except UnicodeEncodeError:
+        # The command contains a non-ascii character
+        cmd = shlex.split(" ".join([x.encode('utf-8') for x in cmd.split()]))

Comment 15 Jan Pazdziora (Red Hat) 2016-04-29 10:23:38 UTC
(In reply to Daniel Walsh from comment #14)
> Jan so you are saying there is no need for
> 
>  -        return " ".join(args)
> +        return " ".join([x.decode('utf-8') for x in args])
> 
> 
> Is this code alright?

I really don't know, I'm not expert on encodings in python.

But if you do

echo malá | iconv -f utf8 -t iso88591 | xargs echo

you will get ISO-8859-1 character (single byte) which is not UTF-8 (try piping to od -c). I'm not sure what the situation with non-UTF-8 is in Asian parts of the world.

Comment 16 Daniel Walsh 2016-04-29 18:42:34 UTC
 atomic install atomic-test ježek 'foo bar'docker run --rm=true --net=host -v /:/host -e NAME=atomic-test -e IMAGE=atomic-test -e HOST=/host atomic-test /bin/install.sh 'ježek' 'foo bar'
ježek
foo bar

So this is what we currently have?  Jan what should the output be?

Comment 17 Jan Pazdziora (Red Hat) 2016-04-30 15:16:45 UTC
The output looks good.

Thank you.

Comment 18 Daniel Walsh 2016-06-03 19:49:52 UTC
Fixed in atomic-1.10

Comment 19 Jan Pazdziora (Red Hat) 2016-06-07 16:56:27 UTC
I confirm that cases from comment 0, comment 1, comment 2, and comment 5 now give expected results with

python-docker-py-1.7.2-1.el7.noarch
atomic-1.10.3-2.el7.x86_64

Comment 21 Alex Jia 2016-06-12 09:02:18 UTC
Moving the bug to VERIFIED status per Comment 19 and actually testing on atomic-1.10.3-2 and atomic-1.10.5-3 w/ python-docker-py-1.7.2-1.

Comment 23 errata-xmlrpc 2016-06-23 16:21:34 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2016:1273