Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1943150

Summary: Incorrect Image name referred for IBM Power images (-i option) while pruning source index
Product: OpenShift Container Platform Reporter: Apoorva Jagtap <apjagtap>
Component: DocumentationAssignee: Alex Dellapenta <adellape>
Status: CLOSED CURRENTRELEASE QA Contact: kuiwang
Severity: medium Docs Contact: Vikram Goyal <vigoyal>
Priority: unspecified    
Version: 4.6CC: adellape, aos-bugs, jokerman
Target Milestone: ---   
Target Release: ---   
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-04-01 15:03:52 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 Apoorva Jagtap 2021-03-25 13:25:22 UTC
Document URL: 
- https://docs.openshift.com/container-platform/4.6/operators/admin/olm-restricted-networks.html#olm-pruning-index-image_olm-restricted-networks
- https://docs.openshift.com/container-platform/4.7/operators/admin/olm-restricted-networks.html#olm-pruning-index-image_olm-restricted-networks

Section Name: Pruning an index image (Step 4)

Describe the issue: 

As per the command in step 4, with option `-i`, we are referring to `registry.redhat.io/openshift4/ose-operator-registry/redhat-operator-index:v4.x`.
- There is no such image found in 'registry.redhat.io'.

~~~
4. Run the following command to prune the source index of all but the specified packages:

$ opm index prune \
    -f registry.redhat.io/redhat/redhat-operator-index:v4.7 \
    -p advanced-cluster-management,jaeger-product,quay-operator \
    -t <target_registry>:<port>/<namespace>/redhat-operator-index:v4.7 \
    -i registry.redhat.io/openshift4/ose-operator-registry/redhat-operator-index:v4.7 
~~~ 

Suggestions for improvement: 

We might need to modify the image name to 'registry.redhat.io/openshift4/ose-operator-registry:v4.x'

Additional information: 

* I could observe a closed bug [1], wrt 'Image Registry update for Z and Power'.
- As per the https://bugzilla.redhat.com/show_bug.cgi?id=1894382#c5 on the bz, it appears that we were aiming to have `-i registry.redhat.io/openshift4/ose-operator-registry:v4.6` added, however, the https://github.com/openshift/openshift-docs/pull/28642/files modifies image name to 'registry.redhat.io/openshift4/ose-operator-registry/{index-image}'

Comment 1 Alex Dellapenta 2021-03-26 19:38:54 UTC
Fixing via https://github.com/openshift/openshift-docs/pull/31013.

Looking for QE review.

Comment 2 kuiwang 2021-03-29 03:03:26 UTC
HI Alex,

  the comment left on PR. There are few issues. please check it.

here is the copy of the comment I left.
---
I try the upstream and downstream because you set registry-image with different value for upstream and downstream.

For downstream, the command works. 
```console
[root@preserve-olm-env operator-registry]#opm index prune -f registry.redhat.io/redhat/redhat-operator-index:v4.7 -p advanced-cluster-management -i registry.redhat.io/openshift4/ose-operator-registry:v4.7 -t quay.io/kuiwang/roi-index:v4.7
INFO[0000] pruning the index                             packages="[advanced-cluster-management]"
INFO[0000] Pulling previous image registry.redhat.io/redhat/redhat-operator-index:v4.7 to get metadata  packages="[advanced-cluster-management]"
INFO[0000] running /usr/bin/podman pull registry.redhat.io/redhat/redhat-operator-index:v4.7  packages="[advanced-cluster-management]"
INFO[0001] running /usr/bin/podman pull registry.redhat.io/redhat/redhat-operator-index:v4.7  packages="[advanced-cluster-management]"
INFO[0002] Getting label data from previous image        packages="[advanced-cluster-management]"
INFO[0002] running podman inspect                        packages="[advanced-cluster-management]"
INFO[0003] running podman create                         packages="[advanced-cluster-management]"
INFO[0003] running podman cp                             packages="[advanced-cluster-management]"
INFO[0008] running podman rm                             packages="[advanced-cluster-management]"
INFO[0009] deleting packages                             pkg=3scale-operator
INFO[0009] packages: [3scale-operator]                   pkg=3scale-operator
INFO[0010] deleting packages                             pkg=amq-broker
INFO[0010] packages: [amq-broker]                        pkg=amq-broker
INFO[0010] deleting packages                             pkg=amq-broker-lts
INFO[0010] packages: [amq-broker-lts]                    pkg=amq-broker-lts
INFO[0010] deleting packages                             pkg=amq-online
INFO[0010] packages: [amq-online]                        pkg=amq-online
...
INFO[0014] deleting packages                             pkg=web-terminal
INFO[0014] packages: [web-terminal]                      pkg=web-terminal
INFO[0014] deleting packages                             pkg=windows-machine-config-operator
INFO[0014] packages: [windows-machine-config-operator]   pkg=windows-machine-config-operator
INFO[0014] Generating dockerfile                         packages="[advanced-cluster-management]"
INFO[0014] writing dockerfile: index.Dockerfile232098483  packages="[advanced-cluster-management]"
INFO[0014] running podman build                          packages="[advanced-cluster-management]"
INFO[0014] [podman build --format docker -f index.Dockerfile232098483 -t quay.io/kuiwang/roi-index:v4.7 .]  packages="[advanced-cluster-management]"
```

But when I check the draft doc https://deploy-preview-31013--osdocs.netlify.app/openshift-enterprise/latest/operators/admin/olm-restricted-networks.html#olm-pruning-index-image_olm-restricted-networks, I find the command is the following
```console
$ opm index prune \
    -f registry.redhat.io/redhat/redhat-operator-index:vBranch Build \
    -p advanced-cluster-management,jaeger-product,quay-operator \
    [-i registry.redhat.io/openshift4/ose-operator-registry:v4.7] \
    -t <target_registry>:<port>/<namespace>/redhat-operator-index:vBranch Build 
``` 
There is vBranch Build. It seem the variable is not replaced.

For upstream, the command does not work because the quay.io/operator-framework/upstream-community-operators:latest       seems has problem
```console
[root@preserve-olm-env operator-registry]# opm index prune -f quay.io/operator-framework/upstream-community-operators:latest -p etcd -i quay.io/openshift/origin-operator-registry:4.7.0 -t quay.io/kuiwang/community-index:v4.7
INFO[0000] pruning the index                             packages="[etcd]"
INFO[0000] Pulling previous image quay.io/operator-framework/upstream-community-operators:latest to get metadata  packages="[etcd]"
INFO[0000] running /usr/bin/podman pull quay.io/operator-framework/upstream-community-operators:latest  packages="[etcd]"
INFO[0001] running /usr/bin/podman pull quay.io/operator-framework/upstream-community-operators:latest  packages="[etcd]"
INFO[0002] Getting label data from previous image        packages="[etcd]"
INFO[0002] running podman inspect                        packages="[etcd]"
Error: index image quay.io/operator-framework/upstream-community-operators:latest missing label operators.operatorframework.io.index.database.v1
Usage:
  opm index prune [flags]

Flags:
  -i, --binary-image opm        container image for on-image opm command
  -c, --container-tool string   tool to interact with container images (save, build, etc.). One of: [docker, podman] (default "podman")
  -f, --from-index string       index to prune
      --generate                if enabled, just creates the dockerfile and saves it to local disk
  -h, --help                    help for prune
  -d, --out-dockerfile string   if generating the dockerfile, this flag is used to (optionally) specify a dockerfile name
  -p, --packages strings        comma separated list of packages to keep
      --permissive              allow registry load errors
  -t, --tag string              custom tag for container image being built

Global Flags:
      --skip-tls   skip TLS certificate verification for container image registries while pulling bundles or index

[root@preserve-olm-env operator-registry]# 
```
---

Comment 3 Alex Dellapenta 2021-03-30 17:30:02 UTC
Updated PR to address QE feedback: https://github.com/openshift/openshift-docs/pull/31013

Comment 4 kuiwang 2021-03-31 01:41:15 UTC
verify it for upstream beside downstream. LGTM
--
[root@preserve-olm-env operator-registry]# opm index prune -f quay.io/operatorhubio/catalog:latest -p etcd -i quay.io/openshift/origin-operator-registry:4.7.0 -t quay.io/kuiwang/community-index:v4.7
INFO[0000] pruning the index                             packages="[etcd]"
INFO[0000] Pulling previous image quay.io/operatorhubio/catalog:latest to get metadata  packages="[etcd]"
INFO[0000] running /usr/bin/podman pull quay.io/operatorhubio/catalog:latest  packages="[etcd]"
INFO[0001] running /usr/bin/podman pull quay.io/operatorhubio/catalog:latest  packages="[etcd]"
INFO[0002] Getting label data from previous image        packages="[etcd]"
INFO[0002] running podman inspect                        packages="[etcd]"
INFO[0002] running podman create                         packages="[etcd]"
INFO[0002] running podman cp                             packages="[etcd]"
INFO[0004] running podman rm                             packages="[etcd]"
INFO[0004] deleting packages                             pkg=akka-cluster-operator
INFO[0004] packages: [akka-cluster-operator]             pkg=akka-cluster-operator
INFO[0004] deleting packages                             pkg=anchore-engine
INFO[0004] packages: [anchore-engine]                    pkg=anchore-engine
INFO[0004] deleting packages                             pkg=api-operator
INFO[0004] packages: [api-operator]                      pkg=api-operator
INFO[0005] deleting packages                             pkg=apicast-community-operator
INFO[0005] packages: [apicast-community-operator]        pkg=apicast-community-operator
...
INFO[0026] deleting packages                             pkg=zoperator
INFO[0026] packages: [zoperator]                         pkg=zoperator
INFO[0026] Generating dockerfile                         packages="[etcd]"
INFO[0026] writing dockerfile: index.Dockerfile512153261  packages="[etcd]"
INFO[0026] running podman build                          packages="[etcd]"
INFO[0026] [podman build --format docker -f index.Dockerfile512153261 -t quay.io/kuiwang/community-index:v4.7 .]  packages="[etcd]"
[root@preserve-olm-env operator-registry]# podman images|head -n 3
REPOSITORY                                                                               TAG                IMAGE ID      CREATED         SIZE
quay.io/kuiwang/community-index                                                          v4.7               5b8ea7f22380  34 seconds ago  686 MB
quay.io/operatorhubio/catalog                                                            latest             a1c85c73129b  14 hours ago    107 MB
[root@preserve-olm-env operator-registry]# 
--