Skip to content
Snippets Groups Projects
Commit 1d3519f1 authored by Balasankar C's avatar Balasankar C Committed by Marin Jankovski
Browse files

Make gitlab-ee recipes rubocop-friendly

parent d4c3e0ac
No related branches found
No related tags found
No related merge requests found
Showing
with 28 additions and 36 deletions
Loading
Loading
@@ -6,5 +6,5 @@ Knapsack.load_tasks
 
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop) do |t|
t.options = ['-D', 'config', 'lib', 'spec', 'files/gitlab-ctl-commands']
t.options = ['-D', 'config', 'lib', 'spec', 'files/gitlab-ctl-commands', 'files/gitlab-cookbooks/gitlab-ee']
end
Loading
Loading
@@ -76,11 +76,11 @@ default['gitlab']['geo-postgresql']['md5_auth_cidr_addresses'] = []
default['gitlab']['geo-postgresql']['trust_auth_cidr_addresses'] = []
 
# Mininum of 1/8 of total memory and Maximum of 1024MB as sane defaults
default['gitlab']['geo-postgresql']['shared_buffers'] = "#{[(node['memory']['total'].to_i / 8) / (1024), 1024].max}MB"
default['gitlab']['geo-postgresql']['shared_buffers'] = "#{[(node['memory']['total'].to_i / 8) / 1024, 1024].max}MB"
 
default['gitlab']['geo-postgresql']['work_mem'] = '8MB'
default['gitlab']['geo-postgresql']['maintenance_work_mem'] = '16MB'
default['gitlab']['geo-postgresql']['effective_cache_size'] = "#{[(node['memory']['total'].to_i / 8) / (1024), 2048].max}MB" # double of shared_buffers estimation
default['gitlab']['geo-postgresql']['effective_cache_size'] = "#{[(node['memory']['total'].to_i / 8) / 1024, 2048].max}MB" # double of shared_buffers estimation
default['gitlab']['geo-postgresql']['log_min_duration_statement'] = -1 # Disable slow query logging by default
default['gitlab']['geo-postgresql']['checkpoint_segments'] = 10
default['gitlab']['geo-postgresql']['min_wal_size'] = '80MB'
Loading
Loading
Loading
Loading
@@ -35,7 +35,7 @@ define :sentinel_service, config_path: nil, redis_configuration: {}, sentinel_co
ugid redis_user
groupname redis_user
gid node['gitlab']['redis']['gid']
shell node['gitlab']['redis']['shell']
shell node['gitlab']['redis']['shell']
home node['gitlab']['redis']['home']
manage node['gitlab']['manage-accounts']['enable']
end
Loading
Loading
Loading
Loading
@@ -35,7 +35,7 @@ module GitlabEE
'postgresql', # impacted by role
'gitlab_rails' # impacted by role
].each do |key|
rkey = key.gsub('_', '-')
rkey = key.tr('_', '-')
results['gitlab'][rkey] = Gitlab[key]
end
 
Loading
Loading
Loading
Loading
@@ -44,7 +44,7 @@ module GitlabGeo
 
def parse_data_dir
postgresql_data_dir = Gitlab['geo_postgresql']['data_dir'] || node['gitlab']['geo-postgresql']['data_dir']
Gitlab['geo_postgresql']['bootstrap'] = !File.exists?(File.join(postgresql_data_dir, 'PG_VERSION'))
Gitlab['geo_postgresql']['bootstrap'] = !File.exist?(File.join(postgresql_data_dir, 'PG_VERSION'))
end
 
def geo_primary_role?
Loading
Loading
Loading
Loading
@@ -25,13 +25,13 @@ class GitlabGeoHelper
end
 
def connection_digest
connection_attributes = [
'db_adapter',
'db_database',
'db_host',
'db_port',
'db_socket'
].collect { |attribute| node['gitlab']['geo-secondary'][attribute] }
connection_attributes = %w(
db_adapter
db_database
db_host
db_port
db_socket
).collect { |attribute| node['gitlab']['geo-secondary'][attribute] }
 
Digest::MD5.hexdigest(Marshal.dump(connection_attributes))
end
Loading
Loading
Loading
Loading
@@ -19,7 +19,7 @@ class SentinelHelper
# Restore from node definition (gitlab.rb)
def restore_from_node
unless MYID_PATTERN =~ sentinel['myid']
fail 'Sentinel myid must be exactly 40 hex-characters lowercase'
raise 'Sentinel myid must be exactly 40 hex-characters lowercase'
end
 
sentinel['myid']
Loading
Loading
@@ -44,22 +44,19 @@ class SentinelHelper
 
# Load from local JSON file
def load_from_file
if File.exists?(JSON_FILE)
Chef::JSONCompat.from_json(File.read(JSON_FILE))
end
Chef::JSONCompat.from_json(File.read(JSON_FILE)) if File.exist?(JSON_FILE)
end
 
# Save to local JSON file
def save_to_file(data)
if File.directory?('/etc/gitlab')
File.open(JSON_FILE, 'w', 0600) do |f|
f.puts(Chef::JSONCompat.to_json_pretty(data))
f.chmod(0600) # update existing file
end
return unless File.directory?('/etc/gitlab')
File.open(JSON_FILE, 'w', 0600) do |f|
f.puts(Chef::JSONCompat.to_json_pretty(data))
f.chmod(0600) # update existing file
end
end
 
def generate_myid
SecureRandom::hex(20) # size will be n*2 -> 40 characters
SecureRandom.hex(20) # size will be n*2 -> 40 characters
end
end
Loading
Loading
@@ -19,7 +19,7 @@ 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']['enable'] ||= Gitlab['node']['gitlab']['sidekiq']['enable']
Gitlab['sidekiq_cluster']['enable'] = false unless Gitlab['sidekiq']['enable']
 
return unless Gitlab['sidekiq_cluster']['enable']
Loading
Loading
@@ -28,9 +28,7 @@ module SidekiqCluster
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
raise "The sidekiq_cluster queue_groups must be set in order to use the sidekiq-cluster service" if Gitlab['sidekiq_cluster']['queue_groups'].empty?
end
end
end
Loading
Loading
@@ -139,7 +139,7 @@ module SSHKeygen
end
 
# provider functions for the SSHKeygen Chef resource provider class
module Helper
module Helper # rubocop:disable Style/MultilineIfModifier
def create_key
converge_by("Create SSH #{new_resource.type} #{new_resource.strength}-bit key (#{new_resource.comment})") do
@key = ::SSHKeygen::Generator.new(
Loading
Loading
Loading
Loading
@@ -91,8 +91,8 @@ runit_service 'geo-postgresql' do
down node['gitlab']['geo-postgresql']['ha']
control(['t'])
options({
:log_directory => postgresql_log_dir
}.merge(params))
log_directory: postgresql_log_dir
}.merge(params))
log_options node['gitlab']['logging'].to_hash.merge(node['gitlab']['geo-postgresql'].to_hash)
end
 
Loading
Loading
@@ -106,9 +106,7 @@ include_recipe 'gitlab::postgresql-bin'
execute 'start geo-postgresql' do
command '/opt/gitlab/bin/gitlab-ctl start geo-postgresql'
retries 20
unless bootstrapping
action :nothing
end
action :nothing unless bootstrapping
end
 
###
Loading
Loading
Loading
Loading
@@ -15,7 +15,6 @@
#
 
account_helper = AccountHelper.new(node)
omnibus_helper = OmnibusHelper.new(node)
 
include_recipe 'gitlab::postgresql_user'
[
Loading
Loading
Loading
Loading
@@ -27,8 +27,8 @@ 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,
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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment