Support dedicated Redis connection for registry DB load balancing

What does this MR do?

Part of Container Registry: Database Load Balancing (DLB) (gitlab-org&8591 - closed), which is currently available as an experimental feature on .com.

Following the feature rollout plan, we started by relying on the existing redis.cache Redis connection for the DB load balancing during Phase 1. This was implemented in Expose new registry database load balancing set... (!3942 - merged).

Now, as part of Phase 2, we're adding support for a dedicated redis connection for DB load balancing under redis.loadBalancing, and moving away from relying on the existing redis.cache connection.

This MR adds support for this new redis.loadBalancing config section and updates the existing validations to make sure that we require this to be set for enabling the DB load balancing feature moving forward. The corresponding registry settings are documented here.

This builds on top of another similar change: !3794 (merged).

Related issues

Related to DLB: Expose settings for dedicated Redis connec... (gitlab-org/container-registry#1502 - closed).

How to test

Setup

Follow the steps described in !3942 (merged).

When it gets to the configuration part, make sure to use:

#...
registry:
  redis:
    loadBalancing: # -> `loadBalancing`, not `cache`
      enabled: true
      host: redis-master.default.svc.cluster.local
      port: 6379
# ...

Tests

  • Check the application behavior when providing the correct registry.redis.loadBalancing configuration as show above:
{"go_version":"go1.23.6","instance_id":"baef5218-d8a8-4893-b0cb-062b08986cd6","level":"info","msg":"redis configured successfully for load balancing","service":"registry","time":"2025-03-19T12:25:11.352Z","version":"v4.18.0-gitlab"}
{"go_version":"go1.23.6","instance_id":"baef5218-d8a8-4893-b0cb-062b08986cd6","level":"info","msg":"enabling database load balancing with service discovery","nameserver":"10.244.0.7","port":8600,"record":"db-replica-registry.service.consul","replica_check_interval_s":60,"service":"registry","time":"2025-03-19T12:25:11.352Z","version":"v4.18.0-gitlab"}
  • Test that it fails without it:
#...
registry:
  redis:
    cache: # -> `cache` present, but no `loadBalancing` section
      enabled: true
      host: redis-master.default.svc.cluster.local
      port: 6379
# ...
Error: UPGRADE FAILED: execution error at (gitlab/templates/NOTES.txt:179:3): 
CONFIGURATION CHECKS:

registry:
    Enabling database load balancing requires a Redis connection to be enabled.
    See https://docs.gitlab.com/charts/charts/registry/#redis-for-database-load-balancing

Author checklist

For general guidance, please follow our Contributing guide.

Required

For anything in this list which will not be completed, please provide a reason in the MR discussion.

  • Merge Request Title and Description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • MR has a green pipeline.
  • Documentation created/updated.
  • Tests added/updated, and test plan for scenarios not covered by automated tests.
  • Equivalent MR/issue for omnibus-gitlab opened.

Reviewers checklist

Edited by João Alexandre Cunha

Merge request reports

Loading