Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1357674 - oc does not validate that git is installed.
Summary: oc does not validate that git is installed.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build
Version: 3.2.0
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
: ---
Assignee: Cesar Wong
QA Contact: Wang Haoran
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-07-18 20:17 UTC by jritenou
Modified: 2016-09-27 09:40 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-09-27 09:40:47 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:1933 normal SHIPPED_LIVE Red Hat OpenShift Container Platform 3.3 Release Advisory 2016-09-27 13:24:36 UTC

Description jritenou 2016-07-18 20:17:02 UTC
Description of problem:

The command line tools for OpenShift 3 have a dependency on git for STI builds. When pulled from the documented url (https://access.redhat.com/downloads/content/290), you are getting a tar archive of the OSE CLI tools, which does no dependency check.  Since it is not packaged, you an run "oc new-app", which will fail without git installed


Version-Release number of selected component (if applicable): Affects all versions of cli as far as I can tell. 


How reproducible: Always.  


Steps to Reproduce:
1. Download tar archive of CLI tools for Linux on a system without git package
2. Extract & connect to an OSE environment
3. Attempt to create a new app from source

Actual results:

[root@livedvd ~]# oc new-app https://github.com/jritenour/hello-python.git
error: unable to load template file "https://github.com/jritenour/hello-python.git": yaml: line 6: mapping values are not allowed in this context
error: no match for "https://github.com/jritenour/hello-python.git"

The 'oc new-app' command will match arguments to the following types:

  1. Images tagged into image streams in the current project or the 'openshift' project
     - if you don't specify a tag, we'll add ':latest'
  2. Images in the Docker Hub, on remote registries, or on the local Docker engine
  3. Templates in the current project or the 'openshift' project
  4. Git repository URLs or local paths that point to Git repositories

--allow-missing-images can be used to point to an image that does not exist yet.



Expected results: [root@livedvd ~]# oc new-app https://github.com/jritenour/hello-python.git
--> Found image 87d749a (4 weeks old) in image stream "python" in project "openshift" under tag "3.5" for "python"

    Python 3.5 
    ---------- 
    Platform for building and running Python 3.5 applications

    Tags: builder, python, python35, rh-python35

    * The source repository appears to match: python
    * A source build using source code from https://github.com/jritenour/hello-python.git will be created
      * The resulting image will be pushed to image stream "hello-python:latest"
    * This image will be deployed in deployment config "hello-python"
    * Port 8080/tcp will be load balanced by service "hello-python"
      * Other containers can access this service through the hostname "hello-python"

--> Creating resources with label app=hello-python ...
    imagestream "hello-python" created
    buildconfig "hello-python" created
    deploymentconfig "hello-python" created
    service "hello-python" created
--> Success
    Build scheduled, use 'oc logs -f bc/hello-python' to track its progress.
    Run 'oc status' to view your app.

Additional info: Since the oc package isn't "installed" per se, and doesn't to dependency checks, it should perform a check on initial run and advise if git is not installed.

Comment 1 Ben Parees 2016-07-25 14:11:15 UTC
Discussed w/ Cesar.. in the case that you are trying to new-app (or new-build) from a git repo and we couldn't find git, we will tell you explicitly that we could not find git and you need to either:

1) install git (or get it into your path)
2) specify --binary to do setup a binary build (which does not require git)

This will involve adding the --binary flag to new-app, as it currently only exists on new-build.

Comment 2 Cesar Wong 2016-08-01 15:59:12 UTC
Both new-app and new-build currently have a behavior defined when pointed to a directory that is not a git repository or does not have an origin remote defined. They fall back to creating a binary build using the information from that directory. If git is not installed, the behavior should be to treat the directory as input for a binary type of build.

PR https://github.com/openshift/origin/pull/10135

Comment 3 Cesar Wong 2016-08-03 13:18:09 UTC
PR https://github.com/openshift/origin/pull/10135 merged. A fix will be included when OSE is rebased with the latest origin.

Comment 4 Troy Dawson 2016-08-03 19:00:35 UTC
This has been merged and is in OSE v3.3.0.14 or newer.

Comment 6 Dongbo Yan 2016-08-04 09:45:23 UTC
Test with
openshift v3.3.0.14
kubernetes v1.3.0+57fb9ac
etcd 2.3.0+git

reproduce steps:
1.Clone a source code repo to localhost
 $ git clone https://github.com/openshift/ruby-hello-world
2.Remove origin remote url
 $ cd ruby-hello-world
 $ git remote remove origin
3.Create an application via "oc new-app"
 $ oc new-app .
4.Start new build
 $ oc start-build ruby-22-centos7 --from-repo=.
5.Check build status
 
actual result:
I.git is installed--
3.Will create a binary build
5.build is successful
II. git is not installed--
4. Uploading "." at commit "HEAD" as binary input for the build ...
error: the directory "." is not a valid Git repository: git binary not available

Result match with comment2

Comment 7 Dongbo Yan 2016-08-04 09:54:18 UTC
But if git is not installed in local, when I create an application from a remote repo:
 $ oc new-app https://github.com/openshift/ruby-hello-world

output:
error: unable to load template file "https://github.com/openshift/ruby-hello-world": yaml: line 6: mapping values are not allowed in this context
error: no match for "https://github.com/openshift/ruby-hello-world"

The 'oc new-app' command will match arguments to the following types:

  1. Images tagged into image streams in the current project or the 'openshift' project
     - if you don't specify a tag, we'll add ':latest'
  2. Images in the Docker Hub, on remote registries, or on the local Docker engine
  3. Templates in the current project or the 'openshift' project
  4. Git repository URLs or local paths that point to Git repositories

--allow-missing-images can be used to point to an image that does not exist yet.

Actual result doesn't match with comment1

Comment 8 Cesar Wong 2016-08-04 15:43:25 UTC
@Dongbo Yan, 

Regarding comment #6:
What you describe is not the same issue that was described in comment #1. From the description of your output, it seems new-app was able to create a binary build ok. 

You get a new message when you try to do a start-build --from-repo (which expects a git repository). Admittedly, the message could be better. But please open a new bug for it (about the output of the 'oc start-build' command when git is not present). 

Also, if you specify --from-dir instead of --from-repo the build works fine.


Regarding comment #7:
When you pass a URL to new-app we have no way of knowing by just looking at the URL whether it points to a git repository, a template, or something else. Because git is not installed, we don't check whether the URL is a repository and move on to the check of whether it's a template. That's why you get the output that you get. I'm not sure that we can do better than that. However, if you think the output can be better, please open a separate bug for that as well.

Comment 9 Dongbo Yan 2016-08-05 09:52:36 UTC
Cesar, hi

Correct my test steps:
1.Make sure git is not installed
 $ rpm -e --nodeps git
2.Clone a source code repo to localhost
 $ git clone https://github.com/openshift/ruby-hello-world
3.Create an application via "oc new-app"
 $ cd ruby-hello-world
 $ oc new-app .

result:
will create a binary build

this bug is fixed

Will file a bug about the output of "oc start-build" from a repo

Comment 10 Cesar Wong 2016-08-05 14:13:20 UTC
Dongbo Yan, 
I submitted a new PR to display a warning that git is not installed. That way at least there is an indication of what happened when you point to a remote repository (comment #7).

https://github.com/openshift/origin/pull/10226

Comment 11 Dongbo Yan 2016-08-09 09:13:21 UTC
Test with 
openshift v3.3.0.17
kubernetes v1.3.0+507d3a7
etcd 2.3.0+git

If git is not installed, create a application from remote repo:
 $ oc new-app https://github.com/openshift/ruby-hello-world

always can get the output:
warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories.

Comment 13 errata-xmlrpc 2016-09-27 09:40:47 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:1933


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