Make Puma low-level handler return recommended status code
What does this MR do?
Because of https://github.com/puma/puma/pull/3094, Puma v6.4.0 now returns the status code sent from the low-level handler instead of Puma's recommended status code. This caused malformed URLs to return a 500 error when previously it would return a 400 Bad Request error, which skewing error metrics.
Previously we hard-coded low-level errors to return a 500 error, but now we should adapt this to return the status code recommended by Puma.
Related issues
Relates to gitlab-com/gl-infra/production#16417 (closed)
Related merge requests:
- CNG: gitlab-org/build/CNG!1556 (merged) (this would fix the issue in production)
- GDK: gitlab-development-kit!3371 (merged)
gitlab#426135 (closed) has been created to address this duplication.
How to test locally
With the current /var/opt/gitlab/gitlab-rails/etc/puma.rb
:
$ curl -I 'https://gitlab.example.com/-/merge_requests?sort=created_date&state=<th:t=\"%24{dfb}%23foreach'
HTTP/2 500
server: nginx
date: Mon, 25 Sep 2023 17:11:54 GMT
content-type: text/html; charset=utf-8
content-length: 3037
cache-control: no-cache, no-store, max-age=0, must-revalidate
expires: Fri, 01 Jan 1990 00:00:00 GMT
pragma: no-cache
Now:
- Apply this patch:
curl -o /tmp/puma.patch https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7161.diff && patch -d /opt/gitlab/embedded/cookbooks -p3 < /tmp/puma.patch
. gitlab-ctl reconfigure && gitlab-ctl restart puma
$ curl -I 'https://gitlab.example.com/-/merge_requests?sort=created_date&state=<th:t=\"%24{dfb}%23foreach'
HTTP/2 400
server: nginx
date: Mon, 25 Sep 2023 17:03:51 GMT
Checklist
See Definition of done.
For anything in this list which will not be completed, please provide a reason in the MR discussion.
Required
-
MR title and description are up to date, accurate, and descriptive. -
MR targeting the appropriate branch. -
Latest Merge Result pipeline is green. -
When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow.
For GitLab team members
If you don't have access to this, the reviewer should trigger these jobs for you during the review process.
-
The manual Trigger:ee-package
jobs have a green pipeline running against latest commit. -
If config/software
orconfig/patches
directories are changed, make sure thebuild-package-on-all-os
job within theTrigger:ee-package
downstream pipeline succeeded. -
If you are changing anything SSL related, then the Trigger:package:fips
manual job within theTrigger:ee-package
downstream pipeline must succeed. -
If CI configuration is changed, the branch must be pushed to dev.gitlab.org
to confirm regular branch builds aren't broken.
Expected (please provide an explanation if not completing)
-
Test plan indicating conditions for success has been posted and passes. -
Documentation created/updated. -
Tests added. -
Integration tests added to GitLab QA. -
Equivalent MR/issue for the GitLab Chart opened. -
Validate potential values for new configuration settings. Formats such as integer 10
, duration10s
, URIscheme://user:passwd@host:port
may require quotation or other special handling when rendered in a template and written to a configuration file.