Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2102140

Summary: ADD Dockerfile reference is not validating HTTP status code [rhel8]
Product: Red Hat Enterprise Linux 8 Reporter: Simon Reber <sreber>
Component: buildahAssignee: Jindrich Novy <jnovy>
Status: CLOSED ERRATA QA Contact: Joy Pu <ypu>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.6CC: arajan, dornelas, jnovy, pthomas, tsweeney, umohnani, ypu
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: buildah-1.26.4-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2129766 2129767 (view as bug list) Environment:
Last Closed: 2022-11-08 09:16:27 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: 2129766, 2129767    

Description Simon Reber 2022-06-29 11:36:54 UTC
Description of problem:

`buildah` does not respect the HTTP status code returned when using ADD Dockerfile reference. Instead a file with the name is added with the HTTP response code included, showing the 404 error for example.

> $ cat Dockerfile 
> FROM registry.fedoraproject.org/fedora:36
> 
> ADD https://mirror.init7.net/fedora/fedora/linux/releases/36/Server/x86_64/iso/Fedora-Server-netinst-x86_64-36-1.5.foo /
Is the Dockerfile used for testing. Mind that `https://mirror.init7.net/fedora/fedora/linux/releases/36/Server/x86_64/iso/Fedora-Server-netinst-x86_64-36-1.5.foo` does not exist and will report a 404.

> $ buildah build .
> STEP 1/2: FROM registry.fedoraproject.org/fedora:36
> Trying to pull registry.fedoraproject.org/fedora:36...
> Getting image source signatures
> Copying blob 75f075168a24 done  
> Copying config 3a66698e60 done  
> Writing manifest to image destination
> Storing signatures
> STEP 2/2: ADD https://mirror.init7.net/fedora/fedora/linux/releases/36/Server/x86_64/iso/Fedora-Server-netinst-x86_64-36-1.5.foo /
> COMMIT
> Getting image source signatures
> Copying blob b7d796ba5c37 skipped: already exists  
> Copying blob 66b9c08284e9 done  
> Copying config 2638ca3348 done  
> Writing manifest to image destination
> Storing signatures
> --> 2638ca33482
> 2638ca334825bc3979415a7df628c1ffe9277e68dd5cd4239bed7319991aab1f
As shown the `buildah` build is just working and writing the following content into `/Fedora-Server-netinst-x86_64-36-1.5.foo` in the Container.

> [root@9ec83cde9359 /]# cat Fedora-Server-netinst-x86_64-36-1.5.foo 
> <html>
> <head><title>404 Not Found</title></head>
> <body>
> <center><h1>404 Not Found</h1></center>
> <hr><center>nginx/1.18.0</center>
> </body>
> </html>

`docker` on the other hand does validate the HTTP status code and will fail when a 404 is reported.

> # docker --version
> Docker version 1.13.1, build 7d71120/1.13.1

> # docker build .
> Sending build context to Docker daemon 2.048 kB
> Step 1/2 : FROM registry.fedoraproject.org/fedora:36
> Trying to pull repository registry.fedoraproject.org/fedora ... 
> 36: Pulling from registry.fedoraproject.org/fedora
> 75f075168a24: Pull complete 
> Digest: sha256:38813cf0913241b7f13c7057e122f7c3cfa2e7c427dca3194f933d94612e280b
> Status: Downloaded newer image for registry.fedoraproject.org/fedora:36
>  ---> 3a66698e6040
> Step 2/2 : ADD https://mirror.init7.net/fedora/fedora/linux/releases/36/Server/x86_64/iso/Fedora-Server-netinst-x86_64-36-1.5.foo /
> Got HTTP status code >= 400: 404 Not Found


This behavior is causing additional overhead when moving from `docker` to `buildah` for builds (for example in OpenShift Container Platform) as suddenly build succeed even though they should have failed (and therefore Container Images may not work as expected.


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

 - buildah-1.24.2-4
 - buildah --version
   buildah version 1.26.0 (image-spec 1.0.2-dev, runtime-spec 1.0.2-dev)
   - On Fedora 36 where it was validated if the behavior is different but was the same

How reproducible:

 - Always

Steps to Reproduce:
1. Create a `Dockerfile` with the Content shown below

> $ cat Dockerfile 
> FROM registry.fedoraproject.org/fedora:36
> 
> ADD https://mirror.init7.net/fedora/fedora/linux/releases/36/Server/x86_64/iso/Fedora-Server-netinst-x86_64-36-1.5.foo /

2. Run `buildah build ...` command to build the Container Image

Actual results:

Build is completing without error being reported but the actual content downloaded from https://mirror.init7.net/fedora/fedora/linux/releases/36/Server/x86_64/iso/Fedora-Server-netinst-x86_64-36-1.5.foo is not as expected and should not have happen as the file does not exist

Expected results:

Behavior similar to `docker` should be provided and a 404 error should be raised, including having the build failing. Putting a 404 message into a file won't help as this is usually not the expected content.

Additional info:

Comment 14 Joy Pu 2022-08-15 09:21:53 UTC
Can reproduce with buildah-1.26.2-1.module+el8.7.0+15895+a6753917.x86_64. And test with buildah-1.26.4-1.module+el8.7.0+16236+504c84c8.x86_64 it works as expected: 

# buildah build .
STEP 1/2: FROM registry.fedoraproject.org/fedora:36
Trying to pull registry.fedoraproject.org/fedora:36...
Getting image source signatures
Copying blob 62946078034b done  
Copying config 2ecb6df959 done  
Writing manifest to image destination
Storing signatures
STEP 2/2: ADD https://mirror.init7.net/fedora/fedora/linux/releases/36/Server/x86_64/iso/Fedora-Server-netinst-x86_64-36-1.5.foo /
error building at STEP "ADD https://mirror.init7.net/fedora/fedora/linux/releases/36/Server/x86_64/iso/Fedora-Server-netinst-x86_64-36-1.5.foo /": error reading "https://mirror.init7.net/fedora/fedora/linux/releases/36/Server/x86_64/iso/Fedora-Server-netinst-x86_64-36-1.5.foo": invalid response status 404


So set the Tested flag.

Comment 20 Joy Pu 2022-09-05 03:22:12 UTC
Test with buildah-1.27.0-2.module+el8.7.0+16493+89f82ab8.x86_64, and the command can report 404 error message as expected. 
#  buildah build .
STEP 1/2: FROM registry.fedoraproject.org/fedora:36
Trying to pull registry.fedoraproject.org/fedora:36...
Getting image source signatures
Copying blob 62946078034b done  
Copying config 2ecb6df959 done  
Writing manifest to image destination
Storing signatures
STEP 2/2: ADD https://mirror.init7.net/fedora/fedora/linux/releases/36/Server/x86_64/iso/Fedora-Server-netinst-x86_64-36-1.5.foo /
error building at STEP "ADD https://mirror.init7.net/fedora/fedora/linux/releases/36/Server/x86_64/iso/Fedora-Server-netinst-x86_64-36-1.5.foo /": error reading "https://mirror.init7.net/fedora/fedora/linux/releases/36/Server/x86_64/iso/Fedora-Server-netinst-x86_64-36-1.5.foo": invalid response status 404

So set this to verified.

Comment 38 errata-xmlrpc 2022-11-08 09:16:27 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: container-tools:rhel8 security, bug fix, and enhancement 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-2022:7457