Bug 1470374 - oc new-app fails if using -i and/or --code
oc new-app fails if using -i and/or --code
Status: ASSIGNED
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build (Show other bugs)
3.5.0
x86_64 Windows
unspecified Severity low
: ---
: 3.11.0
Assigned To: Mangirdas Judeikis
wewang
: OnlineStarter
: 1534916 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-07-12 16:37 EDT by Fernando Lozano
Modified: 2018-05-14 17:58 EDT (History)
11 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
summary of oc new-app options tried and results for each one (4.59 KB, text/plain)
2017-07-12 16:37 EDT, 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 16:38 EDT, Fernando Lozano
no flags Details
logs from 'oc new-app -i <is> <url>' this one fails (109.11 KB, text/plain)
2017-07-12 16:39 EDT, 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 16:40 EDT, Fernando Lozano
no flags Details

  None (edit)
Description Fernando Lozano 2017-07-12 16:37:25 EDT
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 16:38 EDT
Created attachment 1297235 [details]
logs from 'oc new-app <is>~<url>' this one works as expected
Comment 2 Fernando Lozano 2017-07-12 16:39 EDT
Created attachment 1297236 [details]
logs from 'oc new-app -i <is> <url>' this one fails
Comment 3 Fernando Lozano 2017-07-12 16:40 EDT
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 16:42:29 EDT
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 09:16:02 EDT
Actually this might be related to (fixed by) some of Jim's url parsing changes.  Switching assignee.
Comment 6 Jim Minter 2017-07-14 07:53:54 EDT
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 07:58:12 EDT
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 08:41:08 EDT
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 05:11:09 EST
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 17:05:01 EST
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 02:50:34 EST
@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 02:52:08 EST
And add a case for the bug ,pls review.
Comment 15 Mangirdas Judeikis 2018-03-06 03:56:36 EST
WIP... Second might looks like an environmental issue. Validating this again.
Comment 17 wewang 2018-04-26 03:43:14 EDT
Any progress abut the bug?
Comment 18 Ben Parees 2018-04-26 08:39:32 EDT
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 08:40:52 EDT
*** Bug 1534916 has been marked as a duplicate of this bug. ***
Comment 20 wewang 2018-05-14 05:22:35 EDT
@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 11:22:46 EDT
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.

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