Support redis_username for Workhorse Redis ACL authentication
What does this MR do?
GitLab Workhorse cannot connect to an external Redis that uses Redis 6+ ACL authentication (username + password). The gitlab_workhorse['redis_username'] setting already exists in gitlab.rb, but it has no effect: the username is dropped, so Workhorse authenticates with the password only and fails with WRONGPASS.
This MR makes redis_username work by adding it to the generated Redis URL.
Workhorse (Go) reads the username only from the URL (redis.ParseURL), so it has to be embedded there. The Go code and the config.toml template are unchanged, and the existing Password = ... line stays.
Changes
The Redis URL builder is shared, so most of the change is in shared helpers:
redis_uri.rb– adduseras a URI component and renderuser:password(via a sharedURI::Redis.build_userinfohelper).redis_helper.rb– add ausername:parameter tobuild_redis_url(percent-encoded, like the password);encode_redis_passwordis renamed toencode_redis_credentialsince it now encodes both.base.rb– carryusernamethroughredis_credentials/redis_url(TCP and Unix socket).gitlab_workhorse.rb– carryusernamethrough the separate Workhorse Redis instance settings.
The change is additive: username defaults to nil, so password-only and no-auth setups are unchanged.
This MR supports gitlab_workhorse['redis_username']. A global gitlab_rails['redis_username'] (overriding the various instance-specific redis_*_username settings, like redis_password does) does not exist yet and is left as a follow-up.
Result
With gitlab_workhorse['redis_username'] set, the generated config.toml now contains the username in the URL:
[redis]
Password = "secret"
URL = "rediss://my-acl-user:secret@my-redis.example.com:6379/"Specs were added for URL rendering and username propagation. All affected suites pass locally and rubocop is clean.
Related issues
Fixes #9946 (closed). Same pattern as #8559; also unblocks #9939 (KAS ACL).
Follow-ups raised from review: #9950 (closed) (KAS), #9951 (closed) (Sentinel username), #9952 (Container Registry).
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 workflowready for review per the Distribution MR workflow.
- The UBT version and corresponding checksum hash have been updated and referenced in the merge request if applicable. - N/a
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-packagejobs have a green pipeline running against latest commit.- To debug QA failures, refer to the Investigate QA failures section.
- If
config/softwareorconfig/patchesdirectories are changed, make sure thebuild-package-on-all-osjob within theTrigger:ee-packagedownstream pipeline succeeded. - N/A - If you are changing anything SSL related, then the
Trigger:package:fipsmanual job within theTrigger:ee-packagedownstream pipeline must succeed. - N/A - If CI configuration is changed, the branch must be pushed to
dev.gitlab.orgto confirm regular branch builds aren't broken. - N/A
Expected (please provide an explanation if not completing)
- Test plan indicating conditions for success has been posted and passes. !9535 (comment 3492834183)
- Documentation created/updated. - not applicable at the moment, as deployment use case would require have separate Redis for Workhorse => docs should be added when all Redis services support username
- Tests added.
- Integration tests added to GitLab QA. - N/A
- Equivalent MR/issue for the GitLab Chart opened. - N/A
- Validate potential values for new configuration settings. Formats such as integer
10, duration10s, URIscheme://user:passwd@host:portmay require quotation or other special handling when rendered in a template and written to a configuration file. - N/A