Bug 1470374 - oc new-app fails if using -i and/or --code
Summary: oc new-app fails if using -i and/or --code
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build
Version: 3.5.0
Hardware: x86_64
OS: Windows
unspecified
low
Target Milestone: ---
: 4.1.0
Assignee: Ben Parees
QA Contact: wewang
URL:
Whiteboard:
: 1534916 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-07-12 20:37 UTC by Fernando Lozano
Modified: 2019-06-04 10:40 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-06-04 10:40:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
summary of oc new-app options tried and results for each one (4.59 KB, text/plain)
2017-07-12 20:37 UTC, Fernando Lozano
no flags Details
logs from 'oc new-app <is>~<url>' this one works as expected (163.25 KB, text/plain)
2017-07-12 20:38 UTC, Fernando Lozano
no flags Details
logs from 'oc new-app -i <is> <url>' this one fails (109.11 KB, text/plain)
2017-07-12 20:39 UTC, Fernando Lozano
no flags Details
logs from 'oc new-app -i <is> --code <url>' this one fails in a different way (6.01 KB, text/plain)
2017-07-12 20:40 UTC, Fernando Lozano
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:0758 0 None None None 2019-06-04 10:40:28 UTC

Description Fernando Lozano 2017-07-12 20:37:25 UTC
Created attachment 1297234 [details]
summary of oc new-app options tried and results for each one

Description of problem:

Installed using the DeveloperSuite installer, checked only CDK 3 and Cygwin

Found that 'oc new-app -i <is> <url>' and 'oc new-app <is>~<url>' give different results: the first one fails, the second one works fine.

Someone asked me to try 'oc new-app -i <is> --code <url>' and it fails in a different way.

These three alternative syntaxes should be the same: create the resources to an S2I build.

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

CDK 3.0-2 (OpenShift v3.5.5.8)

How reproducible:


Steps to Reproduce:
1. start minishift
2. log in to openshift
3. create a project
4. create an application from sources in github

Actual results:

oc new-app fails

Expected results:

application created, build running to completion

Additional info:

Attachments show the logs from each oc new-app variation I tried, including the single one that worked.

Comment 1 Fernando Lozano 2017-07-12 20:38:40 UTC
Created attachment 1297235 [details]
logs from 'oc new-app <is>~<url>' this one works as expected

Comment 2 Fernando Lozano 2017-07-12 20:39:21 UTC
Created attachment 1297236 [details]
logs from 'oc new-app -i <is> <url>' this one fails

Comment 3 Fernando Lozano 2017-07-12 20:40:01 UTC
Created attachment 1297237 [details]
logs from 'oc new-app -i <is> --code <url>' this one fails in a different way

Comment 4 Fernando Lozano 2017-07-12 20:42:29 UTC
Using VirtualBox 5.1.22 but I think this makes no difference. The windows machine has no git client installed but is fully updated from Windows Update.

Comment 5 Ben Parees 2017-07-13 13:16:02 UTC
Actually this might be related to (fixed by) some of Jim's url parsing changes.  Switching assignee.

Comment 6 Jim Minter 2017-07-14 11:53:54 UTC
The url parsing changes don't really touch this.

There are a few rough edges we can improve here but I think the basic behaviour is about as expected.  Fernando, for now your workaround should hopefully be to please install Git :)

Summary: when `git` isn't available locally:

1) oc new-app image~url: works

==> we probably want to maintain that


2) oc new-app -i image url: gives:

warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories.
error: Errors occurred while determining argument types:

https://github.com/openshift/nodejs-ex as a Git repository URL:  git binary not available

https://github.com/openshift/nodejs-ex as a local directory pointing to a Git repository:  stat https://github.com/openshift/nodejs-ex: no such file or directory

Errors occurred during resource creation:
error: unable to load template file "https://github.com/openshift/nodejs-ex": error converting YAML to JSON: yaml: line 29: mapping values are not allowed in this context
error: no match for "https://github.com/openshift/nodejs-ex"

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.

See 'oc new-app -h' for examples.

==> can improve the clumsy messaging but overall right behaviour, I think


3) oc new-app -i image --code url: gives:

warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories.
error: shallow cloning repository "https://github.com/openshift/nodejs-ex" to "/tmp/gen746788874" failed: git binary not available

==> need to investigate if this can be reduced to case (1)

Comment 7 Ben Parees 2017-07-14 11:58:12 UTC
presumably case (1) works because we don't need to clone your repo and analyze it, we know it's a repo and we know what image you want to use it with.

case (2) is hard since we can't be sure you've given us a repo url since we can't successfully clone it.

but case (3) you've told us it's code, and you've told us an image we should use with it (you didn't tied them together with a ~, but in general new-app assumes if you provided a repo and a valid s2i image, that you want to use them together).

so i'm a bit surprised by the result in (3).

Comment 8 Fernando Lozano 2017-07-14 12:41:08 UTC
I understand how case (2) would need git but I was not able to find this dependency stated anywhere in the docs for OpenShift, CDK or the Developers Studio.

The atomic-openshift-clients RPM package state git as a dependency, but whoever install the oc command (OpenShift client) from pre-built binaries may not have this information. IMHO git should not be a mandatory dependency for the oc command.

I agree with Ben that cases (1) and (3) should behave the same. Yes, this is a bit of a corner case, someone using the CLI to start an S2I build without a Git client, but I think this may happen with automation scenarios and developers using cloud-based IDEs. Hey, if I install JBoss Developer Studio I guess I could live without a CLI git client but want to use the OpenShift CLI some times.

For me (developing Red Hat courseware) it is an usability concern: the "~" is hard to read with some fonts, and hard to find with some keyboards. I wanted to use -i and --code in courseware, but don't want to ask students to install git as they won't need it elsewere in the course.

Comment 10 Mangirdas Judeikis 2017-12-05 10:11:09 UTC
Defined expected behaviour for different syntax options:

`oc import-image openshift/ruby-20-centos7:latest --confirm -n openshift`

### Syntax 1. Case 1. Git: True. URL: Remote.
RESULT: All components created. Source build type.
EXPECTATION: OK
`oc new-app openshift/ruby-20-centos7:latest~https://github.com/openshift/ruby-hello-world.git`

### Syntax 1. Case 2. Git: False. URL: Remote. 
RESULT: All components created. Source build type. 
EXPECTATION: OK
`oc new-app openshift/ruby-20-centos7:latest~https://github.com/openshift/ruby-hello-world.git`
```
-bash-4.4# oc new-app openshift/ruby-20-centos7:latest~https://github.com/openshift/ruby-hello-world.git
warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories.
....
```
### Syntax 1. Case 3. GIT: False. URL: HostPath.
RESULT: All components created. BINARY build type.
EXPECTATION: ok
`oc new-app openshift/ruby-20-centos7:latest~/root/app-examples/ruby`
```
warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories.
...
```

### Syntax 1. Case 4. Git: True. URL: HostDir.
RESULT:  (?TBC?)
EXPECTATION: Check if hostDir is valid git - Source. Else - Binary. 
`oc new-app openshift/ruby-20-centos7:latest~/root/app-examples/ruby`

### Syntax 2. Case 1. GIT: True. URL: Remote. 
RESULT: All components created. Source build type.
EXPECTATION: OK
`oc new-app -i ruby-20-centos7:latest https://github.com/openshift/ruby-hello-world.git`

### Syntax 2. Case 2. GIT: False. URL: Remote
RESULT: No components created. We cant investigate remote repo.
EXPECTATION: Create all components same as `Syntax 1. Case 2`
`oc new-app -i ruby-20-centos7:latest https://github.com/openshift/ruby-hello-world.git`
```
warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories.
error: git binary not available
```

### Syntax 2. Case 3. GIT: False. URL: HostPath. 
RESULT:  All components created. BINARY build type. 
EXPECTATION: ok
`oc new-app -i ruby-20-centos7:latest /root/app-examples/ruby`

### Syntax 2. Case 4. GIT: True. URL: HostPath. 
RESULT:  (?TBC?)
EXPECTATION: Check if hostDir is valid git - Source. Else - Binary. 
`oc new-app -i ruby-20-centos7:latest /root/app-examples/ruby`

### Sytnax 3. Case 1. GIT: True. URL: Remote. 
RESULT: All components created. Source build type.
EXPECTATION: ok
`oc new-app -i ruby-20-centos7:latest --code https://github.com/openshift/ruby-hello-world.git`

### Sytnax 3. Case 2. GIT: False. URL: Remote.
RESULT: All components created. Source build type.
EXPECTATION: ok
`oc new-app -i ruby-20-centos7:latest --code https://github.com/openshift/ruby-hello-world.git`

### Sytnax 3. Case 3. GIT: False. URL: HostPath.
RESULT: All components created. Binary build type. 
EXPECTATION: ok
`oc new-app -i ruby-20-centos7:latest --code /root/app-examples/ruby`

### Sytnax 3. Case 4. GIT: True. URL: HostPath. 
RESULT:  (?TBC?)
EXPECTATION: If hostDir - git repo - Source build. Else Binary build.
`oc new-app -i ruby-20-centos7:latest --code /root/app-examples/ruby`

Comment 11 openshift-github-bot 2018-01-12 22:05:01 UTC
Commit pushed to master at https://github.com/openshift/origin

https://github.com/openshift/origin/commit/0b8095d39abe578d5d44f484aa585a766f6edc26
Merge pull request #17457 from mjudeikis/bugzilla_1470374

Automatic merge from submit-queue (batch tested with PRs 17539, 17457).

bug 1470374 - oc new-app behaviour 

oc new-app

`oc import-image openshift/ruby-20-centos7:latest --confirm -n openshift`

### Syntax 1. Case 1. Git: True. URL: Remote.
RESULT: All components created. Source build type.
EXPECTATION: OK
`oc new-app openshift/ruby-20-centos7:latest~https://github.com/openshift/ruby-hello-world.git`

### Syntax 1. Case 2. Git: False. URL: Remote. 
RESULT: All components created. Source build type. 
EXPECTATION: OK
`oc new-app openshift/ruby-20-centos7:latest~https://github.com/openshift/ruby-hello-world.git`
```
-bash-4.4# oc new-app openshift/ruby-20-centos7:latest~https://github.com/openshift/ruby-hello-world.git
warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories.
....
```
### Syntax 1. Case 3. GIT: False. URL: HostPath.
RESULT: All components created. BINARY build type.
EXPECTATION: ok
`oc new-app openshift/ruby-20-centos7:latest~/root/app-examples/ruby`
```
warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories.
...
```

### Syntax 1. Case 4. Git: True. URL: HostDir.
RESULT:  (?TBC?)
EXPECTATION: Check if hostDir is valid git - Source. Else - Binary. 
`oc new-app openshift/ruby-20-centos7:latest~/root/app-examples/ruby`

### Syntax 2. Case 1. GIT: True. URL: Remote. 
RESULT: All components created. Source build type.
EXPECTATION: OK
`oc new-app -i ruby-20-centos7:latest https://github.com/openshift/ruby-hello-world.git`

### Syntax 2. Case 2. GIT: False. URL: Remote
RESULT: No components created. We cant investigate remote repo.
EXPECTATION: Create all components same as `Syntax 1. Case 2`
`oc new-app -i ruby-20-centos7:latest https://github.com/openshift/ruby-hello-world.git`
```
warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories.
error: git binary not available
```

### Syntax 2. Case 3. GIT: False. URL: HostPath. 
RESULT:  All components created. BINARY build type. 
EXPECTATION: ok
`oc new-app -i ruby-20-centos7:latest /root/app-examples/ruby`

### Syntax 2. Case 4. GIT: True. URL: HostPath. 
RESULT:  (?TBC?)
EXPECTATION: Check if hostDir is valid git - Source. Else - Binary. 
`oc new-app -i ruby-20-centos7:latest /root/app-examples/ruby`

### Sytnax 3. Case 1. GIT: True. URL: Remote. 
RESULT: All components created. Source build type.
EXPECTATION: ok
`oc new-app -i ruby-20-centos7:latest --code https://github.com/openshift/ruby-hello-world.git`

### Sytnax 3. Case 2. GIT: False. URL: Remote.
RESULT: All components created. Source build type.
EXPECTATION: ok
`oc new-app -i ruby-20-centos7:latest --code https://github.com/openshift/ruby-hello-world.git`

### Sytnax 3. Case 3. GIT: False. URL: HostPath.
RESULT: All components created. Binary build type. 
EXPECTATION: ok
`oc new-app -i ruby-20-centos7:latest --code /root/app-examples/ruby`

### Sytnax 3. Case 4. GIT: True. URL: HostPath. 
RESULT:  (?TBC?)
EXPECTATION: If hostDir - git repo - Source build. Else Binary build.
`oc new-app -i ruby-20-centos7:latest --code /root/app-examples/ruby`



TODO:
- add tests to cover this case


https://bugzilla.redhat.com/show_bug.cgi?id=1470374

Comment 13 wewang 2018-01-17 07:50:34 UTC
@mjudeikis, Tested  in 
openshift v3.9.0-0.20.0
kubernetes v1.9.1+a0ce1bc657
etcd 3.2.8

apps works using -i and code when git installed, but found 2 issues without git, could you help to check

1. GIT: false. URL: Remote. ,still cannot install components
# oc new-app -i openshift/ruby --code https://github.com/openshift/ruby-hello-world -n git
warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories.
error: shallow cloning repository "https://github.com/openshift/ruby-hello-world" to "/tmp/gen301233882" failed: git binary not available

2.  GIT: False. URL: HostPath,  build failed
  $oc new-app -i openshift/ruby  --code /root/Desktop/ruby-hello-world
  [root@dhcp-128-91 Desktop]# oc get builds
NAME      TYPE      FROM      STATUS                    STARTED                  DURATION
ruby-1    Source              Failed (AssembleFailed)   Less than a second ago   44s
# oc logs build/ruby-1
---> Installing application source ...
mv: cannot stat '/tmp/src/*': No such file or directory
error: build error: non-zero (13) exit code from brew-pulpxxxxx:8888/rhscl/ruby-24-rhel7@sha256:9cfdf4b811axxxxxx

Comment 14 wewang 2018-01-17 07:52:08 UTC
And add a case for the bug ,pls review.

Comment 15 Mangirdas Judeikis 2018-03-06 08:56:36 UTC
WIP... Second might looks like an environmental issue. Validating this again.

Comment 17 wewang 2018-04-26 07:43:14 UTC
Any progress abut the bug?

Comment 18 Ben Parees 2018-04-26 12:39:32 UTC
after much investigation we are leaning towards documenting the behavior and closing it as won't fix.

There are significant differences between the code path of "oc new-app image~repo" and "oc new-app -i=image --code=repo" and it's not worth the effort of trying to reconcile them when the ~ syntax is available to solve the problem.

Comment 19 Ben Parees 2018-04-26 12:40:52 UTC
*** Bug 1534916 has been marked as a duplicate of this bug. ***

Comment 20 wewang 2018-05-14 09:22:35 UTC
@Ben Parees you mean we can use "oc new-app image~repo"  instead of "oc new-app -i=image --code=repo", so the bug can be closed ?

Comment 21 Ben Parees 2018-05-14 15:22:46 UTC
Yes that's what I mean.  We're going to clean up the documentation so we're leaving the bug open until that is done, but we aren't going to change the behavior.

Comment 22 Ben Parees 2019-03-01 22:17:19 UTC
doc clarification/explanation:

https://github.com/openshift/openshift-docs/pull/13937

Comment 25 wewang 2019-03-20 02:50:47 UTC
Since docs already clarify it, so verify it.

Comment 27 errata-xmlrpc 2019-06-04 10:40:18 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-2019:0758


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