From 5ddacac41809d8f7e26674e5352739abb35cd457 Mon Sep 17 00:00:00 2001
From: DJ Mountney <dj@gitlab.com>
Date: Tue, 20 Dec 2016 23:12:59 -0800
Subject: [PATCH 1/4] Add EE sidekiq_cluster configurable for setting up extra
 Sidekiq processes

This allows configuring the settings that were added in: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/922
---
 CHANGELOG.md                                  |  1 +
 .../gitlab-config-template/gitlab.rb.template | 24 ++++++++++
 .../gitlab-ee/attributes/default.rb           |  9 ++++
 .../gitlab-ee/libraries/gitlab-ee.rb          | 44 ++++++++++++++++++
 .../gitlab-ee/libraries/sidekiq_cluster.rb    | 36 +++++++++++++++
 .../gitlab-ee/recipes/config.rb               | 18 ++++++++
 .../gitlab-ee/recipes/default.rb              | 14 ++++--
 .../gitlab-ee/recipes/sidekiq-cluster.rb      | 40 +++++++++++++++++
 .../recipes/sidekiq-cluster_disable.rb        | 20 +++++++++
 .../default/sv-sidekiq-cluster-log-config.erb |  6 +++
 .../default/sv-sidekiq-cluster-log-run.erb    |  2 +
 .../default/sv-sidekiq-cluster-run.erb        | 18 ++++++++
 .../gitlab/libraries/gitlab.rb                |  5 ++-
 spec/chef/recipes/sidekiq-cluster_spec.rb     | 45 +++++++++++++++++++
 spec/libraries/sidekiq_cluster_spec.rb        | 39 ++++++++++++++++
 15 files changed, 315 insertions(+), 6 deletions(-)
 create mode 100644 files/gitlab-cookbooks/gitlab-ee/libraries/gitlab-ee.rb
 create mode 100644 files/gitlab-cookbooks/gitlab-ee/libraries/sidekiq_cluster.rb
 create mode 100644 files/gitlab-cookbooks/gitlab-ee/recipes/config.rb
 create mode 100644 files/gitlab-cookbooks/gitlab-ee/recipes/sidekiq-cluster.rb
 create mode 100644 files/gitlab-cookbooks/gitlab-ee/recipes/sidekiq-cluster_disable.rb
 create mode 100644 files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-log-config.erb
 create mode 100644 files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-log-run.erb
 create mode 100644 files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-run.erb
 create mode 100644 spec/chef/recipes/sidekiq-cluster_spec.rb
 create mode 100644 spec/libraries/sidekiq_cluster_spec.rb

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5964820c1f..c9381e46c9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,7 @@ omnibus-gitlab repository.
 - Adding attribute for gitlab-shell custom hooks f753e1f0
 - Pass websockets through to workhorse for terminal support
 - Add notification for new PostgreSQL version 05dbb3ec
+- Add EE sidekiq_cluster configurable for setting up extra Sidekiq processes
 
 8.14.5
 
diff --git a/files/gitlab-config-template/gitlab.rb.template b/files/gitlab-config-template/gitlab.rb.template
index cf1d8565c0..e695c4aa4a 100644
--- a/files/gitlab-config-template/gitlab.rb.template
+++ b/files/gitlab-config-template/gitlab.rb.template
@@ -463,6 +463,30 @@ external_url 'GENERATED_EXTERNAL_URL'
 # sidekiq['concurrency'] = 25
 
 
+###############################
+# GitLab Sidekiq Cluster (EE) #
+###############################
+
+# GitLab Enterprise Edition allows one to start an extra set of Sidekiq processes
+# besides the default one. These processes can be used to consume a dedicated set
+# of queues. This can be used to ensure certain queues always have dedicated
+# workers, no matter the amount of jobs that need to be processed.
+
+# sidekiq_cluster['enable'] = false
+# sidekiq_cluster['ha'] = false
+# sidekiq_cluster['log_directory'] = "/var/log/gitlab/sidekiq-cluster"
+# sidekiq_cluster['interval'] = 5 # The number of seconds to wait between worker checks
+
+# Each entry in the queue_groups array denotes a group of queues that have to be processed by a
+# Sidekiq process. Multiple queues can be processed by the same process by
+# separating them with a comma within the group entry
+
+# sidekiq_cluster['queue_groups'] = [
+#   "process_commit,post_receive",
+#   "gitlab_shell"
+# ]
+
+
 ################
 # gitlab-shell #
 ################
diff --git a/files/gitlab-cookbooks/gitlab-ee/attributes/default.rb b/files/gitlab-cookbooks/gitlab-ee/attributes/default.rb
index bc53493b3f..cffd065feb 100644
--- a/files/gitlab-cookbooks/gitlab-ee/attributes/default.rb
+++ b/files/gitlab-cookbooks/gitlab-ee/attributes/default.rb
@@ -25,3 +25,12 @@ default['gitlab']['sentinel']['quorum'] = 1
 default['gitlab']['sentinel']['down_after_milliseconds'] = 10000
 default['gitlab']['sentinel']['failover_timeout'] = 60000
 default['gitlab']['sentinel']['myid'] = nil
+
+####
+# Sidekiq Cluster
+####
+default['gitlab']['sidekiq-cluster']['enable'] = false
+default['gitlab']['sidekiq-cluster']['ha'] = false
+default['gitlab']['sidekiq-cluster']['log_directory'] = "/var/log/gitlab/sidekiq-cluster"
+default['gitlab']['sidekiq-cluster']['interval'] = nil
+default['gitlab']['sidekiq-cluster']['queues'] = []
diff --git a/files/gitlab-cookbooks/gitlab-ee/libraries/gitlab-ee.rb b/files/gitlab-cookbooks/gitlab-ee/libraries/gitlab-ee.rb
new file mode 100644
index 0000000000..45fafe33ae
--- /dev/null
+++ b/files/gitlab-cookbooks/gitlab-ee/libraries/gitlab-ee.rb
@@ -0,0 +1,44 @@
+#
+# Copyright:: Copyright (c) 2016 GitLab B.V.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require_relative 'sidekiq_cluster.rb'
+
+module GitlabEE
+  class << self
+    def generate_hash
+      # NOTE: If you are adding a new service
+      # and that service has logging, make sure you add the service to
+      # the array in parse_udp_log_shipping.
+      results = { "gitlab" => {} }
+      [
+        "sidekiq_cluster",
+        "sentinel"
+      ].each do |key|
+        rkey = key.gsub('_', '-')
+        results['gitlab'][rkey] = Gitlab[key]
+      end
+
+      results
+    end
+
+    def generate_config
+      SidekiqCluster.parse_variables
+      # The last step is to convert underscores to hyphens in top-level keys
+      generate_hash
+    end
+  end
+end
diff --git a/files/gitlab-cookbooks/gitlab-ee/libraries/sidekiq_cluster.rb b/files/gitlab-cookbooks/gitlab-ee/libraries/sidekiq_cluster.rb
new file mode 100644
index 0000000000..105cd05c89
--- /dev/null
+++ b/files/gitlab-cookbooks/gitlab-ee/libraries/sidekiq_cluster.rb
@@ -0,0 +1,36 @@
+#
+# Copyright:: Copyright (c) 2016 GitLab Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+module SidekiqCluster
+  class << self
+    def parse_variables
+      # Force sidekiq-cluster to be disabled if sidekiq is disabled
+      Gitlab['sidekiq']['enable'] ||=  Gitlab['node']['gitlab']['sidekiq']['enable']
+      Gitlab['sidekiq_cluster']['enable'] = false unless Gitlab['sidekiq']['enable']
+
+      return unless Gitlab['sidekiq_cluster']['enable']
+
+      # Ensure queues is an array
+      Gitlab['sidekiq_cluster']['queue_groups'] = Array(Gitlab['sidekiq_cluster']['queue_groups'])
+
+      # Error out if the queue hasn't been set
+      if Gitlab['sidekiq_cluster']['queue_groups'].empty?
+        fail "The sidekiq_cluster queue_groups must be set in order to use the sidekiq-cluster service"
+      end
+    end
+  end
+end
diff --git a/files/gitlab-cookbooks/gitlab-ee/recipes/config.rb b/files/gitlab-cookbooks/gitlab-ee/recipes/config.rb
new file mode 100644
index 0000000000..88a9d7a25a
--- /dev/null
+++ b/files/gitlab-cookbooks/gitlab-ee/recipes/config.rb
@@ -0,0 +1,18 @@
+#
+# Copyright:: Copyright (c) 2016 GitLab B.V.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+node.consume_attributes(GitlabEE.generate_config)
diff --git a/files/gitlab-cookbooks/gitlab-ee/recipes/default.rb b/files/gitlab-cookbooks/gitlab-ee/recipes/default.rb
index a0d3513e00..3f56ae4850 100644
--- a/files/gitlab-cookbooks/gitlab-ee/recipes/default.rb
+++ b/files/gitlab-cookbooks/gitlab-ee/recipes/default.rb
@@ -16,11 +16,17 @@
 #
 
 include_recipe 'gitlab::default'
+include_recipe 'gitlab-ee::config'
 
-if node['gitlab']['sentinel']['enable']
-  include_recipe 'gitlab-ee::sentinel'
-else
-  include_recipe 'gitlab-ee::sentinel_disable'
+[
+  "sentinel",
+  "sidekiq-cluster"
+].each do |service|
+  if node["gitlab"][service]["enable"]
+    include_recipe "gitlab-ee::#{service}"
+  else
+    include_recipe "gitlab-ee::#{service}_disable"
+  end
 end
 
 include_recipe 'gitlab-ee::ssh_keys'
diff --git a/files/gitlab-cookbooks/gitlab-ee/recipes/sidekiq-cluster.rb b/files/gitlab-cookbooks/gitlab-ee/recipes/sidekiq-cluster.rb
new file mode 100644
index 0000000000..68f744dd88
--- /dev/null
+++ b/files/gitlab-cookbooks/gitlab-ee/recipes/sidekiq-cluster.rb
@@ -0,0 +1,40 @@
+#
+# Copyright:: Copyright (c) 2016 GitLab Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+account_helper = AccountHelper.new(node)
+log_directory = node['gitlab']['sidekiq-cluster']['log_directory']
+
+directory log_directory do
+  owner account_helper.gitlab_user
+  mode '0700'
+  recursive true
+end
+
+runit_service 'sidekiq-cluster' do
+  down node['gitlab']['sidekiq-cluster']['ha']
+  template_name 'sidekiq-cluster'
+  options({
+    :user => account_helper.gitlab_user,
+    :log_directory => log_directory,
+  }.merge(params))
+  log_options node['gitlab']['logging'].to_hash.merge(node['gitlab']['sidekiq-cluster'].to_hash)
+end
+
+if node['gitlab']['bootstrap']['enable']
+  execute "/opt/gitlab/bin/gitlab-ctl start sidekiq-cluster" do
+    retries 20
+  end
+end
diff --git a/files/gitlab-cookbooks/gitlab-ee/recipes/sidekiq-cluster_disable.rb b/files/gitlab-cookbooks/gitlab-ee/recipes/sidekiq-cluster_disable.rb
new file mode 100644
index 0000000000..fca4bc06dc
--- /dev/null
+++ b/files/gitlab-cookbooks/gitlab-ee/recipes/sidekiq-cluster_disable.rb
@@ -0,0 +1,20 @@
+#
+# Copyright:: Copyright (c) 2016 GitLab Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+runit_service "sidekiq-cluster" do
+  action :disable
+end
diff --git a/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-log-config.erb b/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-log-config.erb
new file mode 100644
index 0000000000..8902097860
--- /dev/null
+++ b/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-log-config.erb
@@ -0,0 +1,6 @@
+<%= "s#@svlogd_size" if @svlogd_size %>
+<%= "n#@svlogd_num" if @svlogd_num %>
+<%= "t#@svlogd_timeout" if @svlogd_timeout %>
+<%= "!#@svlogd_filter" if @svlogd_filter %>
+<%= "u#@svlogd_udp" if @svlogd_udp %>
+<%= "p#@svlogd_prefix" if @svlogd_prefix %>
diff --git a/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-log-run.erb b/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-log-run.erb
new file mode 100644
index 0000000000..c8ab3e301d
--- /dev/null
+++ b/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-log-run.erb
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec svlogd -tt <%= @options[:log_directory] %>
diff --git a/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-run.erb b/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-run.erb
new file mode 100644
index 0000000000..5421d40c58
--- /dev/null
+++ b/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-run.erb
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+cd <%= node['gitlab']['gitlab-rails']['dir'] %>/working
+
+exec 2>&1
+<%= render("mount_point_check.erb", cookbook: 'gitlab') %>
+exec chpst -e /opt/gitlab/etc/gitlab-rails/env -P \
+  -U <%= @options[:user] %> -u <%= @options[:user] %> \
+  /opt/gitlab/embedded/service/gitlab-rails/bin/sidekiq-cluster \
+    -e <%= node['gitlab']['gitlab-rails']['environment'] %> \
+    <% if node['gitlab']['sidekiq-cluster']['interval'] %>
+    -i <%= node['gitlab']['sidekiq-cluster']['interval'] %> \
+    <% end %>
+    <% node['gitlab']['sidekiq-cluster']['queue_groups'].each do |queue| %>
+      <%= queue %> \
+    <% end %>
+
+# Do not remove this line; it prevents trouble with the trailing backslashes above.
diff --git a/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb b/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb
index 0eb1ad4bf3..46700346c7 100644
--- a/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb
+++ b/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb
@@ -61,6 +61,7 @@ module Gitlab
   unicorn Mash.new
   ci_unicorn Mash.new
   sidekiq Mash.new
+  sidekiq_cluster Mash.new
   ci_sidekiq Mash.new
   gitlab_workhorse Mash.new
   gitlab_git_http_server Mash.new # legacy from GitLab 7.14, 8.0, 8.1
@@ -170,6 +171,7 @@ module Gitlab
         "unicorn",
         "ci_unicorn",
         "sidekiq",
+        "sidekiq-cluster",
         "ci_sidekiq",
         "gitlab_workhorse",
         "mailroom",
@@ -190,8 +192,7 @@ module Gitlab
         "mattermost_external_url",
         "pages_external_url",
         "gitlab_pages",
-        "registry",
-        "sentinel"
+        "registry"
       ].each do |key|
         rkey = key.gsub('_', '-')
         results['gitlab'][rkey] = Gitlab[key]
diff --git a/spec/chef/recipes/sidekiq-cluster_spec.rb b/spec/chef/recipes/sidekiq-cluster_spec.rb
new file mode 100644
index 0000000000..c86599d23c
--- /dev/null
+++ b/spec/chef/recipes/sidekiq-cluster_spec.rb
@@ -0,0 +1,45 @@
+require 'chef_helper'
+
+describe 'gitlab-ee::sidekiq-cluster' do
+  let(:chef_run) { ChefSpec::SoloRunner.converge('gitlab-ee::default') }
+
+  before do
+    allow(Gitlab).to receive(:[]).and_call_original
+  end
+
+  describe 'when sidekiq-cluster is disabled' do
+    before { stub_gitlab_rb(sidekiq_cluster: {enable: false }) }
+
+    it 'does not render the sidekiq-cluster service file' do
+      expect(chef_run).to_not render_file("/opt/gitlab/sv/sidekiq-cluster/run")
+    end
+  end
+
+  context 'with queue_groups set' do
+    before do
+      stub_gitlab_rb(sidekiq_cluster: {
+        enable: true,
+        queue_groups: ['process_commit,post_receive', 'gitlab_shell']
+      })
+    end
+
+    it 'correctly renders out the sidekiq-cluster service file' do
+      expect(chef_run).to render_file("/opt/gitlab/sv/sidekiq-cluster/run").with_content(/process_commit,post_receive/)
+      expect(chef_run).to render_file("/opt/gitlab/sv/sidekiq-cluster/run").with_content(/gitlab_shell/)
+    end
+  end
+
+  context 'with interval set' do
+    before do
+      stub_gitlab_rb(sidekiq_cluster: {
+        enable: true,
+        interval: 10,
+        queue_groups: ['process_commit,post_receive']
+      })
+    end
+
+    it 'correctly renders out the sidekiq-cluster service file' do
+      expect(chef_run).to render_file("/opt/gitlab/sv/sidekiq-cluster/run").with_content(/\-i 10/)
+    end
+  end
+end
diff --git a/spec/libraries/sidekiq_cluster_spec.rb b/spec/libraries/sidekiq_cluster_spec.rb
new file mode 100644
index 0000000000..2574c73448
--- /dev/null
+++ b/spec/libraries/sidekiq_cluster_spec.rb
@@ -0,0 +1,39 @@
+require 'chef_helper'
+
+describe SidekiqCluster do
+  let(:chef_run) { ChefSpec::SoloRunner.converge('gitlab-ee::default') }
+  before { allow(Gitlab).to receive(:[]).and_call_original }
+
+  describe 'when sidekiq is disabled' do
+    before { stub_gitlab_rb(sidekiq: { enable: false }, sidekiq_cluster: { enable: true }) }
+
+    it 'disabled sidekiq-cluster' do
+      expect(chef_run.node['gitlab']['sidekiq-cluster']['enable']).to be false
+    end
+  end
+
+  describe 'when queue_groups is passed a string instead of an array' do
+    before { stub_gitlab_rb(sidekiq_cluster: { enable: true, queue_groups: 'gitlab_shell' }) }
+
+    it 'casts to an array' do
+      expect(chef_run.node['gitlab']['sidekiq-cluster']['queue_groups']).to eql(['gitlab_shell'])
+    end
+  end
+
+  describe 'when queue_groups not set' do
+    before { stub_gitlab_rb(sidekiq_cluster: { enable: true }) }
+
+    it 'throws an error' do
+      expect { chef_run }.to raise_error(/The sidekiq_cluster queue_groups must be set/)
+    end
+  end
+
+  describe 'when sidekiq_cluster is enabled' do
+    before { stub_gitlab_rb(sidekiq_cluster: { enable: true }) }
+
+    it 'allows you to set the queue_groups' do
+      stub_gitlab_rb(sidekiq_cluster: { queue_groups: ['process_commit,post_receive', 'gitlab_shell'] })
+      expect(chef_run.node['gitlab']['sidekiq-cluster']['queue_groups']).to eql(['process_commit,post_receive', 'gitlab_shell'])
+    end
+  end
+end
-- 
GitLab


From a4f650a8fc4ee23b6a80df4aed91fb26f0562fbd Mon Sep 17 00:00:00 2001
From: DJ Mountney <dj@gitlab.com>
Date: Tue, 20 Dec 2016 23:25:53 -0800
Subject: [PATCH 2/4] Fix attribute name for sidekiq-cluster

---
 files/gitlab-cookbooks/gitlab-ee/attributes/default.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/files/gitlab-cookbooks/gitlab-ee/attributes/default.rb b/files/gitlab-cookbooks/gitlab-ee/attributes/default.rb
index cffd065feb..f335b2929e 100644
--- a/files/gitlab-cookbooks/gitlab-ee/attributes/default.rb
+++ b/files/gitlab-cookbooks/gitlab-ee/attributes/default.rb
@@ -33,4 +33,4 @@ default['gitlab']['sidekiq-cluster']['enable'] = false
 default['gitlab']['sidekiq-cluster']['ha'] = false
 default['gitlab']['sidekiq-cluster']['log_directory'] = "/var/log/gitlab/sidekiq-cluster"
 default['gitlab']['sidekiq-cluster']['interval'] = nil
-default['gitlab']['sidekiq-cluster']['queues'] = []
+default['gitlab']['sidekiq-cluster']['queue_groups'] = []
-- 
GitLab


From ed045e5c4779385566957051f60574f88f100799 Mon Sep 17 00:00:00 2001
From: DJ Mountney <dj@gitlab.com>
Date: Tue, 20 Dec 2016 23:48:38 -0800
Subject: [PATCH 3/4] Move sentinel config back to gitlab base cookbook

The redis setting end up impacting it, so it isn't as exclusive
---
 files/gitlab-cookbooks/gitlab-ee/libraries/gitlab-ee.rb | 3 +--
 files/gitlab-cookbooks/gitlab/libraries/gitlab.rb       | 3 ++-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/files/gitlab-cookbooks/gitlab-ee/libraries/gitlab-ee.rb b/files/gitlab-cookbooks/gitlab-ee/libraries/gitlab-ee.rb
index 45fafe33ae..0895e5e1e9 100644
--- a/files/gitlab-cookbooks/gitlab-ee/libraries/gitlab-ee.rb
+++ b/files/gitlab-cookbooks/gitlab-ee/libraries/gitlab-ee.rb
@@ -25,8 +25,7 @@ module GitlabEE
       # the array in parse_udp_log_shipping.
       results = { "gitlab" => {} }
       [
-        "sidekiq_cluster",
-        "sentinel"
+        "sidekiq_cluster"
       ].each do |key|
         rkey = key.gsub('_', '-')
         results['gitlab'][rkey] = Gitlab[key]
diff --git a/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb b/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb
index 46700346c7..f92668fd2e 100644
--- a/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb
+++ b/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb
@@ -192,7 +192,8 @@ module Gitlab
         "mattermost_external_url",
         "pages_external_url",
         "gitlab_pages",
-        "registry"
+        "registry",
+        "sentinel"
       ].each do |key|
         rkey = key.gsub('_', '-')
         results['gitlab'][rkey] = Gitlab[key]
-- 
GitLab


From a8f3e1643ec7c0e9804d249dcd3e3b60c2304be4 Mon Sep 17 00:00:00 2001
From: DJ Mountney <dj@gitlab.com>
Date: Wed, 21 Dec 2016 11:01:15 -0800
Subject: [PATCH 4/4] Pass the rails path to sidekiq-cluster

Previously the sidekiq processes were failing as they were being run from
a different directory than the rails app
---
 .../gitlab-ee/templates/default/sv-sidekiq-cluster-run.erb       | 1 +
 1 file changed, 1 insertion(+)

diff --git a/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-run.erb b/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-run.erb
index 5421d40c58..ffe9b67d15 100644
--- a/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-run.erb
+++ b/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-sidekiq-cluster-run.erb
@@ -8,6 +8,7 @@ exec chpst -e /opt/gitlab/etc/gitlab-rails/env -P \
   -U <%= @options[:user] %> -u <%= @options[:user] %> \
   /opt/gitlab/embedded/service/gitlab-rails/bin/sidekiq-cluster \
     -e <%= node['gitlab']['gitlab-rails']['environment'] %> \
+    -r /opt/gitlab/embedded/service/gitlab-rails \
     <% if node['gitlab']['sidekiq-cluster']['interval'] %>
     -i <%= node['gitlab']['sidekiq-cluster']['interval'] %> \
     <% end %>
-- 
GitLab