Fix /admin/sidekiq not loading CSS assets in Cloud Native GitLab
What does this MR do and why?
In GitLab 14.3, we added a workaround in !70113 (merged) to disable the Sendfile interface for Sidekiq assets. This workaround deleted the HTTP_X_SENDFILE_TYPE header, which signaled to Rack not to use the Sendfile interface.
Sidekiq bundles its own CSS and JavaScript assets in the gem, and
registers these via Rack::Static By default, Rack::Sendfile will use
the Sendfile interface if available to offload the sending to Workhorse
However, Workhorse might not have these assets, as they are bundled with
the installed Ruby gem.
However, with the upgrade to Rack v2.2.20+, the HTTP_X_SENDFILE_TYPE is
ignored. Rails will always use the Sendfile interface if the
body responds to to_path. In this case, Rack::Static uses Rack::Files, which responds to to_path.
To work around this issue, we remove that header and read the file content directly to restore the body that Rack::Sendfile emptied.
References
Relates to https://gitlab.com/gitlab-com/gl-infra/production/-/issues/20862
How to set up and validate locally
- Check out this branch.
- Restart GDK
gdk restart - Watch Workhorse logs (e.g.
gdk tail gitlab-workhorse | grep sidekiq). - In your browser, click on Inspect. Click
Disable cacheto make sure your browser loads assets again. - Visit
/admin/sidekiqwith this branch.
Before
You'll see logs like this:
2025-11-18_20:03:46.34439 gitlab-workhorse : {"correlation_id":"01KAC91VG45H022G8A7ETH0HWR","file":"/Users/stanhu/gitlab/gdk-ee/gitlab/vendor/gems/sidekiq/web/assets/stylesheets/bootstrap.css","level":"info","method":"GET","msg":"Send file","time":"2025-11-18T12:03:46-08:00","uri":"/admin/sidekiq/stylesheets/bootstrap.css"}
The Send file shows that Workhorse is actually sending these files.
After
These logs are gone.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.