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

Bug 1741596

Summary: `oc adm migrate image-references` fails with HTTP 404
Product: OpenShift Container Platform Reporter: Simon Krenger <skrenger>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED WONTFIX QA Contact: zhou ying <yinzhou>
Severity: high Docs Contact:
Priority: high    
Version: 3.11.0CC: akhaire, aos-bugs, jnordell, jokerman, maszulik, mfojtik, sreber
Target Milestone: ---   
Target Release: 3.11.z   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-10-17 13:25:25 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 Simon Krenger 2019-08-15 14:04:57 UTC
Description of problem:

Executing `oc adm migrate image-references` with confirmation results in no changes:

```
$ oc adm migrate image-references myregistry.com/*=docker.io/* --include=deploymentconfigs --all-namespaces=false --confirm
summary: total=1 errors=0 ignored=0 unchanged=1 migrated=0
```

Using `--loglevel=10` shows that a HTTP 404 is generated:

```
  I0815 08:55:27.267252   38750 round_trippers.go:405] PUT https://openshift.internal.xyz.lab.upshift.rdu2.redhat.com:443/apis/apps.openshift.io/__internal/namespaces/random-project/deploymentconfigs/random-thing 404 Not Found in 1 milliseconds
  I0815 08:55:27.267319   38750 round_trippers.go:411] Response Headers:
  I0815 08:55:27.267363   38750 round_trippers.go:414]     Cache-Control: no-store
  I0815 08:55:27.267407   38750 round_trippers.go:414]     Content-Type: application/json
  I0815 08:55:27.267450   38750 round_trippers.go:414]     Content-Length: 174
  I0815 08:55:27.267492   38750 round_trippers.go:414]     Date: Thu, 15 Aug 2019 12:55:27 GMT
  I0815 08:55:27.267548   38750 request.go:897] Response Body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"the server could not find the requested resource","reason":"NotFound","details":{},"code":404}
  I0815 08:55:27.267785 unchanged: -n random-project deploymentconfigs/random-thing
```

Note that the endpoint `/apis/apps.openshift.io/__internal/` is called, which does not exist.

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

```
$ ./oc version
oc v3.11.135
kubernetes v1.11.0+d4cacc0
features: Basic-Auth GSSAPI Kerberos SPNEGO

Server https://openshift.internal.xyz.lab.upshift.rdu2.redhat.com:443
openshift v3.11.135
kubernetes v1.11.0+d4cacc0
```

How reproducible:

Always


Steps to Reproduce:
1. `oc run nginx --image=docker.io/bitnami/nginx`
2. `oc adm migrate image-references docker.io/*=internal-registry.example.com/* --include=deploymentconfigs --all-namespaces=false ` => Looks good
3. `oc adm migrate image-references docker.io/*=internal-registry.example.com/* --include=deploymentconfigs --all-namespaces=false --confirm`

Actual results:

No changes:

```
$ oc adm migrate image-references docker.io/*=internal-registry.example.com/* --include=deploymentconfigs --all-namespaces=false --confirm
summary: total=1 errors=0 ignored=0 unchanged=1 migrated=0
$ oc get dc nginx -o yaml | grep "image:"
      - image: docker.io/bitnami/nginx
```

Also, `--loglevel=10` shows the HTTP 404 error.

Expected results:

```
$ ./oc adm migrate image-references docker.io/*=internal-registry.example.com/* --include=deploymentconfigs --all-namespaces=false --confirm
summary: total=1 errors=0 ignored=0 unchanged=0 migrated=1
[quicklab@master-0 ~]$ oc get dc nginx -o yaml | grep "image:"
      - image: internal-registry.example.com/bitnami/nginx
```

Additional info:

Bug is fixed in `oc` version 4.1 or higher. Customer can use this as a workaround.

Bug seems to be in this file, because the internal client is still used: https://github.com/openshift/origin/blob/release-3.11/pkg/oc/cli/admin/migrate/images/imagerefs.go#L25