Bug 2041454

Summary: Garbage values accepted for `--reference-policy` in `oc import-image` without any error
Product: OpenShift Container Platform Reporter: Mayur Deore <mdeore>
Component: ocAssignee: Arda Guclu <aguclu>
oc sub component: oc QA Contact: zhou ying <yinzhou>
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: medium CC: maszulik, mfojtik
Version: 4.9   
Target Milestone: ---   
Target Release: 4.11.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-08-10 10:42:31 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mayur Deore 2022-01-17 11:36:14 UTC
Description of problem:
- Garbage values accepted for `--reference-policy` in `oc import-image` without any error. 

- Command 'oc import-image' has an option '--reference-policy' that sets a value of the resulting ImageStreamTag (JSON path tag.referencePolicy.type). '--reference-policy=sources' results in 'tag.referencePolicy:type: Source' whereas '--reference-policy=local' results in 'tag.referencePolicy.type: Local'. Ommitting the option results in 'tag.referencePolicy.type: Source', i.e. 'source' is the default value. So far as documented. So far so good.

- Now the interesting part: Specifying '--reference-policy' with any other value than 'source' or 'local' results in 'tag.referencePolicy.type: Source' - without any warning or error message.

- This is not acceptable. Specifying '--reference-policy' with any other value than 'source' or 'local' must result in an appropriate error message and abort the 'oc import-image' command completely.

- I additionally suggested to also make the command option '--reference-policy' a bit more lenient, i.e. treat the lower and upper case in the given values equally. (E.g. 'local' = 'Local')  This is due to the different use of lower case values and upper case values with the command option '--reference-policy' on the one hand and 'tag.referencePolicy.type' in the resource ImageStreamTag on the other hand.


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


How reproducible:
Easily reproducible using the following steps 

Steps to Reproduce:
1. oc import-image registry.redhat.io/openshift3/jenkins-2-rhel7 --reference-policy=sdfsdfds --confirm 

Actual results:
 - We don't get any error msg and we get `Source` as the default `reference-policy`
~~~
[quicklab@upi-0 ~]$ oc get is jenkins-2-rhel7 -o yaml | grep -A1 referencePolicy
    referencePolicy:
      type: Source
~~~  

Expected results:
 We should get an error msg when we pass garbage values to `--reference-policy=sdfsdfds` other than `source` and `local` and import should fail.

Additional info:
 You can do this test with any image.

Comment 2 zhou ying 2022-04-13 01:59:00 UTC
checked with latest oc client, the issue has fixed:

[root@localhost ~]# oc version --client
Client Version: 4.11.0-202204122151.p0.ge88515d.assembly.stream-e88515d


oc import-image registry.redhat.io/openshift3/jenkins-2-rhel7 --reference-policy=sdfsdfds --confirm
error: valid reference policy values are source or local

Comment 5 errata-xmlrpc 2022-08-10 10:42:31 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 (Important: OpenShift Container Platform 4.11.0 bug fix and security update), 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/RHSA-2022:5069