Upgrade rubocop to 0.73.0
* Add rubocop-rails and rubocop-performance gems * Update renamed gems in .rubocop.yml * Auto-correct where possible * Manually fix remaining gems
This commit is contained in:
parent
39d1b55dc7
commit
11c4590546
74
.rubocop.yml
74
.rubocop.yml
|
@ -1,4 +1,5 @@
|
|||
require:
|
||||
- rubocop-performance
|
||||
- rubocop-rspec
|
||||
- ./lib/rubocop/rubocop
|
||||
|
||||
|
@ -26,10 +27,6 @@ AllCops:
|
|||
|
||||
Style/NumericLiteralPrefix:
|
||||
Enabled: false
|
||||
Metrics/BlockLength:
|
||||
Enabled: false
|
||||
Metrics/LineLength:
|
||||
Enabled: false
|
||||
|
||||
# Gems in consecutive lines should be alphabetically sorted
|
||||
Bundler/OrderedGems:
|
||||
|
@ -54,6 +51,10 @@ Layout/AlignHash:
|
|||
Layout/AlignParameters:
|
||||
Enabled: false
|
||||
|
||||
# Align block ends correctly.
|
||||
Layout/BlockAlignment:
|
||||
Enabled: true
|
||||
|
||||
# Put end statement of multiline block on its own line.
|
||||
Layout/BlockEndNewline:
|
||||
Enabled: true
|
||||
|
@ -66,6 +67,14 @@ Layout/CaseIndentation:
|
|||
Layout/CommentIndentation:
|
||||
Enabled: true
|
||||
|
||||
# Checks for condition placed in a confusing position relative to the keyword.
|
||||
Layout/ConditionPosition:
|
||||
Enabled: true
|
||||
|
||||
# Align ends corresponding to defs correctly.
|
||||
Layout/DefEndAlignment:
|
||||
Enabled: true
|
||||
|
||||
# Align elses and elsifs correctly.
|
||||
Layout/ElseAlignment:
|
||||
Enabled: true
|
||||
|
@ -102,6 +111,10 @@ Layout/EmptyLinesAroundMethodBody:
|
|||
Layout/EmptyLinesAroundModuleBody:
|
||||
Enabled: true
|
||||
|
||||
# Align ends correctly.
|
||||
Layout/EndAlignment:
|
||||
Enabled: true
|
||||
|
||||
# Use Unix-style line endings.
|
||||
Layout/EndOfLine:
|
||||
Enabled: true
|
||||
|
@ -407,10 +420,6 @@ Style/EvalWithLocation:
|
|||
Style/EvenOdd:
|
||||
Enabled: true
|
||||
|
||||
# Checks for flip flops.
|
||||
Style/FlipFlop:
|
||||
Enabled: true
|
||||
|
||||
# Checks use of for or each in multiline loops.
|
||||
Style/For:
|
||||
Enabled: true
|
||||
|
@ -537,6 +546,10 @@ Style/RedundantException:
|
|||
Style/RedundantParentheses:
|
||||
Enabled: true
|
||||
|
||||
# Use `sort` instead of `sort_by { |x| x }`.
|
||||
Style/RedundantSortBy:
|
||||
Enabled: true
|
||||
|
||||
Style/RegexpLiteral:
|
||||
Enabled: false
|
||||
|
||||
|
@ -574,12 +587,18 @@ Style/StringMethods:
|
|||
intern: to_sym
|
||||
Enabled: true
|
||||
|
||||
# Use `strip` instead of `lstrip.rstrip`.
|
||||
Style/Strip:
|
||||
Enabled: true
|
||||
|
||||
# Use %i or %I for arrays of symbols.
|
||||
Style/SymbolArray:
|
||||
Enabled: false
|
||||
|
||||
# This cop checks for trailing comma in array and hash literals.
|
||||
Style/TrailingCommaInLiteral:
|
||||
# These cops check for trailing comma in array and hash literals.
|
||||
Style/TrailingCommaInArrayLiteral:
|
||||
Enabled: false
|
||||
Style/TrailingCommaInHashLiteral:
|
||||
Enabled: false
|
||||
|
||||
# Checks for %W when interpolation is not needed.
|
||||
|
@ -685,27 +704,15 @@ Lint/AmbiguousRegexpLiteral:
|
|||
Lint/AssignmentInCondition:
|
||||
Enabled: false
|
||||
|
||||
# Align block ends correctly.
|
||||
Lint/BlockAlignment:
|
||||
Enabled: true
|
||||
|
||||
# Default values in optional keyword arguments and optional ordinal arguments
|
||||
# should not refer back to the name of the argument.
|
||||
Lint/CircularArgumentReference:
|
||||
Enabled: true
|
||||
|
||||
# Checks for condition placed in a confusing position relative to the keyword.
|
||||
Lint/ConditionPosition:
|
||||
Enabled: true
|
||||
|
||||
# Check for debugger calls.
|
||||
Lint/Debugger:
|
||||
Enabled: true
|
||||
|
||||
# Align ends corresponding to defs correctly.
|
||||
Lint/DefEndAlignment:
|
||||
Enabled: true
|
||||
|
||||
# Check for deprecated class method calls.
|
||||
Lint/DeprecatedClassMethods:
|
||||
Enabled: true
|
||||
|
@ -730,10 +737,6 @@ Lint/EmptyEnsure:
|
|||
Lint/EmptyWhen:
|
||||
Enabled: true
|
||||
|
||||
# Align ends correctly.
|
||||
Lint/EndAlignment:
|
||||
Enabled: true
|
||||
|
||||
# END blocks should not be placed inside method definitions.
|
||||
Lint/EndInMethod:
|
||||
Enabled: true
|
||||
|
@ -742,6 +745,10 @@ Lint/EndInMethod:
|
|||
Lint/EnsureReturn:
|
||||
Enabled: true
|
||||
|
||||
# Checks for flip flops.
|
||||
Lint/FlipFlop:
|
||||
Enabled: true
|
||||
|
||||
# Catches floating-point literals too large or small for Ruby to represent.
|
||||
Lint/FloatOutOfRange:
|
||||
Enabled: true
|
||||
|
@ -829,7 +836,7 @@ Lint/UnifiedInteger:
|
|||
# Checks for rubocop:disable comments that can be removed.
|
||||
# Note: this cop is not disabled when disabling all cops.
|
||||
# It must be explicitly disabled.
|
||||
Lint/UnneededDisable:
|
||||
Lint/UnneededCopDisableDirective:
|
||||
Enabled: false
|
||||
|
||||
# This cop checks for unneeded usages of splat expansion
|
||||
|
@ -883,15 +890,6 @@ Performance/Casecmp:
|
|||
Performance/DoubleStartEndWith:
|
||||
Enabled: true
|
||||
|
||||
# Use `Hash#each_key` and `Hash#each_value` instead of
|
||||
# `Hash#keys.each` and `Hash#values.each`.
|
||||
Performance/HashEachMethods:
|
||||
Enabled: false
|
||||
|
||||
# Use `strip` instead of `lstrip.rstrip`.
|
||||
Performance/LstripRstrip:
|
||||
Enabled: true
|
||||
|
||||
# Use `Range#cover?` instead of `Range#include?`.
|
||||
Performance/RangeInclude:
|
||||
Enabled: true
|
||||
|
@ -912,10 +910,6 @@ Performance/RedundantMerge:
|
|||
Enabled: true
|
||||
MaxKeyValuePairs: 1
|
||||
|
||||
# Use `sort` instead of `sort_by { |x| x }`.
|
||||
Performance/RedundantSortBy:
|
||||
Enabled: true
|
||||
|
||||
# Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match` or `=~` when `MatchData` is not used.
|
||||
Performance/RegexpMatch:
|
||||
Enabled: true
|
||||
|
|
4
Gemfile
4
Gemfile
|
@ -38,7 +38,9 @@ gem 'google_drive'
|
|||
gem 'http'
|
||||
|
||||
group :rubocop do
|
||||
gem 'rubocop'
|
||||
gem 'rubocop', '0.69.0'
|
||||
gem 'rubocop-performance', '~> 1.3.0'
|
||||
# gem 'rubocop-rails'
|
||||
gem 'rubocop-rspec'
|
||||
end
|
||||
|
||||
|
|
23
Gemfile.lock
23
Gemfile.lock
|
@ -857,6 +857,7 @@ GEM
|
|||
iniparse (1.4.4)
|
||||
iostruct (0.0.4)
|
||||
ipaddress (0.8.3)
|
||||
jaro_winkler (1.5.3)
|
||||
jmespath (1.4.0)
|
||||
json (2.0.2)
|
||||
json_pure (1.8.1)
|
||||
|
@ -911,8 +912,8 @@ GEM
|
|||
rainbow (= 2.2.2)
|
||||
rest-client (~> 2.0)
|
||||
thor (~> 0.18)
|
||||
parallel (1.12.1)
|
||||
parser (2.5.0.2)
|
||||
parallel (1.17.0)
|
||||
parser (2.6.3.0)
|
||||
ast (~> 2.4.0)
|
||||
pedump (0.5.2)
|
||||
awesome_print
|
||||
|
@ -921,7 +922,6 @@ GEM
|
|||
progressbar
|
||||
zhexdump (>= 0.0.2)
|
||||
plist (3.5.0)
|
||||
powerpack (0.1.1)
|
||||
progressbar (1.10.0)
|
||||
proxifier (1.0.3)
|
||||
pry (0.12.2)
|
||||
|
@ -960,16 +960,18 @@ GEM
|
|||
rspec_junit_formatter (0.2.3)
|
||||
builder (< 4)
|
||||
rspec-core (>= 2, < 4, != 2.12.0)
|
||||
rubocop (0.52.1)
|
||||
rubocop (0.69.0)
|
||||
jaro_winkler (~> 1.5.1)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.4.0.2, < 3.0)
|
||||
powerpack (~> 0.1)
|
||||
parser (>= 2.6)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (~> 1.0, >= 1.0.1)
|
||||
unicode-display_width (>= 1.4.0, < 1.7)
|
||||
rubocop-performance (1.3.0)
|
||||
rubocop (>= 0.68.0)
|
||||
rubocop-rspec (1.12.0)
|
||||
rubocop (>= 0.42.0)
|
||||
ruby-progressbar (1.9.0)
|
||||
ruby-progressbar (1.10.1)
|
||||
serverspec (2.41.4)
|
||||
multi_json
|
||||
rspec (~> 3.0)
|
||||
|
@ -996,7 +998,7 @@ GEM
|
|||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.7.5)
|
||||
unicode-display_width (1.4.0)
|
||||
unicode-display_width (1.6.0)
|
||||
uuidtools (2.1.5)
|
||||
wmi-lite (1.0.2)
|
||||
zhexdump (0.0.2)
|
||||
|
@ -1024,7 +1026,8 @@ DEPENDENCIES
|
|||
rake
|
||||
rspec
|
||||
rspec_junit_formatter
|
||||
rubocop
|
||||
rubocop (= 0.69.0)
|
||||
rubocop-performance (~> 1.3.0)
|
||||
rubocop-rspec
|
||||
thor (= 0.18.1)
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Upgrade rubocop to 0.69.0
|
||||
merge_request: 3473
|
||||
author:
|
||||
type: other
|
|
@ -38,9 +38,7 @@ build do
|
|||
|
||||
# Append the 1024bit Verisign certs so that S3 continues to work
|
||||
block do
|
||||
unless File.foreach("#{project_dir}/cacert-#{version.tr('.', '-')}.pem").grep(/^Verisign Class 3 Public Primary Certification Authority$/).any?
|
||||
File.open("#{project_dir}/cacert-#{version.tr('.', '-')}.pem", 'a') { |fd| fd.write(VERISIGN_CERTS) }
|
||||
end
|
||||
File.open("#{project_dir}/cacert-#{version.tr('.', '-')}.pem", 'a') { |fd| fd.write(VERISIGN_CERTS) } unless File.foreach("#{project_dir}/cacert-#{version.tr('.', '-')}.pem").grep(/^Verisign Class 3 Public Primary Certification Authority$/).any?
|
||||
end
|
||||
|
||||
copy "#{project_dir}/cacert-#{version.tr('.', '-')}.pem", "#{install_dir}/embedded/ssl/certs/cacert.pem"
|
||||
|
|
|
@ -51,7 +51,7 @@ build do
|
|||
env = with_standard_compiler_flags(with_embedded_path)
|
||||
|
||||
block do
|
||||
open(File.join(project_dir, 'config.mak'), 'a') do |file|
|
||||
File.open(File.join(project_dir, 'config.mak'), 'a') do |file|
|
||||
file.print <<-EOH
|
||||
# Added by Omnibus git software definition git.rb
|
||||
CURLDIR=#{install_dir}/embedded
|
||||
|
|
|
@ -31,7 +31,7 @@ build do
|
|||
command "mkdir -p #{install_dir}/bin/"
|
||||
|
||||
block do
|
||||
open("#{install_dir}/bin/gitlab-ctl", 'w') do |file|
|
||||
File.open("#{install_dir}/bin/gitlab-ctl", 'w') do |file|
|
||||
file.print <<-EOH
|
||||
#!/bin/bash
|
||||
#
|
||||
|
@ -69,7 +69,7 @@ done
|
|||
export SVWAIT=30
|
||||
|
||||
#{install_dir}/embedded/bin/omnibus-ctl #{File.basename(install_dir)} '#{install_dir}/embedded/service/omnibus-ctl*' "$@"
|
||||
EOH
|
||||
EOH
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ default_version Digest::MD5.file(__FILE__).hexdigest
|
|||
|
||||
build do
|
||||
block do
|
||||
open("#{install_dir}/bin/gitlab-geo-psql", 'w') do |file|
|
||||
File.open("#{install_dir}/bin/gitlab-geo-psql", 'w') do |file|
|
||||
file.print <<-EOH
|
||||
#!/bin/sh
|
||||
|
||||
|
@ -58,7 +58,7 @@ else
|
|||
fi
|
||||
|
||||
cd /tmp; exec /opt/gitlab/embedded/bin/chpst ${privilege_drop} -U ${psql_user} /usr/bin/env PGSSLCOMPRESSION=0 /opt/gitlab/embedded/bin/psql -p ${psql_port} -h ${psql_host} -d ${psql_dbname} "$@"
|
||||
EOH
|
||||
EOH
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ default_version Digest::MD5.file(__FILE__).hexdigest
|
|||
|
||||
build do
|
||||
block do
|
||||
open("#{install_dir}/bin/gitlab-healthcheck", 'w') do |file|
|
||||
File.open("#{install_dir}/bin/gitlab-healthcheck", 'w') do |file|
|
||||
file.print <<-EOH
|
||||
#!/bin/sh
|
||||
|
||||
|
@ -47,7 +47,7 @@ fi
|
|||
. ${gitlab_healthcheck_rc}
|
||||
|
||||
exec /opt/gitlab/embedded/bin/curl $@ ${flags} ${url}
|
||||
EOH
|
||||
EOH
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ default_version Digest::MD5.file(__FILE__).hexdigest
|
|||
|
||||
build do
|
||||
block do
|
||||
open("#{install_dir}/embedded/bin/gitlab-pg-ctl", 'w') do |file|
|
||||
File.open("#{install_dir}/embedded/bin/gitlab-pg-ctl", 'w') do |file|
|
||||
file.print <<-EOH
|
||||
#!/bin/sh
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ default_version Digest::MD5.file(__FILE__).hexdigest
|
|||
|
||||
build do
|
||||
block do
|
||||
open("#{install_dir}/bin/gitlab-psql", 'w') do |file|
|
||||
File.open("#{install_dir}/bin/gitlab-psql", 'w') do |file|
|
||||
file.print <<-EOH
|
||||
#!/bin/sh
|
||||
|
||||
|
@ -58,7 +58,7 @@ else
|
|||
fi
|
||||
|
||||
cd /tmp; exec /opt/gitlab/embedded/bin/chpst ${privilege_drop} -U ${psql_user} /usr/bin/env PGSSLCOMPRESSION=0 /opt/gitlab/embedded/bin/psql -p ${psql_port} -h ${psql_host} -d ${psql_dbname} "$@"
|
||||
EOH
|
||||
EOH
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -41,9 +41,7 @@ build do
|
|||
config_flags = ""
|
||||
# CentOS 6 doesn't have inotify, which will raise an error
|
||||
# IN_EXCL_UNLINK undeclared. Hence disabling it explicitly.
|
||||
if ohai['platform'] =~ /centos/ && ohai['platform_version'] =~ /^6/
|
||||
config_flags = "ac_cv_func_inotify_init=no"
|
||||
end
|
||||
config_flags = "ac_cv_func_inotify_init=no" if ohai['platform'] =~ /centos/ && ohai['platform_version'] =~ /^6/
|
||||
|
||||
command './configure ' \
|
||||
"--prefix=#{install_dir}/embedded --disable-doc --without-readline --disable-sqlite --disable-gnutls --disable-dirmngr #{config_flags}", env: env
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Copyright 2012-2014 Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -41,9 +40,7 @@ build do
|
|||
|
||||
# The patch is from the FreeBSD ports tree and is for GCC compatibility.
|
||||
# http://svnweb.freebsd.org/ports/head/devel/libedit/files/patch-vi.c?annotate=300896
|
||||
if version.to_i < 20_150_325 && (freebsd? || openbsd?)
|
||||
patch source: 'freebsd-vi-fix.patch', env: env
|
||||
end
|
||||
patch source: 'freebsd-vi-fix.patch', env: env if version.to_i < 20_150_325 && (freebsd? || openbsd?)
|
||||
|
||||
patch source: 'openbsd-weak-alias-fix.patch', plevel: 1, env: env if openbsd?
|
||||
|
||||
|
|
|
@ -39,9 +39,7 @@ build do
|
|||
|
||||
# Windows had worse automake/libtool version issues.
|
||||
# Just patch the output instead.
|
||||
if version >= '0.1.6' && windows?
|
||||
patch source: 'v0.1.6.windows-configure.patch', plevel: 1, env: env
|
||||
end
|
||||
patch source: 'v0.1.6.windows-configure.patch', plevel: 1, env: env if version >= '0.1.6' && windows?
|
||||
|
||||
make "-j #{workers}", env: env
|
||||
make "-j #{workers} install", env: env
|
||||
|
|
|
@ -90,9 +90,7 @@ build do
|
|||
|
||||
patch source: 'patch-ncurses_tinfo_lib__baudrate.c', plevel: 0 if openbsd?
|
||||
|
||||
if version == '5.9' && ppc64le?
|
||||
patch source: 'v5.9.ppc64le-configure.patch', plevel: 1
|
||||
end
|
||||
patch source: 'v5.9.ppc64le-configure.patch', plevel: 1 if version == '5.9' && ppc64le?
|
||||
|
||||
configure_command = [
|
||||
'./configure',
|
||||
|
@ -153,9 +151,7 @@ build do
|
|||
make "-j #{workers} install", env: env
|
||||
|
||||
# Ensure embedded ncurses wins in the LD search path
|
||||
if smartos?
|
||||
link "#{install_dir}/embedded/lib/libcurses.so", "#{install_dir}/embedded/lib/libcurses.so.1"
|
||||
end
|
||||
link "#{install_dir}/embedded/lib/libcurses.so", "#{install_dir}/embedded/lib/libcurses.so.1" if smartos?
|
||||
end
|
||||
|
||||
project.exclude "embedded/bin/ncurses5-config"
|
||||
|
|
|
@ -34,9 +34,7 @@ build do
|
|||
|
||||
update_config_guess
|
||||
|
||||
if version == '1.7.10.1' && (ppc64? || ppc64le?)
|
||||
patch source: 'v1.7.10.1.ppc64le-configure.patch', plevel: 1
|
||||
end
|
||||
patch source: 'v1.7.10.1.ppc64le-configure.patch', plevel: 1 if version == '1.7.10.1' && (ppc64? || ppc64le?)
|
||||
|
||||
# --disable-nls => Disable localization support.
|
||||
command './configure' \
|
||||
|
|
|
@ -115,9 +115,7 @@ build do
|
|||
# wrlinux7/ios_xr build boxes from Cisco include libssp and there is no way to
|
||||
# disable ruby from linking against it, but Cisco switches will not have the
|
||||
# library. Disabling it as we do for Solaris.
|
||||
if ios_xr? && version.satisfies?('>= 2.1')
|
||||
patch source: 'ruby-no-stack-protector.patch', plevel: 1, env: patch_env
|
||||
end
|
||||
patch source: 'ruby-no-stack-protector.patch', plevel: 1, env: patch_env if ios_xr? && version.satisfies?('>= 2.1')
|
||||
|
||||
# disable libpath in mkmf across all platforms, it trolls omnibus and
|
||||
# breaks the postgresql cookbook. i'm not sure why ruby authors decided
|
||||
|
@ -217,6 +215,7 @@ build do
|
|||
arch_suffix = windows_arch_i386? ? '32' : '64'
|
||||
windows_path = "C:/msys2/mingw#{arch_suffix}/bin/#{dll}.dll"
|
||||
raise "Cannot find required DLL needed for dynamic linking: #{windows_path}" unless File.exist?(windows_path)
|
||||
|
||||
copy windows_path, "#{install_dir}/embedded/bin/#{dll}.dll"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,9 +22,9 @@ action :create do
|
|||
|
||||
content = {
|
||||
'service' => {
|
||||
'name' => service_name,
|
||||
'name' => service_name,
|
||||
'address' => ip_address,
|
||||
'port' => port.to_i
|
||||
'port' => port.to_i
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@ class GitlabGeoHelper # rubocop:disable Style/MultilineIfModifier (disabled so w
|
|||
end
|
||||
|
||||
def db_migrate_status_file
|
||||
@migrate_status_file ||= begin
|
||||
@db_migrate_status_file ||= begin
|
||||
upgrade_status_dir = ::File.join(node['gitlab']['gitlab-rails']['dir'], 'upgrade-status')
|
||||
::File.join(upgrade_status_dir, "geo-db-migrate-#{connection_digest}-#{revision}")
|
||||
end
|
||||
end
|
||||
|
||||
def fdw_sync_status_file
|
||||
@sync_status_file ||= begin
|
||||
@fdw_sync_status_file ||= begin
|
||||
upgrade_status_dir = ::File.join(node['gitlab']['gitlab-rails']['dir'], 'upgrade-status')
|
||||
::File.join(upgrade_status_dir, "geo-fdw-sync-#{connection_digest}-#{revision}")
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class SentinelHelper
|
||||
MYID_PATTERN ||= /^[0-9a-f]{40}$/
|
||||
MYID_PATTERN ||= /^[0-9a-f]{40}$/.freeze
|
||||
JSON_FILE ||= '/etc/gitlab/gitlab-sentinel.json'.freeze
|
||||
|
||||
def initialize(node)
|
||||
|
@ -18,9 +18,7 @@ class SentinelHelper
|
|||
|
||||
# Restore from node definition (gitlab.rb)
|
||||
def restore_from_node
|
||||
unless MYID_PATTERN.match?(sentinel['myid'])
|
||||
raise 'Sentinel myid must be exactly 40 hex-characters lowercase'
|
||||
end
|
||||
raise 'Sentinel myid must be exactly 40 hex-characters lowercase' unless MYID_PATTERN.match?(sentinel['myid'])
|
||||
|
||||
sentinel['myid']
|
||||
end
|
||||
|
@ -50,6 +48,7 @@ class SentinelHelper
|
|||
# Save to local JSON file
|
||||
def save_to_file(data)
|
||||
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
|
||||
|
|
|
@ -19,13 +19,13 @@ Services.add_services('gitlab-ee', Services::EEServices.list)
|
|||
|
||||
include_recipe 'gitlab::default'
|
||||
|
||||
[
|
||||
'sentinel',
|
||||
'sidekiq-cluster',
|
||||
'geo-postgresql',
|
||||
'geo-logcursor',
|
||||
'pgbouncer',
|
||||
'pgbouncer-exporter'
|
||||
%w[
|
||||
sentinel
|
||||
sidekiq-cluster
|
||||
geo-postgresql
|
||||
geo-logcursor
|
||||
pgbouncer
|
||||
pgbouncer-exporter
|
||||
].each do |service|
|
||||
if node['gitlab'][service]['enable']
|
||||
include_recipe "gitlab-ee::#{service}"
|
||||
|
|
|
@ -137,9 +137,7 @@ geo_pg_user_password = node['gitlab']['geo-postgresql']['sql_user_password']
|
|||
geo_database_name = node['gitlab']['geo-secondary']['db_database']
|
||||
|
||||
# set custom pg_hba entries at the secondary postgres for FDW compatibility
|
||||
if fdw_helper.fdw_enabled?
|
||||
node.default['postgresql']['custom_pg_hba_entries']['fdw'] = fdw_helper.pg_hba_entries
|
||||
end
|
||||
node.default['postgresql']['custom_pg_hba_entries']['fdw'] = fdw_helper.pg_hba_entries if fdw_helper.fdw_enabled?
|
||||
|
||||
if node['gitlab']['geo-postgresql']['enable']
|
||||
postgresql_user geo_pg_user do
|
||||
|
|
|
@ -39,9 +39,7 @@ module GitlabMattermost
|
|||
|
||||
uri = URI(Gitlab['mattermost_external_url'].to_s)
|
||||
|
||||
unless uri.host
|
||||
raise "GitLab Mattermost external URL must include a schema and FQDN, e.g. http://mattermost.example.com/"
|
||||
end
|
||||
raise "GitLab Mattermost external URL must include a schema and FQDN, e.g. http://mattermost.example.com/" unless uri.host
|
||||
|
||||
Gitlab['mattermost']['host'] = uri.host
|
||||
Gitlab['mattermost']['service_site_url'] ||= Gitlab['mattermost_external_url']
|
||||
|
@ -82,9 +80,7 @@ module GitlabMattermost
|
|||
raise "Unsupported external URL scheme: #{uri.scheme}"
|
||||
end
|
||||
|
||||
unless ["", "/"].include?(uri.path)
|
||||
raise "Unsupported CI external URL path: #{uri.path}"
|
||||
end
|
||||
raise "Unsupported CI external URL path: #{uri.path}" unless ["", "/"].include?(uri.path)
|
||||
|
||||
Gitlab['mattermost']['port'] = uri.port
|
||||
end
|
||||
|
|
|
@ -39,9 +39,7 @@ module GitlabPages
|
|||
|
||||
uri = URI(Gitlab['pages_external_url'].to_s)
|
||||
|
||||
unless uri.host
|
||||
raise "GitLab Pages external URL must include a schema and FQDN, e.g. http://pages.example.com/"
|
||||
end
|
||||
raise "GitLab Pages external URL must include a schema and FQDN, e.g. http://pages.example.com/" unless uri.host
|
||||
|
||||
Gitlab['gitlab_rails']['pages_host'] = uri.host
|
||||
Gitlab['gitlab_rails']['pages_port'] = uri.port
|
||||
|
@ -59,9 +57,7 @@ module GitlabPages
|
|||
raise "Unsupported GitLab Pages external URL scheme: #{uri.scheme}"
|
||||
end
|
||||
|
||||
unless ["", "/"].include?(uri.path)
|
||||
raise "Unsupported GitLab Pages external URL path: #{uri.path}"
|
||||
end
|
||||
raise "Unsupported GitLab Pages external URL path: #{uri.path}" unless ["", "/"].include?(uri.path)
|
||||
|
||||
# FQDN are prepared to be used as regexp: the dot is escaped
|
||||
Gitlab['pages_nginx']['fqdn_regex'] = uri.host.gsub('.', '\.')
|
||||
|
|
|
@ -77,9 +77,8 @@ module GitlabRails # rubocop:disable Style/MultilineIfModifier
|
|||
|
||||
uri = URI(Gitlab['external_url'].to_s)
|
||||
|
||||
unless uri.host
|
||||
raise "GitLab external URL must include a schema and FQDN, e.g. http://gitlab.example.com/"
|
||||
end
|
||||
raise "GitLab external URL must include a schema and FQDN, e.g. http://gitlab.example.com/" unless uri.host
|
||||
|
||||
Gitlab['user']['git_user_email'] ||= "gitlab@#{uri.host}"
|
||||
Gitlab['gitlab_rails']['gitlab_host'] = uri.host
|
||||
Gitlab['gitlab_rails']['gitlab_email_from'] ||= "gitlab@#{uri.host}"
|
||||
|
@ -184,6 +183,7 @@ module GitlabRails # rubocop:disable Style/MultilineIfModifier
|
|||
|
||||
def parse_repository_storage
|
||||
return if Gitlab['gitlab_rails']['repositories_storages']
|
||||
|
||||
gitaly_address = Gitaly.gitaly_address
|
||||
|
||||
Gitlab['gitlab_rails']['repositories_storages'] ||= {
|
||||
|
@ -210,6 +210,7 @@ module GitlabRails # rubocop:disable Style/MultilineIfModifier
|
|||
|
||||
# append urls to the list but without relative_url
|
||||
return unless Gitlab['gitlab_rails']['gitlab_relative_url']
|
||||
|
||||
paths_without_relative_url = []
|
||||
Gitlab['gitlab_rails']['rack_attack_protected_paths'].each do |path|
|
||||
if path.start_with?(Gitlab['gitlab_rails']['gitlab_relative_url'] + '/')
|
||||
|
|
|
@ -6,12 +6,12 @@ class BasePgHelper < BaseHelper
|
|||
include ShellOutHelper
|
||||
attr_reader :node
|
||||
|
||||
PG_HASH_PATTERN ||= /\{(.*)\}/
|
||||
PG_HASH_PATTERN ||= /\{(.*)\}/.freeze
|
||||
PG_HASH_PAIR_SEPARATOR ||= ','.freeze
|
||||
PG_HASH_PAIR_ESCAPED_PATTERN ||= /^"|"$/
|
||||
PG_HASH_PAIR_ESCAPED_PATTERN ||= /^"|"$/.freeze
|
||||
PG_HASH_KEY_VALUE_SEPARATOR ||= '='.freeze
|
||||
PG_ESCAPED_DOUBLE_QUOTE_PATTERN ||= /\\"/
|
||||
PG_ESCAPED_BACKSLASH_PATTERN ||= /\\{2}/
|
||||
PG_ESCAPED_DOUBLE_QUOTE_PATTERN ||= /\\"/.freeze
|
||||
PG_ESCAPED_BACKSLASH_PATTERN ||= /\\{2}/.freeze
|
||||
|
||||
def is_running?
|
||||
OmnibusHelper.new(node).service_up?(service_name)
|
||||
|
@ -227,6 +227,7 @@ class BasePgHelper < BaseHelper
|
|||
# need to check both.
|
||||
|
||||
return File.exist?(File.join(node['gitlab'][service_name]['data_dir'], 'PG_VERSION')) if node['gitlab'].key?(service_name)
|
||||
|
||||
File.exist?(File.join(node[service_name]['data_dir'], 'PG_VERSION'))
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class PGVersion < String
|
|||
\A(?<part1>\d+)
|
||||
(\.(?<part2>\d+))?
|
||||
(\.(?<part3>\d+))?\z
|
||||
}x
|
||||
}x.freeze
|
||||
|
||||
def initialize(version_string)
|
||||
super(version_string)
|
||||
|
|
|
@ -38,13 +38,9 @@ module Redis
|
|||
# When announce-ip is defined and announce-port not, infer the later from the main redis_port
|
||||
# This functionality makes sense for redis slaves but with sentinel, the redis role can swap
|
||||
# We introduce the option regardless the user defined de redis node as master or slave
|
||||
if Gitlab['redis']['announce_ip']
|
||||
Gitlab['redis']['announce_port'] ||= Gitlab['redis']['port']
|
||||
end
|
||||
Gitlab['redis']['announce_port'] ||= Gitlab['redis']['port'] if Gitlab['redis']['announce_ip']
|
||||
|
||||
if redis_managed? && (RedisHelper::Checks.sentinel_daemon_enabled? || RedisHelper::Checks.is_redis_slave? || Gitlab['redis_master_role']['enable'])
|
||||
Gitlab['redis']['master_password'] ||= Gitlab['redis']['password']
|
||||
end
|
||||
Gitlab['redis']['master_password'] ||= Gitlab['redis']['password'] if redis_managed? && (RedisHelper::Checks.sentinel_daemon_enabled? || RedisHelper::Checks.is_redis_slave? || Gitlab['redis_master_role']['enable'])
|
||||
|
||||
Gitlab['redis']['rename_commands'] ||= {
|
||||
'KEYS' => ''
|
||||
|
@ -64,19 +60,16 @@ module Redis
|
|||
|
||||
def parse_redis_daemon!
|
||||
return unless redis_managed?
|
||||
|
||||
redis_bind = Gitlab['redis']['bind'] || node['redis']['bind']
|
||||
|
||||
Gitlab['gitlab_rails']['redis_host'] ||= redis_bind
|
||||
Gitlab['gitlab_rails']['redis_port'] ||= Gitlab['redis']['port']
|
||||
Gitlab['gitlab_rails']['redis_password'] ||= Gitlab['redis']['master_password']
|
||||
|
||||
if Gitlab['gitlab_rails']['redis_host'] != redis_bind
|
||||
Chef::Log.warn "gitlab-rails 'redis_host' is different than 'bind' value defined for managed redis instance. Are you sure you are pointing to the same redis instance?"
|
||||
end
|
||||
Chef::Log.warn "gitlab-rails 'redis_host' is different than 'bind' value defined for managed redis instance. Are you sure you are pointing to the same redis instance?" if Gitlab['gitlab_rails']['redis_host'] != redis_bind
|
||||
|
||||
if Gitlab['gitlab_rails']['redis_port'] != Gitlab['redis']['port']
|
||||
Chef::Log.warn "gitlab-rails 'redis_port' is different than 'port' value defined for managed redis instance. Are you sure you are pointing to the same redis instance?"
|
||||
end
|
||||
Chef::Log.warn "gitlab-rails 'redis_port' is different than 'port' value defined for managed redis instance. Are you sure you are pointing to the same redis instance?" if Gitlab['gitlab_rails']['redis_port'] != Gitlab['redis']['port']
|
||||
|
||||
Chef::Log.warn "gitlab-rails 'redis_password' is different than 'master_password' value defined for managed redis instance. Are you sure you are pointing to the same redis instance?" if Gitlab['gitlab_rails']['redis_password'] != Gitlab['redis']['master_password']
|
||||
end
|
||||
|
|
|
@ -40,9 +40,7 @@ module Registry
|
|||
|
||||
uri = URI(Gitlab['registry_external_url'].to_s)
|
||||
|
||||
unless uri.host
|
||||
raise "GitLab Container Registry external URL must include a schema and FQDN, e.g. https://registry.example.com/"
|
||||
end
|
||||
raise "GitLab Container Registry external URL must include a schema and FQDN, e.g. https://registry.example.com/" unless uri.host
|
||||
|
||||
Gitlab['registry']['enable'] = true if Gitlab['registry']['enable'].nil?
|
||||
Gitlab['gitlab_rails']['registry_enabled'] = true if Gitlab['registry']['enable']
|
||||
|
@ -76,9 +74,7 @@ module Registry
|
|||
raise "Unsupported GitLab Registry external URL scheme: #{uri.scheme}"
|
||||
end
|
||||
|
||||
unless ["", "/"].include?(uri.path)
|
||||
raise "Unsupported GitLab Registry external URL path: #{uri.path}"
|
||||
end
|
||||
raise "Unsupported GitLab Registry external URL path: #{uri.path}" unless ["", "/"].include?(uri.path)
|
||||
|
||||
# Docker versions before 1.13 will fail to authenticate/push with the
|
||||
# registry if Registry URL contained :80 or :443. So, we don't set the
|
||||
|
|
|
@ -19,8 +19,6 @@ Gitlab[:node] = node
|
|||
|
||||
Services.add_services('gitlab', Services::BaseServices.list)
|
||||
|
||||
if File.exist?('/etc/gitlab/gitlab.rb')
|
||||
Gitlab.from_file('/etc/gitlab/gitlab.rb')
|
||||
end
|
||||
Gitlab.from_file('/etc/gitlab/gitlab.rb') if File.exist?('/etc/gitlab/gitlab.rb')
|
||||
|
||||
node.consume_attributes(Gitlab.generate_config(node['fqdn']))
|
||||
|
|
|
@ -34,9 +34,7 @@ directory "/etc/gitlab" do
|
|||
only_if { node['gitlab']['manage-storage-directories']['manage_etc'] }
|
||||
end.run_action(:create)
|
||||
|
||||
if File.exist?("/var/opt/gitlab/bootstrapped")
|
||||
node.default['gitlab']['bootstrap']['enable'] = false
|
||||
end
|
||||
node.default['gitlab']['bootstrap']['enable'] = false if File.exist?("/var/opt/gitlab/bootstrapped")
|
||||
|
||||
directory "Create /var/opt/gitlab" do
|
||||
path "/var/opt/gitlab"
|
||||
|
@ -108,27 +106,25 @@ include_recipe "package::runit"
|
|||
end
|
||||
end
|
||||
|
||||
if node['gitlab']['gitlab-rails']['enable'] && !node['gitlab']['pgbouncer']['enable']
|
||||
include_recipe "gitlab::database_migrations"
|
||||
end
|
||||
include_recipe "gitlab::database_migrations" if node['gitlab']['gitlab-rails']['enable'] && !node['gitlab']['pgbouncer']['enable']
|
||||
|
||||
# Always create logrotate folders and configs, even if the service is not enabled.
|
||||
# https://gitlab.com/gitlab-org/omnibus-gitlab/issues/508
|
||||
include_recipe "gitlab::logrotate_folders_and_configs"
|
||||
|
||||
# Configure Services
|
||||
[
|
||||
"unicorn",
|
||||
"puma",
|
||||
"sidekiq",
|
||||
"gitlab-workhorse",
|
||||
"mailroom",
|
||||
"nginx",
|
||||
"remote-syslog",
|
||||
"logrotate",
|
||||
"bootstrap",
|
||||
"gitlab-pages",
|
||||
"storage-check"
|
||||
%w[
|
||||
unicorn
|
||||
puma
|
||||
sidekiq
|
||||
gitlab-workhorse
|
||||
mailroom
|
||||
nginx
|
||||
remote-syslog
|
||||
logrotate
|
||||
bootstrap
|
||||
gitlab-pages
|
||||
storage-check
|
||||
].each do |service|
|
||||
if node["gitlab"][service]["enable"]
|
||||
include_recipe "gitlab::#{service}"
|
||||
|
|
|
@ -365,9 +365,7 @@ end
|
|||
gitlab_relative_url = node['gitlab']['gitlab-rails']['gitlab_relative_url']
|
||||
rails_env['RAILS_RELATIVE_URL_ROOT'] = gitlab_relative_url if gitlab_relative_url
|
||||
|
||||
if node['gitlab']['gitlab-rails']['enable_jemalloc']
|
||||
rails_env['LD_PRELOAD'] = "/opt/gitlab/embedded/lib/libjemalloc.so"
|
||||
end
|
||||
rails_env['LD_PRELOAD'] = "/opt/gitlab/embedded/lib/libjemalloc.so" if node['gitlab']['gitlab-rails']['enable_jemalloc']
|
||||
|
||||
env_dir File.join(gitlab_rails_static_etc_dir, 'env') do
|
||||
variables(
|
||||
|
|
|
@ -16,6 +16,4 @@
|
|||
|
||||
include_recipe 'gitlab::config'
|
||||
|
||||
if node['gitlab']['nginx']['enable'] && node['letsencrypt']['enable']
|
||||
include_recipe 'letsencrypt::enable'
|
||||
end
|
||||
include_recipe 'letsencrypt::enable' if node['gitlab']['nginx']['enable'] && node['letsencrypt']['enable']
|
||||
|
|
|
@ -195,16 +195,14 @@ template gitlab_pages_http_conf do
|
|||
pages_path: node['gitlab']['gitlab-rails']['pages_path'],
|
||||
pages_listen_proxy: node['gitlab']['gitlab-pages']['listen_proxy']
|
||||
}
|
||||
))
|
||||
))
|
||||
notifies :restart, 'service[nginx]' if omnibus_helper.should_notify?("nginx")
|
||||
action gitlab_pages_enabled ? :create : :delete
|
||||
end
|
||||
|
||||
registry_nginx_vars = node['gitlab']['registry-nginx'].to_hash
|
||||
|
||||
unless registry_nginx_vars['listen_https'].nil?
|
||||
registry_nginx_vars['https'] = registry_nginx_vars['listen_https']
|
||||
end
|
||||
registry_nginx_vars['https'] = registry_nginx_vars['listen_https'] unless registry_nginx_vars['listen_https'].nil?
|
||||
|
||||
template gitlab_registry_http_conf do
|
||||
source "nginx-gitlab-registry-http.conf.erb"
|
||||
|
@ -220,7 +218,7 @@ template gitlab_registry_http_conf do
|
|||
letsencrypt_enable: node['letsencrypt']['enable'],
|
||||
redirect_http_to_https: node['gitlab']['registry-nginx']['redirect_http_to_https']
|
||||
}
|
||||
))
|
||||
))
|
||||
notifies :restart, 'service[nginx]' if omnibus_helper.should_notify?("nginx")
|
||||
action gitlab_registry_enabled ? :create : :delete
|
||||
end
|
||||
|
@ -247,7 +245,7 @@ template gitlab_mattermost_http_conf do
|
|||
letsencrypt_enable: node['letsencrypt']['enable'],
|
||||
redirect_http_to_https: node['gitlab']['mattermost-nginx']['redirect_http_to_https']
|
||||
}
|
||||
))
|
||||
))
|
||||
notifies :restart, 'service[nginx]' if omnibus_helper.should_notify?("nginx")
|
||||
action gitlab_mattermost_enabled ? :create : :delete
|
||||
end
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
#
|
||||
account_helper = AccountHelper.new(node)
|
||||
|
||||
unless node['gitlab']['unicorn']['worker_processes']
|
||||
node.default['gitlab']['unicorn']['worker_processes'] = Unicorn.workers
|
||||
end
|
||||
node.default['gitlab']['unicorn']['worker_processes'] = Unicorn.workers unless node['gitlab']['unicorn']['worker_processes']
|
||||
|
||||
unicorn_service 'unicorn' do
|
||||
rails_app 'gitlab-rails'
|
||||
|
|
|
@ -68,12 +68,13 @@ class LetsEncrypt
|
|||
|
||||
# Avoid writing if the attribute is there and true
|
||||
return if secrets.dig('letsencrypt', 'auto_enabled')
|
||||
|
||||
SecretsHelper.write_to_gitlab_secrets
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
LETSENCRYPT_ISSUER = %r(/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X[1-4])
|
||||
LETSENCRYPT_ISSUER = %r(/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X[1-4]).freeze
|
||||
|
||||
# Checks wheather the existing Let's Encrypt certificate is expired and needs renewal.
|
||||
#
|
||||
|
|
|
@ -50,9 +50,7 @@ end
|
|||
|
||||
ruby_block 'display_le_message' do
|
||||
block do
|
||||
unless node['letsencrypt']['auto_renew']
|
||||
LoggingHelper.warning("Let's Encrypt integration does not setup any automatic renewal. Please see https://docs.gitlab.com/omnibus/settings/ssl.html#lets-encrypt-integration for more information")
|
||||
end
|
||||
LoggingHelper.warning("Let's Encrypt integration does not setup any automatic renewal. Please see https://docs.gitlab.com/omnibus/settings/ssl.html#lets-encrypt-integration for more information") unless node['letsencrypt']['auto_renew']
|
||||
end
|
||||
action :nothing
|
||||
end
|
||||
|
|
|
@ -8,11 +8,11 @@ property :crt, [String, nil], default: lazy { node['letsencrypt']['crt'] }
|
|||
property :group, [String, nil], default: lazy { node['letsencrypt']['group'] }
|
||||
|
||||
property :chain, [String, nil],
|
||||
deprecated: 'chain has been deprecated since crt now returns the full certificate by default',
|
||||
default: lazy { node['letsencrypt']['chain'] }
|
||||
deprecated: 'chain has been deprecated since crt now returns the full certificate by default',
|
||||
default: lazy { node['letsencrypt']['chain'] }
|
||||
|
||||
deprecated_property_alias :fullchain, :crt,
|
||||
'The fullchain property has been deprecated in favor of crt, and will be removed in GitLab 13.0'
|
||||
'The fullchain property has been deprecated in favor of crt, and will be removed in GitLab 13.0'
|
||||
|
||||
action :create do
|
||||
# Attempt to fetch a certificate from Let's Encrypt staging instance
|
||||
|
|
|
@ -170,6 +170,7 @@ module Prometheus
|
|||
|
||||
def parse_alertmanager_config
|
||||
return unless Services.enabled?('alertmanager')
|
||||
|
||||
user_config = Gitlab['alertmanager']
|
||||
rails_config = Gitlab['gitlab_rails']
|
||||
|
||||
|
@ -221,6 +222,7 @@ module Prometheus
|
|||
def parse_scrape_configs
|
||||
# Don't parse if prometheus is explicitly disabled
|
||||
return unless Services.enabled?('prometheus')
|
||||
|
||||
gitaly_scrape_config
|
||||
gitlab_monitor_scrape_configs
|
||||
registry_scrape_config
|
||||
|
|
|
@ -31,6 +31,7 @@ class PrometheusHelper
|
|||
config << "--no-#{flag_key}"
|
||||
else
|
||||
next if flag_value.empty?
|
||||
|
||||
config << "--#{flag_key}=#{flag_value}"
|
||||
end
|
||||
end
|
||||
|
@ -43,6 +44,7 @@ class PrometheusHelper
|
|||
|
||||
node_service(service)['flags'].each do |flag_key, flag_value|
|
||||
next if flag_value.empty?
|
||||
|
||||
config << "--#{flag_key}=#{flag_value}"
|
||||
end
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ module Gitlab
|
|||
class ConfigMash < Mash
|
||||
def self.auto_vivify
|
||||
return unless block_given?
|
||||
|
||||
begin
|
||||
@auto_vivify = true
|
||||
yield
|
||||
|
|
|
@ -72,6 +72,7 @@ module Gitlab
|
|||
# 6. note: General note regarding removal
|
||||
matching_config = existing_config.dig(*config_keys)
|
||||
return [] unless matching_config
|
||||
|
||||
deprecated_config = matching_config.select { |config| !allowed_keys.include?(config) }
|
||||
deprecated_config.keys.map do |key|
|
||||
{
|
||||
|
|
|
@ -27,9 +27,7 @@ module RolesHelper
|
|||
invalid_roles = active - valid_roles
|
||||
|
||||
# Ensure all active roles exist as valid role names
|
||||
unless invalid_roles.empty?
|
||||
raise "The following invalid roles have been set in 'roles': #{invalid_roles.join(', ')}"
|
||||
end
|
||||
raise "The following invalid roles have been set in 'roles': #{invalid_roles.join(', ')}" unless invalid_roles.empty?
|
||||
|
||||
active.each { |role_name| Gitlab[role_name]['enable'] = true }
|
||||
end
|
||||
|
|
|
@ -35,9 +35,7 @@ class SecretsHelper
|
|||
def self.load_gitlab_secrets
|
||||
existing_secrets = {}
|
||||
|
||||
if File.exist?("/etc/gitlab/gitlab-secrets.json")
|
||||
existing_secrets = Chef::JSONCompat.from_json(File.read("/etc/gitlab/gitlab-secrets.json"))
|
||||
end
|
||||
existing_secrets = Chef::JSONCompat.from_json(File.read("/etc/gitlab/gitlab-secrets.json")) if File.exist?("/etc/gitlab/gitlab-secrets.json")
|
||||
|
||||
existing_secrets
|
||||
end
|
||||
|
@ -58,7 +56,7 @@ class SecretsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def self.gather_gitlab_secrets # rubocop:disable Metrics/AbcSize
|
||||
def self.gather_gitlab_secrets
|
||||
secret_tokens = {
|
||||
'gitlab_workhorse' => {
|
||||
'secret_token' => Gitlab['gitlab_workhorse']['secret_token'],
|
||||
|
|
|
@ -170,9 +170,7 @@ module Services # rubocop:disable Style/MultilineIfModifier (disabled so we can
|
|||
# AND
|
||||
# The current service was requested to be set, or ALL_SERVICES was
|
||||
# requested, so we are setting them all
|
||||
if !exceptions.include?(name) && (services.include?(ALL_SERVICES) || services.include?(name))
|
||||
service_status(name, enable)
|
||||
end
|
||||
service_status(name, enable) if !exceptions.include?(name) && (services.include?(ALL_SERVICES) || services.include?(name))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -188,9 +186,7 @@ module Services # rubocop:disable Style/MultilineIfModifier (disabled so we can
|
|||
# AND
|
||||
# The current service has matching groups that were requested to be set,
|
||||
# or ALL_GROUPS was requested, so we are setting them all
|
||||
if matching_exceptions.empty? && (groups.include?(ALL_GROUPS) || !matching_groups.empty?)
|
||||
service_status(name, enable)
|
||||
end
|
||||
service_status(name, enable) if matching_exceptions.empty? && (groups.include?(ALL_GROUPS) || !matching_groups.empty?)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,6 +45,7 @@ module SettingsHelper
|
|||
# This will convert Gitlab['some_attribute'] to node['example']['some-attribute']
|
||||
def attribute_block(root = nil)
|
||||
return unless block_given?
|
||||
|
||||
begin
|
||||
@_default_parent = root
|
||||
yield
|
||||
|
@ -100,7 +101,7 @@ module SettingsHelper
|
|||
Gitlab::ConfigMash.auto_vivify { super }
|
||||
end
|
||||
|
||||
def method_missing(method_name, *arguments) # rubocop:disable Style/MethodMissing
|
||||
def method_missing(method_name, *arguments) # rubocop:disable Style/MissingRespondToMissing
|
||||
# Give better message for NilClass errors
|
||||
# If there are no arguments passed, this is a 'GET' call, and if
|
||||
# there is no matching key in the configuration, then it has not been set (not even to nil)
|
||||
|
@ -122,6 +123,7 @@ module SettingsHelper
|
|||
# Add the settings to the results
|
||||
sorted_settings.each do |key, value|
|
||||
raise "Attribute parent value invalid for key: #{key} (#{value})" if value[:parent] && !results.key?(value[:parent])
|
||||
|
||||
target = value[:parent] ? results[value[:parent]] : results
|
||||
|
||||
rkey = key.tr('_', '-')
|
||||
|
|
|
@ -27,6 +27,7 @@ class OmnibusHelper # rubocop:disable Style/MultilineIfModifier (disabled so we
|
|||
# need to check both.
|
||||
return node['gitlab'][service_name]['enable'] if node['gitlab'].key?(service_name)
|
||||
return node['monitoring'][service_name]['enable'] if node['monitoring'].key?(service_name)
|
||||
|
||||
node[service_name]['enable']
|
||||
end
|
||||
|
||||
|
@ -87,6 +88,7 @@ class OmnibusHelper # rubocop:disable Style/MultilineIfModifier (disabled so we
|
|||
matching_list = deprecated_os.keys.select { |x| os_string =~ Regexp.new(x) }
|
||||
|
||||
return if matching_list.empty?
|
||||
|
||||
message = <<~EOS
|
||||
Your OS, #{os_string}, will be deprecated soon.
|
||||
Staring with #{deprecated_os[matching_list.first]}, packages will not be built for it.
|
||||
|
@ -97,6 +99,7 @@ class OmnibusHelper # rubocop:disable Style/MultilineIfModifier (disabled so we
|
|||
|
||||
def self.parse_current_version
|
||||
return unless File.exist?("/opt/gitlab/version-manifest.json")
|
||||
|
||||
version_manifest = JSON.parse(File.read("/opt/gitlab/version-manifest.json"))
|
||||
version_components = version_manifest['build_version'].split(".")
|
||||
version_components[0, 2].join(".")
|
||||
|
|
|
@ -27,6 +27,7 @@ property :mode, [String, nil], default: nil
|
|||
|
||||
action :create do
|
||||
next unless node['gitlab']['manage-storage-directories']['enable']
|
||||
|
||||
new_resource.path ||= new_resource.name
|
||||
storage_helper = StorageDirectoryHelper.new(new_resource.owner, new_resource.group, new_resource.mode)
|
||||
|
||||
|
|
|
@ -37,10 +37,10 @@ end
|
|||
ruby_block "Link postgresql bin files to the correct version" do
|
||||
block do
|
||||
db_version = pg_helper.database_version
|
||||
db_path = db_version && Dir.glob("#{postgresql_install_dir}/#{db_version}*").sort.first
|
||||
db_path = db_version && Dir.glob("#{postgresql_install_dir}/#{db_version}*").min
|
||||
|
||||
# Fallback to the psql version if needed
|
||||
pg_path = db_path || Dir.glob("#{postgresql_install_dir}/#{pg_helper.version.major}*").sort.first
|
||||
pg_path = db_path || Dir.glob("#{postgresql_install_dir}/#{pg_helper.version.major}*").min
|
||||
|
||||
raise "Could not find PostgreSQL binaries" unless pg_path
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ file File.join(node['postgresql']['home'], ".profile") do
|
|||
mode "0600"
|
||||
content <<-EOH
|
||||
PATH=#{node['postgresql']['user_path']}
|
||||
EOH
|
||||
EOH
|
||||
end
|
||||
|
||||
gitlab_sysctl "kernel.shmmax" do
|
||||
|
|
|
@ -46,7 +46,7 @@ class RepmgrHelper < BaseHelper
|
|||
else
|
||||
node['fqdn']
|
||||
end
|
||||
Digest::MD5.hexdigest(seed_data).unpack('L').first
|
||||
Digest::MD5.hexdigest(seed_data).unpack1('L')
|
||||
end
|
||||
|
||||
def public_attributes
|
||||
|
|
|
@ -27,6 +27,7 @@ module Geo
|
|||
|
||||
def check_gitlab_active?
|
||||
return unless gitlab_is_active?
|
||||
|
||||
if @options[:force]
|
||||
puts "Found data inside the #{db_name} database! Proceeding because --force was supplied".color(:yellow)
|
||||
else
|
||||
|
@ -37,12 +38,14 @@ module Geo
|
|||
|
||||
def check_service_enabled?
|
||||
return if ctl.service_enabled?('postgresql')
|
||||
|
||||
puts 'There is no PostgreSQL instance enabled in omnibus, exiting...'.color(:red)
|
||||
Kernel.exit 1
|
||||
end
|
||||
|
||||
def confirm_replication
|
||||
return if @options[:now]
|
||||
|
||||
puts '*** Are you sure you want to continue (replicate/no)? ***'.color(:yellow)
|
||||
|
||||
loop do
|
||||
|
@ -50,6 +53,7 @@ module Geo
|
|||
answer = STDIN.gets.to_s.strip
|
||||
|
||||
break if answer == 'replicate'
|
||||
|
||||
exit 0 if answer == 'no'
|
||||
|
||||
puts "*** You entered `#{answer}` instead of `replicate` or `no`.".color(:red)
|
||||
|
|
|
@ -65,9 +65,8 @@ module Pgbouncer
|
|||
|
||||
def data_path=(path)
|
||||
full_path = "#{path}/pgbouncer"
|
||||
unless Dir.exist?(full_path)
|
||||
raise "The directory #{full_path} does not exist. Please ensure pgbouncer is configured on this node"
|
||||
end
|
||||
raise "The directory #{full_path} does not exist. Please ensure pgbouncer is configured on this node" unless Dir.exist?(full_path)
|
||||
|
||||
@data_path = full_path
|
||||
end
|
||||
|
||||
|
@ -95,9 +94,9 @@ module Pgbouncer
|
|||
"#{build_command_line} -c '#{command}'",
|
||||
options['host_user']
|
||||
)
|
||||
rescue GitlabCtl::Errors::ExecutionError => results
|
||||
$stderr.puts "Error running command: #{results}"
|
||||
$stderr.puts "ERROR: #{results.stderr}"
|
||||
rescue GitlabCtl::Errors::ExecutionError => e
|
||||
$stderr.puts "Error running command: #{e}"
|
||||
$stderr.puts "ERROR: #{e.stderr}"
|
||||
raise
|
||||
end
|
||||
|
||||
|
@ -150,6 +149,7 @@ module Pgbouncer
|
|||
def notify
|
||||
# If we haven't written databases.json yet, don't do anything
|
||||
return if databases.nil?
|
||||
|
||||
write
|
||||
resume_if_paused
|
||||
begin
|
||||
|
|
|
@ -119,11 +119,12 @@ class Repmgr
|
|||
rescue Mixlib::ShellOut::CommandTimeout
|
||||
$stderr.puts "Timeout running command: #{results.command}"
|
||||
raise
|
||||
rescue StandardError => se
|
||||
puts "Unknown Error: #{se}"
|
||||
rescue StandardError => e
|
||||
puts "Unknown Error: #{e}"
|
||||
end
|
||||
# repmgr logs most output to stderr by default
|
||||
return results.stdout unless results.stdout.empty?
|
||||
|
||||
results.stderr
|
||||
end
|
||||
|
||||
|
@ -162,6 +163,7 @@ class Repmgr
|
|||
|
||||
def unregister(args)
|
||||
return repmgr_cmd(args, "standby unregister --node=#{args[:node]}") unless args[:node].nil?
|
||||
|
||||
repmgr_cmd(args, "standby unregister")
|
||||
end
|
||||
|
||||
|
@ -223,7 +225,7 @@ class Repmgr
|
|||
elsif args.key?(:node_id)
|
||||
query << "id='#{args[:node_id]}'"
|
||||
end
|
||||
user = args[:user] ? args[:user] : nil
|
||||
user = args[:user] || nil
|
||||
execute_psql(database: 'gitlab_repmgr', query: query, host: '127.0.0.1', port: 5432, user: user)
|
||||
end
|
||||
end
|
||||
|
@ -269,6 +271,7 @@ class Repmgr
|
|||
|
||||
def repmgrd_failover_promote(node_id, success, timestamp, details)
|
||||
raise Repmgr::EventError, "We tried to failover at #{timestamp}, but failed with: #{details}" unless success.eql?('1')
|
||||
|
||||
old_master = details.match(/old master (\d+) marked as failed/)[1]
|
||||
Consul::Kv.put("gitlab/ha/postgresql/failed_masters/#{old_master}")
|
||||
end
|
||||
|
|
|
@ -137,8 +137,8 @@ end
|
|||
def get_client
|
||||
begin
|
||||
pgb = Pgbouncer::Databases.new(get_pg_options, base_path, data_path)
|
||||
rescue RuntimeError => rte
|
||||
log rte.message
|
||||
rescue RuntimeError => e
|
||||
log e.message
|
||||
exit 1
|
||||
end
|
||||
pgb
|
||||
|
|
|
@ -25,7 +25,7 @@ add_command_under_category('repmgr', 'database', 'Manage repmgr PostgreSQL clust
|
|||
{
|
||||
primary: repmgr_primary,
|
||||
user: repmgr_options[:user] || node_attributes['repmgr']['user'],
|
||||
database: node_attributes['repmgr']['database'],
|
||||
database: node_attributes['repmgr']['database'],
|
||||
directory: postgresql_directory,
|
||||
verbose: repmgr_options[:verbose],
|
||||
wait: repmgr_options[:wait],
|
||||
|
@ -42,13 +42,11 @@ add_command_under_category('repmgr', 'database', 'Manage repmgr PostgreSQL clust
|
|||
rescue Mixlib::ShellOut::ShellCommandFailed
|
||||
exit 1
|
||||
rescue NoMethodError
|
||||
if repmgr_command
|
||||
$stderr.puts "The repmgr command #{repmgr_command} does not support #{repmgr_subcommand}"
|
||||
end
|
||||
$stderr.puts "The repmgr command #{repmgr_command} does not support #{repmgr_subcommand}" if repmgr_command
|
||||
puts repmgr_help
|
||||
exit 1
|
||||
rescue NameError => ne
|
||||
puts ne
|
||||
rescue NameError => e
|
||||
puts e
|
||||
$stderr.puts "There is no repmgr command #{repmgr_command}"
|
||||
puts repmgr_help
|
||||
exit 1
|
||||
|
@ -64,8 +62,8 @@ add_command_under_category('repmgr-check-master', 'database', 'Check if the curr
|
|||
else
|
||||
Kernel.exit 1
|
||||
end
|
||||
rescue Repmgr::MasterError => se
|
||||
$stderr.puts "Error checking for master: #{se}"
|
||||
rescue Repmgr::MasterError => e
|
||||
$stderr.puts "Error checking for master: #{e}"
|
||||
Kernel.exit 3
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,6 +36,7 @@ module GitlabCtl
|
|||
|
||||
def tmp_data_dir
|
||||
return @tmp_data_dir if @tmp_data_dir
|
||||
|
||||
@tmp_data_dir = @tmp_dir ? "#{@tmp_dir}/data" : data_dir
|
||||
end
|
||||
|
||||
|
@ -101,10 +102,10 @@ module GitlabCtl
|
|||
"--new-datadir=#{tmp_data_dir}.#{upgrade_version.major} " \
|
||||
"-B #{base_path}/embedded/bin"
|
||||
)
|
||||
rescue GitlabCtl::Errors::ExecutionError => ee
|
||||
rescue GitlabCtl::Errors::ExecutionError => e
|
||||
$stderr.puts "Error upgrading the data to version #{upgrade_version}"
|
||||
$stderr.puts "STDOUT: #{ee.stdout}"
|
||||
$stderr.puts "STDERR: #{ee.stderr}"
|
||||
$stderr.puts "STDOUT: #{e.stdout}"
|
||||
$stderr.puts "STDERR: #{e.stderr}"
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ module GitlabCtl
|
|||
|
||||
# Sample output of prometheus --version is
|
||||
# prometheus, version 1.8.2 (branch: master, revision: 6aa68e74cdc25a7d95f3f120ccc8eddd46e3c07b)
|
||||
VERSION_REGEX = %r{.*?version (?<version>.*?) .*?}
|
||||
VERSION_REGEX = %r{.*?version (?<version>.*?) .*?}.freeze
|
||||
|
||||
def initialize(base_path, home_dir)
|
||||
@base_path = base_path
|
||||
|
|
|
@ -45,12 +45,12 @@ module GitlabCtl
|
|||
data = JSON.parse(File.read(file))
|
||||
rescue JSON::ParserError
|
||||
raise GitlabCtl::Errors::NodeError,
|
||||
"Error reading #{file}, has reconfigure been run yet?"
|
||||
"Error reading #{file}, has reconfigure been run yet?"
|
||||
end
|
||||
|
||||
if file.start_with?('/opt/gitlab/embedded/nodes') && !data.key?('normal')
|
||||
raise GitlabCtl::Errors::NodeError,
|
||||
"Attributes not found in #{file}, has reconfigure been run yet?"
|
||||
"Attributes not found in #{file}, has reconfigure been run yet?"
|
||||
end
|
||||
data
|
||||
end
|
||||
|
|
|
@ -47,9 +47,7 @@ class PostgreSQL
|
|||
node_attributes.dig('postgresql', 'sql_replication_user')).to_s
|
||||
|
||||
configured_user.tap do |user|
|
||||
if user.strip.empty?
|
||||
raise ArgumentError, 'Replication user not defined in `sql_replication_user`!'
|
||||
end
|
||||
raise ArgumentError, 'Replication user not defined in `sql_replication_user`!' if user.strip.empty?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ end
|
|||
add_command_under_category 'pg-upgrade', 'database',
|
||||
'Upgrade the PostgreSQL DB to the latest supported version',
|
||||
2 do |_cmd_name|
|
||||
|
||||
options = GitlabCtl::PgUpgrade.parse_options(ARGV)
|
||||
@db_worker = GitlabCtl::PgUpgrade.new(
|
||||
base_path,
|
||||
|
@ -122,9 +121,9 @@ add_command_under_category 'pg-upgrade', 'database',
|
|||
|
||||
begin
|
||||
@db_worker.start
|
||||
rescue Mixlib::ShellOut::ShellCommandFailed => scf
|
||||
rescue Mixlib::ShellOut::ShellCommandFailed => e
|
||||
log "Error starting the database. Please fix the error before continuing"
|
||||
log scf.message
|
||||
log e.message
|
||||
Kernel.exit 1
|
||||
end
|
||||
end
|
||||
|
@ -256,11 +255,11 @@ def get_locale_encoding
|
|||
locale = @db_worker.fetch_lc_ctype
|
||||
collate = @db_worker.fetch_lc_collate
|
||||
encoding = @db_worker.fetch_server_encoding
|
||||
rescue GitlabCtl::Errors::ExecutionError => ee
|
||||
rescue GitlabCtl::Errors::ExecutionError => e
|
||||
log 'There wasn an error fetching locale and encoding information from the database'
|
||||
log 'Please ensure the database is running and functional before running pg-upgrade'
|
||||
log "STDOUT: #{ee.stdout}"
|
||||
log "STDERR: #{ee.stderr}"
|
||||
log "STDOUT: #{e.stdout}"
|
||||
log "STDERR: #{e.stderr}"
|
||||
end
|
||||
|
||||
[locale, collate, encoding]
|
||||
|
@ -272,10 +271,10 @@ def create_temp_data_dir
|
|||
@db_worker.run_pg_command(
|
||||
"mkdir -p #{@db_worker.tmp_data_dir}.#{upgrade_version.major}"
|
||||
)
|
||||
rescue GitlabCtl::Errors::ExecutionError => ee
|
||||
rescue GitlabCtl::Errors::ExecutionError => e
|
||||
log "Error creating new directory: #{@db_worker.tmp_data_dir}.#{upgrade_version.major}"
|
||||
log "STDOUT: #{ee.stdout}"
|
||||
log "STDERR: #{ee.stderr}"
|
||||
log "STDOUT: #{e.stdout}"
|
||||
log "STDERR: #{e.stderr}"
|
||||
false
|
||||
else
|
||||
true
|
||||
|
@ -296,10 +295,10 @@ def initialize_new_db(locale, collate, encoding)
|
|||
" --lc-collate=#{collate} " \
|
||||
"--lc-ctype=#{locale}"
|
||||
)
|
||||
rescue GitlabCtl::Errors::ExecutionError => ee
|
||||
rescue GitlabCtl::Errors::ExecutionError => e
|
||||
log "Error initializing database for #{upgrade_version}"
|
||||
log "STDOUT: #{ee.stdout}"
|
||||
log "STDERR: #{ee.stderr}"
|
||||
log "STDOUT: #{e.stdout}"
|
||||
log "STDERR: #{e.stderr}"
|
||||
GitlabCtl::PgUpgrade.die 'Please check the output and try again'
|
||||
end
|
||||
end
|
||||
|
@ -340,10 +339,10 @@ def analyze_cluster
|
|||
)
|
||||
begin
|
||||
@db_worker.run_pg_command("/bin/sh #{analyze_script}")
|
||||
rescue GitlabCtl::Errors::ExecutionError => ee
|
||||
rescue GitlabCtl::Errors::ExecutionError => e
|
||||
log 'Error running analyze_new_cluster.sh'
|
||||
log "STDOUT: #{ee.stdout}"
|
||||
log "STDERR: #{ee.stderr}"
|
||||
log "STDOUT: #{e.stdout}"
|
||||
log "STDERR: #{e.stderr}"
|
||||
log 'Please check the output, and rerun the command if needed:'
|
||||
log "/bin/sh #{analyze_script}"
|
||||
log 'If the error persists, please open an issue at: '
|
||||
|
@ -352,12 +351,9 @@ def analyze_cluster
|
|||
end
|
||||
|
||||
def version_from_manifest(software)
|
||||
if @versions.nil?
|
||||
@versions = JSON.parse(File.read("#{base_path}/version-manifest.json"))
|
||||
end
|
||||
if @versions['software'].key?(software)
|
||||
return @versions['software'][software]['described_version']
|
||||
end
|
||||
@versions = JSON.parse(File.read("#{base_path}/version-manifest.json")) if @versions.nil?
|
||||
return @versions['software'][software]['described_version'] if @versions['software'].key?(software)
|
||||
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
require "#{base_path}/embedded/service/omnibus-ctl/lib/gitlab_ctl"
|
||||
|
||||
add_command 'prometheus-upgrade', 'Upgrade the Prometheus data to the latest supported version',
|
||||
2 do |_cmd_name|
|
||||
|
||||
2 do |_cmd_name|
|
||||
unless service_enabled?('prometheus')
|
||||
log "Prometheus not enabled."
|
||||
Kernel.exit 0
|
||||
|
|
|
@ -71,6 +71,7 @@ add_command 'upgrade', 'Run migrations after a package upgrade', 1 do |cmd_name|
|
|||
SERVICE_WAIT.times do
|
||||
status = run_sv_command_for_service('status', sv_name)
|
||||
break if status.zero?
|
||||
|
||||
sleep 1
|
||||
end
|
||||
|
||||
|
@ -128,9 +129,7 @@ add_command 'upgrade', 'Run migrations after a package upgrade', 1 do |cmd_name|
|
|||
|
||||
log 'Restarting previously running GitLab services'
|
||||
get_all_services.each do |sv_name|
|
||||
if /^run: #{sv_name}:/.match?(service_statuses)
|
||||
run_sv_command_for_service('start', sv_name)
|
||||
end
|
||||
run_sv_command_for_service('start', sv_name) if /^run: #{sv_name}:/.match?(service_statuses)
|
||||
end
|
||||
|
||||
print_upgrade_and_exit
|
||||
|
@ -143,6 +142,7 @@ def stale_files_check
|
|||
# file is always the file to keep, and it's name is excluded from the output to the user.
|
||||
sprocket_files = Dir.glob("#{base_path}/embedded/service/gitlab-rails/public/assets/.sprockets-manifest*").sort_by { |f| File.ctime(f) }
|
||||
return unless sprocket_files.size > 1
|
||||
|
||||
puts "WARNING:"
|
||||
puts "GitLab discovered stale file(s) from a previous install that need to be cleaned up."
|
||||
puts "The following files need to be removed:"
|
||||
|
|
|
@ -108,7 +108,7 @@ Trigger:ee-package:
|
|||
rubocop:
|
||||
stage: check
|
||||
<<: *dedicated-runner
|
||||
image: ruby:2.4
|
||||
image: ruby:2.6
|
||||
before_script:
|
||||
- bundle install -j $(nproc) --binstubs --path gems --without default test
|
||||
script:
|
||||
|
|
|
@ -3,7 +3,7 @@ require_relative 'build/info.rb'
|
|||
require_relative 'util.rb'
|
||||
|
||||
class AWSHelper
|
||||
VERSION_REGEX = /\A(?<version>\d+\.\d+\.\d+)-?(?<type>(ee|ce))?\z/
|
||||
VERSION_REGEX = /\A(?<version>\d+\.\d+\.\d+)-?(?<type>(ee|ce))?\z/.freeze
|
||||
|
||||
def initialize(version, type)
|
||||
# version specifies the GitLab version being processed
|
||||
|
@ -11,9 +11,7 @@ class AWSHelper
|
|||
|
||||
@version = version
|
||||
@type = type || 'ce'
|
||||
if @type == 'ee' && Gitlab::Util.get_env("EE_ULTIMATE_AMI") == "true"
|
||||
@type = 'ee-ultimate'
|
||||
end
|
||||
@type = 'ee-ultimate' if @type == 'ee' && Gitlab::Util.get_env("EE_ULTIMATE_AMI") == "true"
|
||||
@clients = {}
|
||||
@download_url = Build::Info.package_download_url
|
||||
end
|
||||
|
@ -71,6 +69,7 @@ class AWSHelper
|
|||
images = list_images(region)
|
||||
images.each do |image|
|
||||
next unless Gem::Version.new(image_version(image)) < Gem::Version.new(@version)
|
||||
|
||||
puts "\t#{image.image_id} - #{image.name} - #{image_version(image)}"
|
||||
|
||||
# Commenting out actual deregister code temporarily for first few releases
|
||||
|
|
|
@ -3,7 +3,7 @@ require_relative "../util.rb"
|
|||
|
||||
module Build
|
||||
class Check
|
||||
AUTO_DEPLOY_TAG_REGEX = /^\d+\.\d+\.\d+\+[^ ]{7,}\.[^ ]{7,}$/
|
||||
AUTO_DEPLOY_TAG_REGEX = /^\d+\.\d+\.\d+\+[^ ]{7,}\.[^ ]{7,}$/.freeze
|
||||
class << self
|
||||
def is_ee?
|
||||
Gitlab::Util.get_env('ee') == 'true' || \
|
||||
|
|
|
@ -22,7 +22,7 @@ module Build
|
|||
{
|
||||
'ref' => 'master',
|
||||
'token' => Gitlab::Util.get_env('HA_VALIDATE_TOKEN'),
|
||||
'variables[QA_IMAGE]' => qa_image,
|
||||
'variables[QA_IMAGE]' => qa_image,
|
||||
'variables[PACKAGE_URL]' => package_url
|
||||
}
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@ module Build
|
|||
{
|
||||
'ref' => 'master',
|
||||
'token' => Gitlab::Util.get_env('HA_VALIDATE_TOKEN'),
|
||||
'variables[QA_IMAGE]' => qa_image,
|
||||
'variables[QA_IMAGE]' => qa_image,
|
||||
'variables[OMNIBUS_JOB_ID]' => ee_package_job_id
|
||||
}
|
||||
end
|
||||
|
|
|
@ -148,7 +148,7 @@ module Build
|
|||
|
||||
def fetch_artifact_url(project_id, pipeline_id)
|
||||
output = get_api("projects/#{project_id}/pipelines/#{pipeline_id}/jobs")
|
||||
output.map { |job| job['id'] if job['name'] == 'Trigger:package' }.compact.sort.last
|
||||
output.map { |job| job['id'] if job['name'] == 'Trigger:package' }.compact.max
|
||||
end
|
||||
|
||||
def fetch_pipeline_jobs(project_id, pipeline_id, token)
|
||||
|
|
|
@ -93,7 +93,7 @@ module Build
|
|||
|
||||
def append_to_sheet(version, duration)
|
||||
# Append duration to Google Sheets where a chart will be generated
|
||||
service_account_file = File.expand_path("../../../../service_account.json", __FILE__)
|
||||
service_account_file = File.expand_path('../../../service_account.json', __dir__)
|
||||
session = GoogleDrive::Session.from_service_account_key(service_account_file)
|
||||
spreadsheet = session.spreadsheet_by_title("GitLab EE Upgrade Metrics")
|
||||
worksheet = spreadsheet.worksheets.first
|
||||
|
|
|
@ -20,9 +20,7 @@ class OhaiHelper
|
|||
os = os_platform
|
||||
version = os_platform_version
|
||||
|
||||
if (os == :unknown) || (version == :unknown)
|
||||
abort "Unsupported OS: #{ohai.values_at('platform', 'platform_version').inspect}"
|
||||
end
|
||||
abort "Unsupported OS: #{ohai.values_at('platform', 'platform_version').inspect}" if (os == :unknown) || (version == :unknown)
|
||||
|
||||
[os, version]
|
||||
end
|
||||
|
|
|
@ -12,11 +12,7 @@ class PackageRepository
|
|||
return Gitlab::Util.get_env('RASPBERRY_REPO') if Gitlab::Util.get_env('RASPBERRY_REPO') && !Gitlab::Util.get_env('RASPBERRY_REPO').empty?
|
||||
|
||||
rc_repository = repository_for_rc
|
||||
if rc_repository
|
||||
rc_repository
|
||||
else
|
||||
Build::Info.package
|
||||
end
|
||||
rc_repository || Build::Info.package
|
||||
end
|
||||
|
||||
def repository_for_rc
|
||||
|
@ -44,9 +40,7 @@ class PackageRepository
|
|||
# For CentOS 6 and 7 we will upload the same package to Scientific and Oracle Linux
|
||||
# For all other OSs, we only upload one package.
|
||||
upload_list = package_list(repository)
|
||||
if upload_list.empty?
|
||||
raise "No packages found for upload. Are artifacts available?"
|
||||
end
|
||||
raise "No packages found for upload. Are artifacts available?" if upload_list.empty?
|
||||
|
||||
validate(dry_run)
|
||||
|
||||
|
@ -62,6 +56,7 @@ class PackageRepository
|
|||
|
||||
if $CHILD_STATUS.exitstatus == 1
|
||||
raise "Upload to package server failed!." unless /filename: has already been taken/.match?(result)
|
||||
|
||||
puts "Package #{pkg} has already been uploaded, skipping.\n"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,8 +35,6 @@ namespace :cache do
|
|||
desc "Restore cache bundle"
|
||||
task :restore do
|
||||
platform_dir = OhaiHelper.platform_dir
|
||||
if File.exist?("cache/#{platform_dir}") && File.file?("cache/#{platform_dir}")
|
||||
system(*%W[git clone --mirror cache/#{platform_dir} /var/cache/omnibus/cache/git_cache/opt/gitlab])
|
||||
end
|
||||
system(*%W[git clone --mirror cache/#{platform_dir} /var/cache/omnibus/cache/git_cache/opt/gitlab]) if File.exist?("cache/#{platform_dir}") && File.file?("cache/#{platform_dir}")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,23 +32,17 @@ namespace :docker do
|
|||
|
||||
# Special tags
|
||||
task :nightly do
|
||||
if Build::Check.is_nightly?
|
||||
Build::GitlabImage.tag_and_push_to_dockerhub('nightly')
|
||||
end
|
||||
Build::GitlabImage.tag_and_push_to_dockerhub('nightly') if Build::Check.is_nightly?
|
||||
end
|
||||
|
||||
# push as :rc tag, the :rc is always the latest tagged release
|
||||
task :rc do
|
||||
if Build::Check.is_latest_tag?
|
||||
Build::GitlabImage.tag_and_push_to_dockerhub('rc')
|
||||
end
|
||||
Build::GitlabImage.tag_and_push_to_dockerhub('rc') if Build::Check.is_latest_tag?
|
||||
end
|
||||
|
||||
# push as :latest tag, the :latest is always the latest stable release
|
||||
task :latest do
|
||||
if Build::Check.is_latest_stable_tag?
|
||||
Build::GitlabImage.tag_and_push_to_dockerhub('latest')
|
||||
end
|
||||
Build::GitlabImage.tag_and_push_to_dockerhub('latest') if Build::Check.is_latest_stable_tag?
|
||||
end
|
||||
|
||||
desc "Push triggered Docker Image to GitLab Registry"
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace :gitlab_com do
|
|||
# directly to production from the omnibus pipeline, this check is here
|
||||
# for safety
|
||||
raise NotImplementedError, "Environment #{deploy_env} is not supported" if deploy_env == 'gprd'
|
||||
|
||||
deployer_helper = DeployerHelper.new(trigger_token, deploy_env, trigger_ref)
|
||||
url = deployer_helper.trigger_deploy
|
||||
puts "Deployer build triggered at #{url} on #{trigger_ref} for the #{deploy_env} environment"
|
||||
|
|
|
@ -36,23 +36,17 @@ namespace :qa do
|
|||
|
||||
desc "Push rc version of gitlab-{ce,ee}-qa to Docker Hub"
|
||||
task :rc do
|
||||
if Build::Check.is_latest_tag?
|
||||
Build::QAImage.tag_and_push_to_dockerhub('rc', initial_tag: 'latest')
|
||||
end
|
||||
Build::QAImage.tag_and_push_to_dockerhub('rc', initial_tag: 'latest') if Build::Check.is_latest_tag?
|
||||
end
|
||||
|
||||
desc "Push nightly version of gitlab-{ce,ee}-qa to Docker Hub"
|
||||
task :nightly do
|
||||
if Build::Check.is_nightly?
|
||||
Build::QAImage.tag_and_push_to_dockerhub('nightly', initial_tag: 'latest')
|
||||
end
|
||||
Build::QAImage.tag_and_push_to_dockerhub('nightly', initial_tag: 'latest') if Build::Check.is_nightly?
|
||||
end
|
||||
|
||||
desc "Push latest version of gitlab-{ce,ee}-qa to Docker Hub"
|
||||
task :latest do
|
||||
if Build::Check.is_latest_stable_tag?
|
||||
Build::QAImage.tag_and_push_to_dockerhub('latest', initial_tag: 'latest')
|
||||
end
|
||||
Build::QAImage.tag_and_push_to_dockerhub('latest', initial_tag: 'latest') if Build::Check.is_latest_stable_tag?
|
||||
end
|
||||
|
||||
desc "Push triggered version of gitlab-{ce,ee}-qa to the GitLab registry"
|
||||
|
|
|
@ -7,11 +7,7 @@ module Gitlab
|
|||
def initialize(software_name, version = nil)
|
||||
@software = software_name
|
||||
|
||||
@read_version = if version
|
||||
version
|
||||
else
|
||||
get_software_version
|
||||
end
|
||||
@read_version = version || get_software_version
|
||||
@project_root = File.join(File.dirname(__dir__), '../')
|
||||
@software_sources = Gitlab::Util.get_env("ALTERNATIVE_SOURCES").to_s == "true" ? "alternative" : "remote"
|
||||
end
|
||||
|
@ -71,9 +67,7 @@ module Gitlab
|
|||
# If it satisfy both, it is probably a branch name or a SHA
|
||||
# commit of one of our own component so it doesn't need `v` prepended
|
||||
if components_files.key?(@software)
|
||||
unless /^\d+\.\d+\.\d+(-rc\d+)?(-ee)?$/.match?(@read_version)
|
||||
return @read_version
|
||||
end
|
||||
return @read_version unless /^\d+\.\d+\.\d+(-rc\d+)?(-ee)?$/.match?(@read_version)
|
||||
end
|
||||
v = "v" if prepend_version
|
||||
[
|
||||
|
|
|
@ -6,15 +6,11 @@ fail "Please add labels to this merge request." if gitlab.mr_labels.empty?
|
|||
|
||||
warn "You may want to add ~Distribution label to this MR for gitlab-insights" unless gitlab.mr_labels.include?("Distribution")
|
||||
|
||||
unless gitlab.mr_json["assignee"]
|
||||
warn "This merge request does not have any assignee yet. Setting an assignee clarifies who needs to take action on the merge request at any given time."
|
||||
end
|
||||
warn "This merge request does not have any assignee yet. Setting an assignee clarifies who needs to take action on the merge request at any given time." unless gitlab.mr_json["assignee"]
|
||||
|
||||
has_milestone = !gitlab.mr_json["milestone"].nil?
|
||||
|
||||
unless has_milestone
|
||||
warn "This merge request does not refer to an existing milestone.", sticky: false
|
||||
end
|
||||
warn "This merge request does not refer to an existing milestone.", sticky: false unless has_milestone
|
||||
|
||||
has_pick_into_stable_label = gitlab.mr_labels.find { |label| label.start_with?('Pick into') }
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# rubocop:disable Style/SignalException
|
||||
|
||||
QA_LABELS = %w[backstage QA test].freeze
|
||||
|
||||
MESSAGE = <<~MSG.freeze
|
||||
|
@ -41,8 +39,4 @@ all_files = git.added_files + git.modified_files
|
|||
has_config_changes = !library_paths_requiring_review(all_files).empty?
|
||||
manual_check_needed = (gitlab.mr_labels & QA_LABELS).empty?
|
||||
|
||||
if has_config_changes && !manual_check_needed
|
||||
warn format(MESSAGE, labels: qa_labels)
|
||||
end
|
||||
|
||||
# rubocop:enable Style/SignalException
|
||||
warn format(MESSAGE, labels: qa_labels) if has_config_changes && !manual_check_needed
|
||||
|
|
|
@ -52,6 +52,4 @@ to gitlab.rb.template located in files/gitlab-config-template/gitlab.rb.template
|
|||
Otherwise, please consider adding the ~backstage label in that case.
|
||||
MSG
|
||||
|
||||
if !git.modified_files.include?('files/gitlab-config-template/gitlab.rb.template') && !configuration_paths_to_review.empty?
|
||||
warn NO_TEMPLATE_CHANGE_MESSAGE, sticky: false
|
||||
end
|
||||
warn NO_TEMPLATE_CHANGE_MESSAGE, sticky: false if !git.modified_files.include?('files/gitlab-config-template/gitlab.rb.template') && !configuration_paths_to_review.empty?
|
||||
|
|
|
@ -2,7 +2,7 @@ require_relative '../../../../files/gitlab-cookbooks/gitlab-ee/libraries/fdw_hel
|
|||
require 'chef_helper'
|
||||
|
||||
describe FdwHelper do
|
||||
let(:chef_run) { converge_config(ee: true) }
|
||||
let(:chef_run) { converge_config(is_ee: true) }
|
||||
subject { described_class.new(chef_run.node) }
|
||||
|
||||
before do
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'chef_helper'
|
||||
|
||||
describe PgbouncerHelper do
|
||||
let(:chef_run) { converge_config(ee: true) }
|
||||
let(:chef_run) { converge_config(is_ee: true) }
|
||||
subject { described_class.new(chef_run.node) }
|
||||
|
||||
before do
|
||||
|
|
|
@ -113,7 +113,7 @@ witness_repl_nodes_sync_interval_secs=15
|
|||
it 'creates pg_hba.conf with custom entries and repmgr entries' do
|
||||
stub_gitlab_rb(
|
||||
postgresql: {
|
||||
custom_pg_hba_entries: {
|
||||
custom_pg_hba_entries: {
|
||||
postgres: [
|
||||
{
|
||||
type: 'host',
|
||||
|
|
|
@ -151,9 +151,9 @@ describe 'monitoring::grafana' do
|
|||
gitlab_application_id: 'appid',
|
||||
gitlab_secret: 'secret',
|
||||
gitlab_auth_sign_up: false,
|
||||
allowed_groups: [
|
||||
'allowed',
|
||||
'also-allowed',
|
||||
allowed_groups: %w[
|
||||
allowed
|
||||
also-allowed
|
||||
],
|
||||
env: {
|
||||
'USER_SETTING' => 'asdf1234'
|
||||
|
|
|
@ -69,7 +69,7 @@ describe 'gitlab::config' do
|
|||
|
||||
context 'with roles' do
|
||||
context 'when redis_sentinel_role is enabled' do
|
||||
cached(:chef_run) { converge_config(ee: true) }
|
||||
cached(:chef_run) { converge_config(is_ee: true) }
|
||||
before do
|
||||
stub_gitlab_rb(
|
||||
redis_sentinel_role: {
|
||||
|
@ -93,7 +93,7 @@ describe 'gitlab::config' do
|
|||
end
|
||||
|
||||
context 'when redis_sentinel_role is enabled with redis_master_role' do
|
||||
cached(:chef_run) { converge_config(ee: true) }
|
||||
cached(:chef_run) { converge_config(is_ee: true) }
|
||||
before do
|
||||
stub_gitlab_rb(
|
||||
redis_sentinel_role: {
|
||||
|
@ -117,7 +117,7 @@ describe 'gitlab::config' do
|
|||
end
|
||||
|
||||
context 'when redis_sentinel_role is enabled with redis_slave_role' do
|
||||
cached(:chef_run) { converge_config(ee: true) }
|
||||
cached(:chef_run) { converge_config(is_ee: true) }
|
||||
before do
|
||||
stub_gitlab_rb(
|
||||
redis_sentinel_role: {
|
||||
|
@ -147,7 +147,7 @@ describe 'gitlab::config' do
|
|||
end
|
||||
|
||||
context 'when redis_master_role is enabled' do
|
||||
cached(:chef_run) { converge_config(ee: true) }
|
||||
cached(:chef_run) { converge_config(is_ee: true) }
|
||||
before do
|
||||
stub_gitlab_rb(
|
||||
redis_master_role: {
|
||||
|
@ -168,7 +168,7 @@ describe 'gitlab::config' do
|
|||
end
|
||||
|
||||
context 'when redis_slave_role is enabled' do
|
||||
cached(:chef_run) { converge_config(ee: true) }
|
||||
cached(:chef_run) { converge_config(is_ee: true) }
|
||||
before do
|
||||
stub_gitlab_rb(
|
||||
redis_slave_role: {
|
||||
|
@ -191,7 +191,7 @@ describe 'gitlab::config' do
|
|||
end
|
||||
|
||||
context 'when redis_master_role and redis_slave_role are enabled' do
|
||||
cached(:chef_run) { converge_config(ee: true) }
|
||||
cached(:chef_run) { converge_config(is_ee: true) }
|
||||
before do
|
||||
stub_gitlab_rb(
|
||||
redis_master_role: {
|
||||
|
|
|
@ -75,7 +75,7 @@ server {
|
|||
access_log /var/log/gitlab/nginx/gitlab_access.log gitlab_access;
|
||||
error_log /var/log/gitlab/nginx/gitlab_error.log;
|
||||
}
|
||||
EOF
|
||||
EOF
|
||||
end
|
||||
|
||||
before do
|
||||
|
|
|
@ -16,7 +16,7 @@ describe 'gitlab::rails-cache-clear' do
|
|||
let(:clear_cache_exec) { chef_run.execute('clear the gitlab-rails cache') }
|
||||
let(:gilab_yml_temp) do
|
||||
chef_run.find_resource(:templatesymlink,
|
||||
'Create a gitlab.yml and create a symlink to Rails root')
|
||||
'Create a gitlab.yml and create a symlink to Rails root')
|
||||
end
|
||||
|
||||
it 'check rake_cache_clear default attribute value set to true' do
|
||||
|
|
|
@ -4,8 +4,8 @@ require 'base64'
|
|||
describe 'secrets' do
|
||||
let(:chef_run) { ChefSpec::SoloRunner.new.converge('gitlab::default') }
|
||||
|
||||
HEX_KEY = /\h{128}/
|
||||
RSA_KEY = /\A-----BEGIN RSA PRIVATE KEY-----\n.+\n-----END RSA PRIVATE KEY-----\n\Z/m
|
||||
HEX_KEY = /\h{128}/.freeze
|
||||
RSA_KEY = /\A-----BEGIN RSA PRIVATE KEY-----\n.+\n-----END RSA PRIVATE KEY-----\n\Z/m.freeze
|
||||
|
||||
def stub_gitlab_secrets_json(secrets)
|
||||
allow(File).to receive(:read).with('/etc/gitlab/gitlab-secrets.json').and_return(JSON.generate(secrets))
|
||||
|
|
|
@ -12,7 +12,7 @@ cookbooks.each do |cookbook|
|
|||
end
|
||||
|
||||
def deep_clone(obj)
|
||||
Marshal.load(Marshal.dump(obj)) # rubocop:disable Security/MarshalLoad
|
||||
Marshal.load(Marshal.dump(obj))
|
||||
end
|
||||
|
||||
# Save the empty state of the Gitlab config singleton
|
||||
|
|
|
@ -60,7 +60,7 @@ describe Gitlab::Deprecations do
|
|||
note: "Use nginx['listen_addresses'] instead."
|
||||
}
|
||||
conf2 = {
|
||||
config_keys: ["gitlab", "gitlab-rails", "stuck_ci_builds_worker_cron"],
|
||||
config_keys: %w[gitlab gitlab-rails stuck_ci_builds_worker_cron],
|
||||
deprecation: "9.0",
|
||||
removal: "12.0",
|
||||
note: "Use gitlab_rails['stuck_ci_jobs_worker_cron'] instead."
|
||||
|
|
|
@ -52,10 +52,10 @@ module GitlabSpec
|
|||
stub_is_ee_env(value)
|
||||
end
|
||||
|
||||
def converge_config(*recipes, ee: false)
|
||||
def converge_config(*recipes, is_ee: false)
|
||||
Gitlab[:node] = nil
|
||||
Services.add_services('gitlab-ee', Services::EEServices.list) if ee
|
||||
config_recipe = ee ? 'gitlab-ee::config' : 'gitlab::config'
|
||||
Services.add_services('gitlab-ee', Services::EEServices.list) if is_ee
|
||||
config_recipe = is_ee ? 'gitlab-ee::config' : 'gitlab::config'
|
||||
ChefSpec::SoloRunner.converge(config_recipe, *recipes)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,7 @@ module GitlabYamlConverter
|
|||
Enumerator.new do |yielder|
|
||||
hash.each do |key, value|
|
||||
raise "Bad key: #{key.inspect}" unless key.is_a?(String)
|
||||
|
||||
key = [prefix, key].join(@separator) if prefix
|
||||
|
||||
if value.is_a?(Hash)
|
||||
|
|
Loading…
Reference in New Issue