Bug 1390139 - Failed to output in yaml or json format when set image with local dry run
Summary: Failed to output in yaml or json format when set image with local dry run
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 3.4.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 3.9.0
Assignee: Juan Vallejo
QA Contact: Xingxing Xia
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-31 09:55 UTC by XiaochuanWang
Modified: 2018-09-10 16:22 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: Error message contained misleading information when attempting to use `oc set image ...` with the `--local` flag. Consequence: Users were given the impression that <resource> / <name> pairs could be given as resource arguments with the `oc set image` command, while using the `--local` flag. Fix: Update all `oc set ...` commands to return an appropriate error message if a user specifies a <resource> / <name> pair along with the `--local` flag. Return an error message if a user specifies both a `--filename` paratemer, and a <resource> / <name> pair. Result: Error messages should be more clear when attempting to use a <resource> / <name> pair with the `--local` flag in `oc set ...` commands.
Clone Of:
Environment:
Last Closed: 2018-09-10 16:22:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github https://github.com/kubernetes kubernetes pull 36071 0 None None None 2020-08-04 09:23:43 UTC

Description XiaochuanWang 2016-10-31 09:55:44 UTC
Description of problem:
Create is for a project, then oc set image for rc by dry run and try to output to a json or yaml format

Version-Release number of selected component (if applicable):
oc v3.4.0.17+b8a03bc

How reproducible:
Always

Steps to Reproduce:
1.# oc create -f https://raw.githubusercontent.com/openshift-qe/v3-testfiles/master/deployment/dc-with-two-containers.yaml
2. # oc tag docker.io/openshift/hello-openshift xiaocwan-r/ho:latest
3. # oc set image rc dctest-1=xiaocwan-r/ho:latest --local -o yaml (or -o json)

Actual results:
3. 
error: You must provide one or more resources by argument or filename.
Example resource specifications include:
   '-f rsrc.yaml'
   '--filename=rsrc.json'
   'pods my-pod'
   'services'


Expected results:
3. Should print dry run result in correct format

Additional info:
# oc set image rc dctest-1=xiaocwan-r/ho:latest --local -o yaml -f rc.yaml
this is successfully

Comment 1 Juan Vallejo 2016-11-02 14:00:41 UTC
Related PR: https://github.com/openshift/origin/pull/11664

Comment 2 Juan Vallejo 2016-11-02 15:21:21 UTC
Please ignore the PR linked to in https://bugzilla.redhat.com/show_bug.cgi?id=1390139#c1

Actual related PR: https://github.com/openshift/origin/pull/11733

xiaocwan After applying the patch in the linked PR, the command in step 3 returns the error:

> error: resource(s) were provided, but no name, label selector, or --all flag specified

To avoid this, I have to specify the name of the resource whose container image I wish to change:

```
# oc set image rc dctest-1 dctest-1=xiaocwan-r/ho:latest --local -o yaml
```

In the command above, `dctest-1` ends up being the name of the specific replication controller I wish to target. I believe this error was not happening in the command mentioned under "Additional info" because prior to the patch in the PR, running a command locally always ignored any "resource arguments" that were passed, it always attempted to use a resource from a file, even if a filename was not specified by a user. With the patch, this command should now give the error:

```
# oc set image rc dctest-1=xiaocwan-r/ho:latest --local -o yaml -f rc.yaml

error: when paths, URLs, or stdin is provided as input, you may not specify resource arguments as well
```

Comment 3 Juan Vallejo 2016-11-04 13:37:34 UTC
Related bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1388404

Comment 4 Juan Vallejo 2016-12-09 20:06:39 UTC
Upstream PR (https://github.com/kubernetes/kubernetes/pull/36071) has merged. Origin PR (https://github.com/openshift/origin/pull/11733) will merge after the kube 1.6 rebase

Comment 5 Fabiano Franz 2017-01-26 18:39:44 UTC
Adjusting tags to fit the "waiting for upstream rebase" state.

Comment 6 Juan Vallejo 2017-05-12 18:34:32 UTC
Origin PR (https://github.com/openshift/origin/pull/11733) has merged, moving to ON_QA

Comment 8 XiaochuanWang 2017-06-05 08:10:25 UTC
Sorry but this Origin PR (https://github.com/openshift/origin/pull/11733) is closed and it hasn't been merged.

Tested on latest OCP openshift/oc v3.6.94 but still reproduces this issue, is there any PR directly for OCP?

Comment 9 Juan Vallejo 2017-06-14 19:18:15 UTC
(In reply to XiaochuanWang from comment #8)
> Sorry but this Origin PR (https://github.com/openshift/origin/pull/11733) is
> closed and it hasn't been merged.
> 
> Tested on latest OCP openshift/oc v3.6.94 but still reproduces this issue,
> is there any PR directly for OCP?

Changes should be on latest master. Not sure about OCP, but updated PR for this was merged here: https://github.com/openshift/origin/pull/14123

Comment 10 Fabiano Franz 2017-06-14 21:29:20 UTC
Moving to MODIFIED to wait for the next OCP build.

Comment 12 XiaochuanWang 2017-07-05 09:09:02 UTC
The output is still the same with original "Actual result" even specify the rc name, but as per Comment 2 's expected, it needs an explanation error message "error: when paths, URLs, or stdin is provided as input, you may not specify resource arguments as well"

Tested on oc v3.6.133
kubernetes v1.6.1+5115d708d7

Now the output is:
# oc set image rc dctest-1 dctest-1=xiaocwan-r/ho:latest --local -o yaml 
error: You must provide one or more resources by argument or filename.
Example resource specifications include:
   '-f rsrc.yaml'
   '--filename=rsrc.json'
   'pods my-pod'
   'services'

Comment 13 Fabiano Franz 2017-07-07 02:07:38 UTC
I'm going to mark this one UpcomingRelease so that we can discuss about it, since I believe there's something conceptually wrong with the command. 

When running a command like 'set image' with TYPE or TYPE/NAME I need to go get the resource data on the server, *specially* if I want to display the resource entirely with -o yaml. How is that supposed to work with --local, which never goes to the server?

--local is supposed to work fine when the resource is --filename, but by resource type and name we either fail with an error message right away, or try to get it from the cache if not yet expired, otherwise fail.

Comment 14 Jordan Liggitt 2017-07-07 02:18:47 UTC
I would expect --local to be incompatible with "<type> <name>" or "<type>/<name>" usage and to error immediately

Comment 15 Juan Vallejo 2017-07-11 14:49:19 UTC
Related upstream PR: https://github.com/kubernetes/kubernetes/pull/48763

With linked patch, specifying a resource by `<resource>/<name>` pair with a `--local` flag now results in the error:

# oc set image dc/idling-echo idling-tcp-echo=ruby:2.0 --local -o yaml
error: you must specify resources by --filename when --local is set.
Example resource specifications include:
   '-f rsrc.yaml'
   '--filename=rsrc.json'

Specifying both a `<resource>/<name>` pair and a resource by filename (or stdin), still results in the error:

# oc set image -f examples/image-streams/image-streams-centos7.json dc/idling-echo idling-tcp-echo=ruby:2.0  -o yaml
error: resource/name arguments cannot be provided when a path is specified

Comment 16 Juan Vallejo 2017-07-11 15:41:58 UTC
Related origin PR: https://github.com/openshift/origin/pull/15140

Comment 19 Juan Vallejo 2017-08-25 20:01:04 UTC
Marking as "UpcomingRelease"; Upstream PR changes [1] will be brought in as part of the next rebase.

1. https://github.com/kubernetes/kubernetes/pull/48763

Comment 20 Juan Vallejo 2017-09-25 14:19:19 UTC
Upstream PR [1] has merged.
Tagging as UpcomingRelease

1. https://github.com/kubernetes/kubernetes/pull/48763

Comment 21 Fabiano Franz 2017-12-07 18:13:48 UTC
This will be fixed in 3.9, the fix is coming with the upstream rebase that lands there.

Comment 22 Xingxing Xia 2018-01-19 07:14:53 UTC
Tested with oc/OCP v3.9.0-0.21.0.
Negative tests:
$ oc set image # Below prompt is acceptable
error: You must provide one or more resources by argument or filename.
Example resource specifications include:
   '-f rsrc.yaml'
   '--filename=rsrc.json'
   '<resource> <name>'
   '<resource>'

$ oc set image dc/dctest dctest-1=openshift/hello-openshift --local -o yaml # Below prompt is acceptable
error: you must specify resources by --filename when --local is set.
Example resource specifications include:
   '-f rsrc.yaml'
   '--filename=rsrc.json'

Postive tests:
$ oc set image -f dc-with-two-containers.yaml dctest-1=openshift/hello-openshift --local -o yaml # Can get correct YAML content
apiVersion: v1
kind: DeploymentConfig
metadata:
<snipped>
    spec:
      containers:
      - image: openshift/hello-openshift
        name: dctest-1
<snipped>

So bug is fixed. Because PR targets "any of the kube set ... sub-commands", BTW checked `oc set resources` with above cmd format, got similar result


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