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

  1. Check out this branch.
  2. Restart GDK gdk restart
  3. Watch Workhorse logs (e.g. gdk tail gitlab-workhorse | grep sidekiq).
  4. In your browser, click on Inspect. Click Disable cache to make sure your browser loads assets again.
  5. Visit /admin/sidekiq with 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.

Edited by Stan Hu

Merge request reports

Loading