Bug 2003696

Summary: Custom 404 503 page failure when import from file
Product: OpenShift Container Platform Reporter: Timothy Rees <trees>
Component: NetworkingAssignee: Miheer Salunke <misalunk>
Networking sub component: router QA Contact: jechen <jechen>
Status: CLOSED NOTABUG Docs Contact:
Severity: high    
Priority: unspecified CC: aos-bugs, hongli, jechen, misalunk, mmasters, snalawad, xsoldaat
Version: 4.9   
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-09-14 16:23:40 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:
Attachments:
Description Flags
yaml file to create custom 404 and 503 pages none

Description Timothy Rees 2021-09-13 13:02:30 UTC
Created attachment 1822771 [details]
yaml file to create custom 404 and 503 pages

Description of problem:

When importing a custom HTTP 404, 503 response from file the ingress controller configured to use the custom map fails to start.


OpenShift release version:

4.9.0-0.nightly-2021-09-10-170926

Cluster Platform:

N/A

How reproducible:

100%


Steps to Reproduce (in detail):

Using the following build of docs; https://deploy-preview-36065--osdocs.netlify.app/openshift-enterprise/latest/networking/ingress-operator?utm_source=github&utm_campaign=bot_dp#nw-customize-ingress-error-pages_configuring-ingress

1. Create error-page-503.http and file=error-page-404.http

cat << EOF > error-page-404.http
"HTTP/1.0 404 Not Found\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n<html>\r\n<head><title>Not Found</title></head>\r\n<body>\r\n<p>Custom error page:The requested document was not found.</p>\r\n</body>\r\n</html>\r\n"
EOF

cat << EOF > error-page-503.http
"HTTP/1.0 503 Service Unavailable\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n<html>\r\n<head><title>Application Unavailable</title></head>\r\n<body>\r\n<p>Custom error page:The requested application is not available.</p>\r\n</body>\r\n</html>\r\n"
EOF

2. Create CM

oc -n openshift-config create configmap my-custom-error-code-pages --from-file=error-page-503.http --from-file=error-page-404.http

3.  Patch ingresscontrollers/default

oc -n openshift-ingress-operator patch ingresscontrollers/default --type=merge --patch='{"spec":{"httpErrorCodePages":{"name":"my-custom-error-code-pages"}}}'

4. Delete default errorpages CM

oc delete cm default-errorpages -n openshift-ingress


Actual results:

Router pods fail to start, show haproxy errors:

[ALERT] 255/124104 (23) : parsing [/var/lib/haproxy/conf/haproxy.config:43] : errorfile : '/var/lib/haproxy/conf/error_code_pages/error-page-503.http': unabled to parse headers (error offset: 0)
[ALERT] 255/124104 (23) : parsing [/var/lib/haproxy/conf/haproxy.config:44] : errorfile : '/var/lib/haproxy/conf/error_code_pages/error-page-404.http': unabled to parse headers (error offset: 0)
[ALERT] 255/124104 (23) : Error(s) found in configuration file : /var/lib/haproxy/conf/haproxy.config
[ALERT] 255/124104 (23) : Fatal errors found in configuration.


Expected results:

Router pods to start and custom error pages to display.

Impact of the problem:

All applications served by respective ingress are offline.

Additional info:

When creating the pages using a yaml import (attached), the customized pages work as expected.


** Please do not disregard the report template; filling the template out as much as possible will allow us to help you. Please consider attaching a must-gather archive (via `oc adm must-gather`). Please review must-gather contents for sensitive information before attaching any must-gathers to a bugzilla report.  You may also mark the bug private if you wish.

Comment 1 Miheer Salunke 2021-09-13 16:02:05 UTC
I am not sure

Comment 2 Miheer Salunke 2021-09-13 16:02:45 UTC
Please ignore my previous comment

Comment 3 Miheer Salunke 2021-09-13 16:20:54 UTC
Putting an http response in inverted quotes is wrong

"HTTP/1.0 404 Not Found\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n<html>\r\n<head><title>Not Found</title></head>\r\n<body>\r\n<p>Custom error page:The requested document was not found.</p>\r\n</body>\r\n</html>\r\n"


A http repsonse looks like this ->

https://raw.githubusercontent.com/openshift/router/master/images/router/haproxy/conf/error-page-503.http  ---we ship by default

https://raw.githubusercontent.com/Jonathan-Rosewood/haproxy-custom-errors/master/503.http  --- a custom one



Where is it mentioned to do this ?  I don't see this thing mentioned anywhere

cat << EOF > error-page-404.http
"HTTP/1.0 404 Not Found\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n<html>\r\n<head><title>Not Found</title></head>\r\n<body>\r\n<p>Custom error page:The requested document was not found.</p>\r\n</body>\r\n</html>\r\n"
EOF

cat << EOF > error-page-503.http
"HTTP/1.0 503 Service Unavailable\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n<html>\r\n<head><title>Application Unavailable</title></head>\r\n<body>\r\n<p>Custom error page:The requested application is not available.</p>\r\n</body>\r\n</html>\r\n"
EOF

Comment 4 Miheer Salunke 2021-09-13 17:05:43 UTC
Also as per the doc it should not be HttpErrorCodePages but httpErrorCodePages

$ oc patch -n openshift-ingress-operator ingresscontroller/default --patch '{"spec":{"httpErrorCodePages": "my-custom-error-code-pages"}}' --type=merge

The docs team is still working on this doc so it is work in progress.

Comment 5 Timothy Rees 2021-09-13 17:21:02 UTC
What should the contents of error-page-404.http and error-page-503.http be for the most fundamental, working example? @misalunk

Comment 6 jechen 2021-09-13 20:33:48 UTC
I am not able to reproduce this bug, I tried deleting configmap "my-custom-error-code-pages" from openshift-config namespace first, then I re-created the configmap.    I also tried just delete configmap "default-errorpages" from openshift-ingress namespace.   In both cases, haproxy router was restarted and health check was ok.  Please see attachment "reproduction of bug 2003696"

Comment 8 jechen 2021-09-13 20:37:18 UTC
my error page files:

[jechen@jechen ~]$ cat ./NE-379-test/error-page-503.http 
HTTP/1.0 503 Service Unavailable
Connection: close
Content-Type: text/html

<html>
<head><title>Custom:Application Unavailable</title></head>
<body>
<p>Custom error page:The requested application is not available.</p>
</body>
</html>

[jechen@jechen ~]$ cat ./NE-379-test/error-page-404.http 
HTTP/1.0 404 Not Found
Connection: close
Content-Type: text/html

<html>
<head><title>Custom:Not Found</title></head>
<body>
<p>Custom error page:The requested document was not found.</p>
</body>
</html>

Comment 16 Miciah Dashiel Butler Masters 2021-09-14 16:23:40 UTC
The input in comment 0 is invalid because it uses literal double-quotes and "\r\n" strings.  Bug 2003961 covers the documentation side of things (the documentation seems clear to me, but maybe we could be a little more explicit that the user needs to include HTTP response headers).  Closing as NOTABUG.