Bug 1925148

Summary: Shouldn't create the redundant imagestream when use `oc new-app --name=testapp2 -i ` with exist imagestream
Product: OpenShift Container Platform Reporter: zhou ying <yinzhou>
Component: BuildAssignee: Alice Rum <irum>
Status: CLOSED ERRATA QA Contact: XiuJuan Wang <xiuwang>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.7CC: adam.kaplan, aos-bugs, jokerman, mfojtik, nagrawal
Target Milestone: ---   
Target Release: 4.8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-07-27 22:41:34 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 zhou ying 2021-02-04 13:51:33 UTC
Description of problem:
When use `oc new-app --name -i ` to reference an exist imagestream should not create a new imagestream 


Version-Release number of selected component (if applicable):
[root@dhcp-140-138 ~]# oc version
Client Version: 4.7.0-202102032256.p0-c66c03f
Server Version: 4.7.0-0.nightly-2021-02-03-165316
Kubernetes Version: v1.20.0+e761892

How reproducible:
Always

Steps to Reproduce:
1) Use `oc new-app openshift/deployment-example ` to create an application ;
2) Use the prior imagestream to create a new application :
    `oc new-app --name=apptest -i deployment-example` 


Actual results:
1) Create the first imagestream:
[zhouying@dhcp-140-138 ~]$ oc get is
NAME                 IMAGE REPOSITORY                                                             TAGS     UPDATED
deployment-example   image-registry.openshift-image-registry.svc:5000/testp2/deployment-example   latest   9 seconds ago

2) Will create a new imagestream , but no app reference the new imagestream, the new deploy still use the prior imagestream.
[zhouying@dhcp-140-138 ~]$ oc new-app --name=apptest -i deployment-example
--> Found image 1c839d8 (5 years old) in image stream "testp2/deployment-example" under tag "latest" for "deployment-example"

--> Creating resources ...
    imagestreamtag.image.openshift.io "apptest:latest" created
    deployment.apps "apptest" created
    service "apptest" created
--> Success
    Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
     'oc expose service/apptest' 
    Run 'oc status' to view your app.

[zhouying@dhcp-140-138 ~]$ oc get is 
NAME                 IMAGE REPOSITORY                                                             TAGS     UPDATED
apptest              image-registry.openshift-image-registry.svc:5000/testp2/apptest              latest   21 minutes ago
deployment-example   image-registry.openshift-image-registry.svc:5000/testp2/deployment-example   latest   37 minutes ago

Expected results:
2) No need to create the redundant imagestream, the new deploy still reference the prior imagestream:
[zhouying@dhcp-140-138 ~]$ oc get deploy apptest -o yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "2"
    image.openshift.io/triggers: '[{"from":{"kind":"ImageStreamTag","name":"deployment-example:latest","namespace":"testp2"},"fieldPath":"spec.template.spec.containers[?(@.name==\"apptest\")].image"}]'
    openshift.io/generated-by: OpenShiftNewApp
  creationTimestamp: "2021-02-04T13:07:39Z"


Additional info:

Comment 5 XiuJuan Wang 2021-03-23 07:23:11 UTC
Build oc client from pr code. Can't reproduce the bug issue now, when reference ImageStream already exists, no new ImageStream is created.
And no regression issue found.

$ ./oc new-app openshift/deployment-example
$ ./oc new-app --name=apptest -i deployment-example
--> Found image 1c839d8 (5 years old) in image stream "xiuwang/deployment-example" under tag "latest" for "deployment-example"


--> Creating resources ...
    deployment.apps "apptest" created
    service "apptest" created
--> Success
    Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
     'oc expose service/apptest' 
    Run 'oc status' to view your app.

Comment 8 XiuJuan Wang 2021-04-12 03:10:49 UTC
Can't reproduce the bug issue now, when reference ImageStream already exists, no new ImageStream is created. 
oc client version 4.8.0-0.nightly-2021-04-09-222447.

$oc new-app openshift/deployment-example
$oc new-app --name=apptest -i deployment-example
--> Found image 1c839d8 (5 years old) in image stream "xiuwang/deployment-example" under tag "latest" for "deployment-example"


--> Creating resources ...
    deployment.apps "apptest" created
    service "apptest" created
--> Success
    Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
     'oc expose service/apptest' 
    Run 'oc status' to view your app.

Comment 11 errata-xmlrpc 2021-07-27 22:41:34 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 (Moderate: OpenShift Container Platform 4.8.2 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-2021:2438