Bug 1709945

Summary: Builds fail to commit/push if registries are whitelisted
Product: OpenShift Container Platform Reporter: Nalin Dahyabhai <nalin>
Component: BuildAssignee: Nalin Dahyabhai <nalin>
Status: CLOSED DUPLICATE QA Contact: Wenjing Zheng <wzheng>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.1.0CC: adam.kaplan, aos-bugs, vzharov, wzheng, xtian
Target Milestone: ---   
Target Release: 4.2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1709985 (view as bug list) Environment:
Last Closed: 2019-05-17 08:20:44 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:
Bug Depends On:    
Bug Blocks: 1709985    

Description Nalin Dahyabhai 2019-05-14 15:35:22 UTC
Description of problem:
Per https://github.com/openshift/builder/issues/71, when the the image policy defined in images.config.openshift.io/cluster whitelists the set of registries from which we're allowed to push images, the generated policy.json defaults to disallowing all transports, which prevents the builder from committing or pushing a new image.

Version-Release number of selected component (if applicable):
4.1.0-rc.0

How reproducible:
Always

Steps to Reproduce:
1. Set a cluster spec of:
  allowedRegistriesForImport:
  - domainName: registry.redhat.io
    insecure: false
  - domainName: quay.io
    insecure: false
  - domainName: registry.access.redhat.com
    insecure: false
  registrySources:
    allowedRegistries:
    - registry.redhat.io
    - registry.access.redhat.com
    - image-registry.openshift-image-registry.svc:5000
    - quay.io
  allowedRegistriesForImport:
  - domainName: registry.redhat.io
    insecure: false
  - domainName: quay.io
    insecure: false
  - domainName: registry.access.redhat.com
    insecure: false
  registrySources:
    allowedRegistries:
    - registry.redhat.io
    - registry.access.redhat.com
    - image-registry.openshift-image-registry.svc:5000
    - quay.io
2. Start a build.

Actual results:
The generated policy.json looks like:
{"default":[{"type":"reject"}],"transports":{"atomic":{"image-registry.openshift-image-registry.svc:5000":[{"type":"insecureAcceptAnything"}],"quay.io":[{"type":"insecureAcceptAnything"}],"registry.access.redhat.com":[{"type":"insecureAcceptAnything"}],"registry.redhat.io":[{"type":"insecureAcceptAnything"}]},"docker":{"image-registry.openshift-image-registry.svc:5000":[{"type":"insecureAcceptAnything"}],"quay.io":[{"type":"insecureAcceptAnything"}],"registry.access.redhat.com":[{"type":"insecureAcceptAnything"}],"registry.redhat.io":[{"type":"insecureAcceptAnything"}]}}}

The build fails with:
error: build error: error copying layers and metadata for container "ceed796969e4947a471e4c866606d1fb5067055f7c0d8d9e3b174e3906fa37d7": Source image rejected: Running image containers-storage:ruby-working-container is rejected by policy.

Expected results:
Regardless of the spec, the builder should not fail to commit an image, or push an image because local storage is not mentioned in the policy.json.

Comment 1 Adam Kaplan 2019-05-14 16:18:19 UTC
PR: https://github.com/openshift/builder/pull/72

Comment 2 Xiaoli Tian 2019-05-17 08:20:44 UTC
Close this bug since the fix is already in 4.1.0 and will be in 4.2.0

*** This bug has been marked as a duplicate of bug 1709985 ***