Docs: Add gitlab_workhorse TMPDIR requirement to environment variables
What does this MR do?
Updates the TMPDIR documentation in doc/settings/environment-variables.md to:
- Include
gitlab_workhorse['env']alongsidegitlab_rails['env']in the configuration instructions - Add a note explaining why both values must match
- Add a troubleshooting section for the
400 Bad Requesterror caused by a TMPDIR mismatch
Why?
The current documentation only instructs users to set TMPDIR for gitlab_rails['env']. When object storage with direct upload is enabled, Workhorse generates artifact metadata (metadata.gz) locally using Go's os.TempDir(), which defaults to /tmp. Rails' multipart middleware then validates that the metadata temp file path falls within allowed directories, which includes Ruby's Dir.tmpdir (respecting the TMPDIR environment variable).
If a user follows the current docs and sets only gitlab_rails['env'] = { 'TMPDIR' => '/var/opt/gitlab/tmp' }, Rails expects temp files under /var/opt/gitlab/tmp, but Workhorse still writes metadata to /tmp. This causes Rails to reject artifact uploads with 400 Bad Request and Content-Type: text/plain.
This is the same class of issue documented in gitlab#363701 (closed), which was partially addressed by reverting gitlab!87255 (merged) in gitlab!90083 (merged). However, the os.TempDir() fallback path in workhorse/internal/upload/artifacts_uploader.go still exists for the object storage + direct upload case.
A previous documentation MR (!6152 (closed)) attempted to address this but was closed without merging.
Related issues
- gitlab#363701 (closed) - Original report of this class of issue
- gitlab#593294 - Bug report for the underlying code issue