Bug 1415062

Summary: post-commit with Shell script and args will print some irrelevant lines in build log on console terminal
Product: OKD Reporter: XiaochuanWang <xiaocwan>
Component: BuildAssignee: Corey Daley <cdaley>
Status: CLOSED NOTABUG QA Contact: Wang Haoran <haowang>
Severity: low Docs Contact:
Priority: medium    
Version: 3.xCC: aos-bugs, bparees, dyan, xiuwang
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-02-06 14:34:52 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:

Description XiaochuanWang 2017-01-20 06:44:12 UTC
Description of problem:
Set Post-Commit Hooks by script with args from web console and start build, build log contains some irrelevant lines.

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

How reproducible:

Steps to Reproduce:
1. # oc new-project xiaocwan-t
# oc new-app https://raw.githubusercontent.com/openshift/origin/master/examples/sample-app/application-template-stibuild.json
2. # Edit bc on web console
click "Show advanced options" and find "Post-Commit Hooks"
set Shell Script with Arguments
    Script -> echo "this is a script"
    1 arguments: hello -> click Add 
3. Save and start build#2 and check log in web terminal again

Actual results:
Build#2 log contains below output
  ---> Cleaning up unused ruby gems ...
  Running post commit hook ...
  sh: cannot set terminal process group (-1): Inappropriate ioctl for device
  sh: no job control in this shell
  this is a script
  Pushing image x.x.x.x:5000/xiaocwan-t/origin-ruby-sample:latest ...
Then the build is completed.

Expected results:
Seems these 2 lines has no reason to display:
  sh: cannot set terminal process group (-1): Inappropriate ioctl for device
  sh: no job control in this shell

Additional info:
test command with args will not reproduced, output is below
Running post commit hook ... 
BC config for Post-Commit Hooks:
Command: echo 
Args:    hello

Comment 1 Corey Daley 2017-01-25 19:30:11 UTC
According to a comment in the code (located here: https://github.com/openshift/origin/blob/master/pkg/build/builder/common.go#L124)

"// The `-i` flag is needed to support CentOS and RHEL images
// that use Software Collections (SCL), in order to have the
// appropriate collections enabled in the shell. E.g., in the
// Ruby image, this is necessary to make `ruby`, `bundle` and
// other binaries available in the PATH."

So, the first example that you showed that shows the extra lines of output is the equivalent of:

docker run centos /bin/sh -ic echo "this is a test" /bin/sh hello

And the second example that does NOT show the extra lines is the equivalent of:

docker run centos echo hello

If you run those commands on your workstation you will get the same lines output.  Which seems to make this a docker issue that is possibly fixed in docker 1.2 from what I have read.

Closing as not a bug.

Comment 2 Ben Parees 2017-01-25 19:33:13 UTC
Moving to ON_QA so test cases (if applicable) can be updated.

Comment 3 XiaochuanWang 2017-02-06 06:42:50 UTC
This is caused by an old existed docker issue: https://github.com/docker/docker/issues/18

'docker run centos /bin/sh -ic echo "this is a test" /bin/sh hello' will get the message
'docker run centos echo hello' will not get the message

Case will be updated to use other image or ignore it for this scenario. So close it as not a bug.