Only check optional ActionCable Redis instance if necessary

What does this MR do and why?

!214008 (merged) aadded Gitlab::Redis::ActionCable to ALL_CLASSES, which caused the Admin Dashboard to fail with a Redis connection error when redis.action_cable.yml is not configured.

On an Omnibus instance, it's possible to configure Redis-specific instances and disable the default Redis server:

redis['enable'] = false
gitlab_rails['redis_cache_instance'] = 'redis://localhost'
gitlab_rails['redis_queues_instance'] = 'redis://localhost'
gitlab_rails['redis_actioncable_instance'] = 'redis://localhost'
gitlab_rails['redis_shared_state_instance'] = 'redis://localhost'

Prior to GitLab 18.7.0, this configuration worked fine. However, after !214008 (merged) gitlab_rails['redis_host'] must be configured or the /admin page would throw a 500 error because the default Redis server was not available.

To avoid this error, introduce an active? method to determine if a Redis instance is configured and available:

  • Wrapper base class: Returns true by default (all Redis instances are active)
  • ActionCable: Returns false if redis.action_cable.yml doesn't exist
  • Dashboard & Health Checks: Only include active Redis instances when collecting versions or creating health checks

This allows ActionCable to be optional without breaking deployments where it's not configured.

Relates to https://gitlab.com/gitlab-com/request-for-help/-/work_items/4037

How to set up and validate locally

On an Omnibus instance:

  1. Run Redis in one window via /opt/gitlab/embedded/bin/redis-server.
  2. Add this to /etc/gitlab/gitlab.rb:
redis['enable'] = false
gitlab_rails['redis_cache_instance'] = 'redis://localhost'
gitlab_rails['redis_queues_instance'] = 'redis://localhost'
gitlab_rails['redis_actioncable_instance'] = 'redis://localhost'
gitlab_rails['redis_shared_state_instance'] = 'redis://localhost'
  1. Run gitlab-ctl reconfigure.
  2. Visit the /admin page and get a 500 error.
  3. Also run curl "http://localhost:8080/-/readiness?all=1" | jq and check that this error is present:
  "action_cable_check": [
    {
      "status": "failed",
      "message": "unexpected Action_cable check result: No such file or directory - connect(2) for /var/opt/gitlab/redis/redis.socket (unix:///var/opt/gitlab/redis/redis.socket)"
    }

As root, apply this patch:

curl -o /tmp/config.patch https://gitlab.com/gitlab-org/gitlab/-/merge_requests/219019.diff
cd /opt/gitlab/embedded/service/gitlab-rails
patch -p1 < /tmp/config.patch
gitlab-ctl restart puma

Repeat steps 4 and 5 and verify no error.

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