Extroverted Introspection

Me looking at new things

Gitlab CI: Clashing Sidekiqs

For a few months now I have been wondering about occasional hickups in my Gitlab setup. I run both Gitlab and Gitlab CI on my server, along with a number of other Rails-based applications.

Since I could mostly relate these to the creation of new repository, which is something I don’t do that often, I didn’t care that much about it.

But then today it happened again and, having some time on my hands, I decided to finally investigate. As it turns out, it was a problem with both Gitlab and its CI using the (wonderful) Sidekiq gem for asynchronous job execution. And both instances tried to use the same Redis instance, getting hopelessly tangled in the process.

Luckily, this kind of situation can be easily solved with a custom initializer. Just create a new file, config/initializers/sidekiq.rb in each project, with the following content:

config/initializers/sidekiq.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
require 'sidekiq'

redisConfig = {
  namespace: 'Gitlab', # adapt name for each project
  url: 'redis://127.0.0.1:6379/1' # replace '1' with a unique number
}

Sidekiq.configure_client do |config|
  config.redis = redisConfig
end

Sidekiq.configure_server do |config|
  config.redis = redisConfig
end

Technically speaking, the namespace is not required but I think it’s a good idea nonetheless.