Support redis_sentinels_username for Workhorse Sentinel ACL authentication

What does this MR do?

GitLab Workhorse cannot authenticate against Redis Sentinel nodes that use Redis 6+ ACL authentication (username + password). Omnibus supports redis_sentinels_password, but has no username counterpart: Workhorse authenticates against the Sentinels with the password only and fails with WRONGPASS.

This MR makes a Sentinel username configurable by adding gitlab_workhorse['redis_sentinels_username'] (and the matching gitlab_rails['redis_workhorse_sentinels_username'] pass-through) and rendering it as SentinelUsername in the Workhorse config.toml.

Workhorse (Go) reads the Sentinel username from a dedicated SentinelUsername config field, so it is deliberately not embedded in the Sentinel URLs — the main Redis username is not the right value for Sentinel auth. The comment in redis_helper.rb introduced in !9535 (merged) is extended to document this.

Changes

The Sentinel settings plumbing is shared, so part of the change is in shared helpers:

  • attributes/default.rb – add redis_sentinels_username defaults for gitlab_workhorse and redis_workhorse_* (both default to nil).
  • gitlab_workhorse.rb (library) – carry sentinels_username through the separate-instance and shared-state settings lists.
  • redis_helper/base.rb – add a redis_sentinels_username reader.
  • redis_helper/gitlab_workhorse.rb – expose sentinelUsername in redis_params.
  • gitlab-workhorse.rb (recipe) / workhorse-config.toml.erb – render SentinelUsername (only when set, so existing configs are byte-identical).
  • gitlab.rb.template – add commented examples next to the existing sentinels_password entries.

The change is additive: redis_sentinels_username defaults to nil and the TOML key is only rendered when set, so password-only and no-auth Sentinel setups are unchanged.

This MR supports the Sentinel username for Workhorse only. The Rails side (resque.yml / cable.yml / redis.<instance>.yml) is left as a follow-up (#9996). KAS and gitlab-exporter have no upstream support for a Sentinel username yet (kascfg.proto has no such field), so they are out of scope — same split as !9535 (merged) / !9538 (merged). The global gitlab_rails['redis_sentinels_username'] fallback was removed again after review feedback, since only Workhorse would consume it for now; it moves to #9996 as well.

Result

With gitlab_workhorse['redis_sentinels_username'] (or gitlab_rails['redis_workhorse_sentinels_username']) set, the generated config.toml now contains the username next to the existing Sentinel settings:

[redis]
Password = "secret"
Sentinel = ["redis://:sentinel-pass@sentinel1:26379"]
SentinelMaster = "gitlab-redis"
SentinelUsername = "my-sentinel-acl-user"
SentinelPassword = "sentinel-pass"

Specs were added for username propagation (workhorse-specific, redis_workhorse_* and redis_shared_state_* paths) and config rendering (with and without username). All affected suites pass locally and rubocop is clean.

Closes #9951 (closed). Follow-up of #9946 (closed) / !9535 (merged); same pattern as #8559.

Follow-ups: #9996 (Rails Sentinel username). Chart equivalent: gitlab-org/charts/gitlab#6555.

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
    • UBT EE pipeline (Trigger:ee-package-ubt) is green - 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-package jobs have a green pipeline running against latest commit.
  • If config/software or config/patches directories are changed, make sure the build-package-on-all-os job within the Trigger:ee-package downstream pipeline succeeded. - N/A
  • If you are changing anything SSL related, then the Trigger:package:fips manual job within the Trigger:ee-package downstream pipeline must succeed. - N/A
  • If CI configuration is changed, the branch must be pushed to dev.gitlab.org to 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. - See the validation report in the MR discussion (scenario 4 run end-to-end, PASS).
  • Documentation created/updated. - Not applicable at the moment; docs should be added when all Redis services support the Sentinel username (same reasoning as !9535 (merged)).
  • Tests added.
  • Integration tests added to GitLab QA. - N/A
  • Equivalent MR/issue for the GitLab Chart opened. - gitlab-org/charts/gitlab#6555
  • Validate potential values for new configuration settings. Formats such as integer 10, duration 10s, URI scheme://user:passwd@host:port may require quotation or other special handling when rendered in a template and written to a configuration file. - The username is a plain string rendered inside quotes in TOML; it is not embedded in URLs (Workhorse reads the dedicated SentinelUsername field), so no percent-encoding is required.
Edited by Norman Debald

Merge request reports

Loading
Loading