Bug 1845345 - Unable to build multi-stage image that has a --from=X that matches FROM X
Summary: Unable to build multi-stage image that has a --from=X that matches FROM X
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build
Version: 4.5
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: 4.5.z
Assignee: Adam Kaplan
QA Contact: wewang
URL:
Whiteboard:
Depends On: 1844596
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-06-08 23:58 UTC by Clayton Coleman
Modified: 2020-08-17 20:05 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1843232
Environment:
Last Closed: 2020-08-17 20:05:19 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Github openshift builder pull 166 None closed Bug 1845345: Fix building multi-stage image that has a --from=X 2020-08-17 23:48:02 UTC
Red Hat Product Errata RHBA-2020:3330 None None None 2020-08-17 20:05:40 UTC

Description Clayton Coleman 2020-06-08 23:58:30 UTC
+++ This bug was initially created as a clone of Bug #1843232 +++

One of our tests is a multistage build

FROM scratch as test
USER 1001
FROM %[1]s
COPY --from=test /usr/bin/curl /test/
COPY --from=%[1]s /bin/echo /test/
COPY --from=%[1]s /bin/ping /test/

where %[1]s is "image-registry.openshift-image-registry.svc:5000/openshift/tools:latest"

This fails with 

STEP 5: COPY --from=image-registry.openshift-image-registry.svc:5000/openshift/tools:latest /bin/echo /test/
error: build error: error building at STEP "COPY --from=image-registry.openshift-image-registry.svc:5000/openshift/tools:latest /bin/echo /test/": the stage "image-registry.openshift-image-registry.svc:5000/openshift/tools:latest" has not been built

which is not correct. --from implies image OR stage by name.  I tried to run


FROM scratch as test
USER 1001
FROM %[1]s as other
COPY --from=test /usr/bin/curl /test/
COPY --from=%[1]s /bin/echo /test/
COPY --from=%[1]s /bin/ping /test/

and it still failed.

There was an attempted fix in https://github.com/containers/buildah/pull/2321, but it either didn't make it into 4.5/master or may not cover the whole problem.

Marked as 4.5, this needs to be fixed and backported potentially to 4.4.

--- Additional comment from Adam Kaplan on 2020-06-03 13:59:18 EDT ---

Targeting 4.6.0 - this is not a release blocker. Per Clayton's note, backport is requested to 4.5.z and 4.4.z

--- Additional comment from Adam Kaplan on 2020-06-05 14:00:55 EDT ---

This did not make it to 4.5/master - this merged in buildah master, but is not available in a v1.14.z stream. Openshift/builder currently uses buildah v1.14.2 [1].

Moving this to the Containers team so that we get this backported to buildah v1.14.z, and cloning to ensure this gets into builds.

[1] https://github.com/openshift/builder/blob/release-4.5/go.mod

Comment 1 Tom Sweeney 2020-07-02 20:07:19 UTC
Upstream PR at:  https://github.com/containers/buildah/pull/2401  working on the vendoring into openshift/builder which is proving problematic.

Comment 6 wewang 2020-08-07 04:13:03 UTC
Verified in version:
4.5.0-0.nightly-2020-08-06-215703

Steps:
1. Using Dockerfile as follow to build,build complete
```
FROM docker.io/library/busybox AS build
RUN rm -f /bin/paste
USER 1001
COPY --from=docker.io/library/busybox /bin/paste /test/
```

2. Using Dockerfile as follow to build,build complete
```
FROM docker.io/library/busybox AS test
RUN rm -f /bin/nl
FROM docker.io/library/alpine AS final
COPY --from=docker.io/library/busybox /bin/nl /test/
```

3. Using Dockerfile as follow to build,build failed
```
FROM busybox AS test
USER 1001
FROM busybox AS build
COPY --from=test /bin/cut /test/
COPY --from=build /bin/cp /test/
COPY --from=busybox /bin/paste /test/
```
[root@wangwen work]# oc logs -f build/test-3
STEP 3: FROM busybox AS build
STEP 4: COPY --from=test /bin/cut /test/
STEP 5: COPY --from=build /bin/cp /test/
error: build error: COPY --from=build: no stage or image found with that name

Comment 8 errata-xmlrpc 2020-08-17 20:05:19 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 (OpenShift Container Platform 4.5.6 bug fix 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/RHBA-2020:3330


Note You need to log in before you can comment on or make changes to this bug.