Bug 1347512 - Meet error 'unable to load template file "openshift/...' when run oc new-app openshift/image-name:latest under a directory which contains the 'openshift' binary
Summary: Meet error 'unable to load template file "openshift/...' when run oc new-app ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build
Version: 3.2.1
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
: ---
Assignee: Martin Milata
QA Contact: Wenjing Zheng
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-06-17 06:52 UTC by zhou ying
Modified: 2017-07-24 14:11 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: oc new-app tries to interpret its argument as a path and exits with an error when a component of this path exists but is not a directory. Consequence: Running oc new-app X/Y with file named X in the current directory exits with an error even though X/Y denotes valid docker image. Fix: When oc new-app tries to interpret input component as a directory and object with that name exists on a filesystem but is not a directory, try another possible interpretation instead of exiting with an error. Result: Running oc new-app X/Y creates new app based on docker image X/Y even in the case when file X exists in the current directory.
Clone Of:
Environment:
Last Closed: 2017-04-12 19:05:43 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:0884 0 normal SHIPPED_LIVE Red Hat OpenShift Container Platform 3.5 RPM Release Advisory 2017-04-12 22:50:07 UTC

Description zhou ying 2016-06-17 06:52:25 UTC
Description of problem:
Meet error 'unable to load template file  "unable to load template file "openshift/hello-openshift": the path "openshift/hello-openshift" cannot be accessed: stat openshift/hello-openshift: not a directory' when run oc new-app openshift/hello-openshift:latest under a  directory which contains the 'openshift' binary.  
Delete the openshift binary, or change to a nother directory without the openshift binary, oc new-app works well.

Version-Release number of selected component (if applicable):
oc v3.2.1.2-1-g64665fc
kubernetes v1.2.0-36-g4a3f9c5

How reproducible:
always

Steps to Reproduce:
1. Login OpenShift and create project;
2. Suppose you have copied 'openshift' binary to a directory 'mydir'
[root@pc ~]$ mkdir mydir
[root@pc ~]$ cp /usr/bin/openshift mydir/
[root@pc ~]$ cd mydir/
[root@pc mydir] oc new-app openshift/hello-openshift:latest
error: unable to load template file  "openshift/hello-openshift:latest": the path  "openshift/hello-openshift:latest" cannot be accessed: stat  openshift/hello-openshift:latest: not a directory

3. Remove 'openshift' binary from 'mydir', then try oc new-app again
[root@pc mydir] rm -f openshift
[root@pc mydir] oc new-app openshift/hello-openshift:latest
--> Found Docker image 3c55d5d (5 hours old) from Docker Hub for "openshift/hello-openshift:latest"
    * An image stream will be created as "hello-openshift:latest" that will track this image
    * This image will be deployed in deployment config "hello-openshift"
    * [WARNING] Image "hello-openshift" runs as the 'root' user which may not be permitted by your cluster administrator
    * Ports 8080/tcp, 8888/tcp will be load balanced by service "hello-openshift"
--> Creating resources with label app=hello-openshift ...
...

Actual results:
2. 
[root@pc mydir] oc new-app openshift/hello-openshift:latest
error:  unable to load template file  "openshift/hello-openshift:latest": the  path  "openshift/hello-openshift:latest" cannot be accessed: stat   openshift/hello-openshift:latest: not a directory

Expected results:
Create app successfully.

Additional info:
As far as I tried, old version of oc does not have the problem, e.g. oc v3.1.1.6-35-g0742c54, but oc v3.2.0.5 does have.

Comment 1 Martin Milata 2016-11-21 15:32:33 UTC
Pull request: https://github.com/openshift/origin/pull/11918
(I mixed up the BZ number, the one in commit message is wrong)

Commit: https://github.com/openshift/origin/commit/b94313c00c053eaebf3f2183f15bd61b6516a7fd

Should be included in OCP 3.5

Comment 2 Troy Dawson 2017-01-20 23:21:53 UTC
This has been merged into ocp and is in OCP v3.5.0.7 or newer.

Comment 3 zhou ying 2017-01-22 06:01:41 UTC
Confirmed with latest OCP, the issue has fixed:

[root@zhouy testjson]# ll openshift 
-rwxr-xr-x. 1 root root 213234440 Jan 22 13:42 openshift
[root@zhouy testjson]# oc new-app openshift/deployment-example
--> Found Docker image 1c839d8 (18 months old) from Docker Hub for "openshift/deployment-example"

    * An image stream will be created as "deployment-example:latest" that will track this image
    * This image will be deployed in deployment config "deployment-example"
    * Port 8080/tcp will be load balanced by service "deployment-example"
      * Other containers can access this service through the hostname "deployment-example"
    * WARNING: Image "openshift/deployment-example" runs as the 'root' user which may not be permitted by your cluster administrator

--> Creating resources ...
    imagestream "deployment-example" created
    deploymentconfig "deployment-example" created
    service "deployment-example" created
--> Success
    Run 'oc status' to view your app.
[root@zhouy testjson]# oc get po 
NAME                         READY     STATUS    RESTARTS   AGE
deployment-example-1-2mlwv   1/1       Running   0          1m
[root@zhouy testjson]# oc version
oc v3.5.0.7+390ef18
kubernetes v1.5.2+43a9be4
features: Basic-Auth GSSAPI Kerberos SPNEGO



openshift v3.5.0.7+390ef18
kubernetes v1.5.2+43a9be4

Comment 5 errata-xmlrpc 2017-04-12 19:05:43 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-2017:0884


Note You need to log in before you can comment on or make changes to this bug.