Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
581b3020
Commit
581b3020
authored
Dec 18, 2019
by
Matthias Kaeppler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert revert of 35170-consolidate-process-config
This reverts commit
b0944b95
.
parent
7a8057fd
Changes
40
Hide whitespace changes
Inline
Side-by-side
Showing
40 changed files
with
249 additions
and
76 deletions
+249
-76
app/services/git/base_hooks_service.rb
app/services/git/base_hooks_service.rb
+1
-1
config/application.rb
config/application.rb
+2
-1
config/environments/development.rb
config/environments/development.rb
+1
-1
config/environments/production.rb
config/environments/production.rb
+1
-1
config/initializers/0_runtime_identify.rb
config/initializers/0_runtime_identify.rb
+13
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-1
config/initializers/7_prometheus_metrics.rb
config/initializers/7_prometheus_metrics.rb
+6
-6
config/initializers/active_record_lifecycle.rb
config/initializers/active_record_lifecycle.rb
+1
-1
config/initializers/cluster_events_before_phased_restart.rb
config/initializers/cluster_events_before_phased_restart.rb
+2
-4
config/initializers/database_config.rb
config/initializers/database_config.rb
+1
-1
config/initializers/lograge.rb
config/initializers/lograge.rb
+1
-1
config/initializers/rack_timeout.rb
config/initializers/rack_timeout.rb
+1
-1
config/initializers/tracing.rb
config/initializers/tracing.rb
+1
-1
config/initializers/validate_puma.rb
config/initializers/validate_puma.rb
+1
-1
ee/lib/gitlab/database/load_balancing.rb
ee/lib/gitlab/database/load_balancing.rb
+1
-1
ee/spec/lib/gitlab/database/load_balancing_spec.rb
ee/spec/lib/gitlab/database/load_balancing_spec.rb
+4
-4
lib/gitlab.rb
lib/gitlab.rb
+2
-2
lib/gitlab/cluster/lifecycle_events.rb
lib/gitlab/cluster/lifecycle_events.rb
+3
-3
lib/gitlab/gitaly_client.rb
lib/gitlab/gitaly_client.rb
+2
-6
lib/gitlab/gpg.rb
lib/gitlab/gpg.rb
+1
-1
lib/gitlab/health_checks/puma_check.rb
lib/gitlab/health_checks/puma_check.rb
+1
-1
lib/gitlab/health_checks/unicorn_check.rb
lib/gitlab/health_checks/unicorn_check.rb
+1
-1
lib/gitlab/highlight.rb
lib/gitlab/highlight.rb
+1
-1
lib/gitlab/metrics/influx_db.rb
lib/gitlab/metrics/influx_db.rb
+1
-1
lib/gitlab/metrics/samplers/influx_sampler.rb
lib/gitlab/metrics/samplers/influx_sampler.rb
+1
-5
lib/gitlab/metrics/samplers/unicorn_sampler.rb
lib/gitlab/metrics/samplers/unicorn_sampler.rb
+1
-1
lib/gitlab/redis/wrapper.rb
lib/gitlab/redis/wrapper.rb
+2
-2
lib/gitlab/runtime.rb
lib/gitlab/runtime.rb
+62
-0
lib/prometheus/pid_provider.rb
lib/prometheus/pid_provider.rb
+3
-3
spec/initializers/database_config_spec.rb
spec/initializers/database_config_spec.rb
+1
-0
spec/lib/gitlab/gitaly_client_spec.rb
spec/lib/gitlab/gitaly_client_spec.rb
+2
-2
spec/lib/gitlab/gpg_spec.rb
spec/lib/gitlab/gpg_spec.rb
+1
-1
spec/lib/gitlab/health_checks/puma_check_spec.rb
spec/lib/gitlab/health_checks/puma_check_spec.rb
+2
-0
spec/lib/gitlab/health_checks/unicorn_check_spec.rb
spec/lib/gitlab/health_checks/unicorn_check_spec.rb
+2
-0
spec/lib/gitlab/highlight_spec.rb
spec/lib/gitlab/highlight_spec.rb
+1
-1
spec/lib/gitlab/metrics/samplers/influx_sampler_spec.rb
spec/lib/gitlab/metrics/samplers/influx_sampler_spec.rb
+2
-2
spec/lib/gitlab/runtime_spec.rb
spec/lib/gitlab/runtime_spec.rb
+112
-0
spec/lib/prometheus/pid_provider_spec.rb
spec/lib/prometheus/pid_provider_spec.rb
+4
-14
spec/services/git/branch_push_service_spec.rb
spec/services/git/branch_push_service_spec.rb
+1
-1
spec/support/redis/redis_shared_examples.rb
spec/support/redis/redis_shared_examples.rb
+2
-2
No files found.
app/services/git/base_hooks_service.rb
View file @
581b3020
...
@@ -163,7 +163,7 @@ module Git
...
@@ -163,7 +163,7 @@ module Git
end
end
def
logger
def
logger
if
Sidekiq
.
server
?
if
Gitlab
::
Runtime
.
sidekiq
?
Sidekiq
.
logger
Sidekiq
.
logger
else
else
# This service runs in Sidekiq, so this shouldn't ever be
# This service runs in Sidekiq, so this shouldn't ever be
...
...
config/application.rb
View file @
581b3020
...
@@ -22,6 +22,7 @@ module Gitlab
...
@@ -22,6 +22,7 @@ module Gitlab
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/current_settings'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/current_settings'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/middleware/read_only'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/middleware/read_only'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/middleware/basic_health_check'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/middleware/basic_health_check'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/runtime'
)
# Settings in config/environments/* take precedence over those specified here.
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# Application configuration should go into files in config/initializers
...
@@ -255,7 +256,7 @@ module Gitlab
...
@@ -255,7 +256,7 @@ module Gitlab
caching_config_hash
[
:compress
]
=
false
caching_config_hash
[
:compress
]
=
false
caching_config_hash
[
:namespace
]
=
Gitlab
::
Redis
::
Cache
::
CACHE_NAMESPACE
caching_config_hash
[
:namespace
]
=
Gitlab
::
Redis
::
Cache
::
CACHE_NAMESPACE
caching_config_hash
[
:expires_in
]
=
2
.
weeks
# Cache should not grow forever
caching_config_hash
[
:expires_in
]
=
2
.
weeks
# Cache should not grow forever
if
Sidekiq
.
server?
||
defined?
(
::
Puma
)
# threaded context
if
Gitlab
::
Runtime
.
multi_threaded?
caching_config_hash
[
:pool_size
]
=
Gitlab
::
Redis
::
Cache
.
pool_size
caching_config_hash
[
:pool_size
]
=
Gitlab
::
Redis
::
Cache
.
pool_size
caching_config_hash
[
:pool_timeout
]
=
1
caching_config_hash
[
:pool_timeout
]
=
1
end
end
...
...
config/environments/development.rb
View file @
581b3020
...
@@ -46,7 +46,7 @@ Rails.application.configure do
...
@@ -46,7 +46,7 @@ Rails.application.configure do
# Do not log asset requests
# Do not log asset requests
config
.
assets
.
quiet
=
true
config
.
assets
.
quiet
=
true
config
.
allow_concurrency
=
defined?
(
::
Puma
)
config
.
allow_concurrency
=
Gitlab
::
Runtime
.
multi_threaded?
# BetterErrors live shell (REPL) on every stack frame
# BetterErrors live shell (REPL) on every stack frame
BetterErrors
::
Middleware
.
allow_ip!
(
"127.0.0.1/0"
)
BetterErrors
::
Middleware
.
allow_ip!
(
"127.0.0.1/0"
)
...
...
config/environments/production.rb
View file @
581b3020
...
@@ -75,5 +75,5 @@ Rails.application.configure do
...
@@ -75,5 +75,5 @@ Rails.application.configure do
config
.
eager_load
=
true
config
.
eager_load
=
true
config
.
allow_concurrency
=
defined?
(
::
Puma
)
config
.
allow_concurrency
=
Gitlab
::
Runtime
.
multi_threaded?
end
end
config/initializers/0_runtime_identify.rb
0 → 100644
View file @
581b3020
# frozen_string_literal: true
begin
Gitlab
::
AppLogger
.
info
(
"Runtime:
#{
Gitlab
::
Runtime
.
name
}
"
)
rescue
=>
e
message
=
<<-
NOTICE
\n
!! RUNTIME IDENTIFICATION FAILED:
#{
e
}
Runtime based configuration settings may not work properly.
If you continue to see this error, please file an issue via
https://gitlab.com/gitlab-org/gitlab/issues/new
NOTICE
Gitlab
::
AppLogger
.
error
(
message
)
end
config/initializers/1_settings.rb
View file @
581b3020
...
@@ -364,7 +364,7 @@ Gitlab.ee do
...
@@ -364,7 +364,7 @@ Gitlab.ee do
# To ensure acceptable performance we only allow feature to be used with
# To ensure acceptable performance we only allow feature to be used with
# multithreaded web-server Puma. This will be removed once download logic is moved
# multithreaded web-server Puma. This will be removed once download logic is moved
# to GitLab workhorse
# to GitLab workhorse
Settings
.
dependency_proxy
[
'enabled'
]
=
false
unless
defined?
(
::
Puma
)
Settings
.
dependency_proxy
[
'enabled'
]
=
false
unless
Gitlab
::
Runtime
.
puma?
end
end
#
#
...
...
config/initializers/7_prometheus_metrics.rb
View file @
581b3020
...
@@ -4,11 +4,11 @@ require 'prometheus/client'
...
@@ -4,11 +4,11 @@ require 'prometheus/client'
def
prometheus_default_multiproc_dir
def
prometheus_default_multiproc_dir
return
unless
Rails
.
env
.
development?
||
Rails
.
env
.
test?
return
unless
Rails
.
env
.
development?
||
Rails
.
env
.
test?
if
Sidekiq
.
server
?
if
Gitlab
::
Runtime
.
sidekiq
?
Rails
.
root
.
join
(
'tmp/prometheus_multiproc_dir/sidekiq'
)
Rails
.
root
.
join
(
'tmp/prometheus_multiproc_dir/sidekiq'
)
elsif
defined?
(
Unicorn
::
Worker
)
elsif
Gitlab
::
Runtime
.
unicorn?
Rails
.
root
.
join
(
'tmp/prometheus_multiproc_dir/unicorn'
)
Rails
.
root
.
join
(
'tmp/prometheus_multiproc_dir/unicorn'
)
elsif
defined?
(
::
Puma
)
elsif
Gitlab
::
Runtime
.
puma?
Rails
.
root
.
join
(
'tmp/prometheus_multiproc_dir/puma'
)
Rails
.
root
.
join
(
'tmp/prometheus_multiproc_dir/puma'
)
else
else
Rails
.
root
.
join
(
'tmp/prometheus_multiproc_dir'
)
Rails
.
root
.
join
(
'tmp/prometheus_multiproc_dir'
)
...
@@ -48,9 +48,9 @@ if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled?
...
@@ -48,9 +48,9 @@ if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled?
Gitlab
::
Cluster
::
LifecycleEvents
.
on_master_start
do
Gitlab
::
Cluster
::
LifecycleEvents
.
on_master_start
do
::
Prometheus
::
Client
.
reinitialize_on_pid_change
(
force:
true
)
::
Prometheus
::
Client
.
reinitialize_on_pid_change
(
force:
true
)
if
defined?
(
::
Unicorn
)
if
Gitlab
::
Runtime
.
unicorn?
Gitlab
::
Metrics
::
Samplers
::
UnicornSampler
.
instance
(
Settings
.
monitoring
.
unicorn_sampler_interval
).
start
Gitlab
::
Metrics
::
Samplers
::
UnicornSampler
.
instance
(
Settings
.
monitoring
.
unicorn_sampler_interval
).
start
elsif
defined?
(
::
Puma
)
elsif
Gitlab
::
Runtime
.
puma?
Gitlab
::
Metrics
::
Samplers
::
PumaSampler
.
instance
(
Settings
.
monitoring
.
puma_sampler_interval
).
start
Gitlab
::
Metrics
::
Samplers
::
PumaSampler
.
instance
(
Settings
.
monitoring
.
puma_sampler_interval
).
start
end
end
...
@@ -58,7 +58,7 @@ if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled?
...
@@ -58,7 +58,7 @@ if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled?
end
end
end
end
if
defined?
(
::
Unicorn
)
||
defined?
(
::
Puma
)
if
Gitlab
::
Runtime
.
app_server?
Gitlab
::
Cluster
::
LifecycleEvents
.
on_master_start
do
Gitlab
::
Cluster
::
LifecycleEvents
.
on_master_start
do
Gitlab
::
Metrics
::
Exporter
::
WebExporter
.
instance
.
start
Gitlab
::
Metrics
::
Exporter
::
WebExporter
.
instance
.
start
end
end
...
...
config/initializers/active_record_lifecycle.rb
View file @
581b3020
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
# Don't handle sidekiq configuration as it
# Don't handle sidekiq configuration as it
# has its own special active record configuration here
# has its own special active record configuration here
if
defined?
(
ActiveRecord
::
Base
)
&&
!
Sidekiq
.
server
?
if
defined?
(
ActiveRecord
::
Base
)
&&
!
Gitlab
::
Runtime
.
sidekiq
?
Gitlab
::
Cluster
::
LifecycleEvents
.
on_worker_start
do
Gitlab
::
Cluster
::
LifecycleEvents
.
on_worker_start
do
ActiveSupport
.
on_load
(
:active_record
)
do
ActiveSupport
.
on_load
(
:active_record
)
do
ActiveRecord
::
Base
.
establish_connection
ActiveRecord
::
Base
.
establish_connection
...
...
config/initializers/cluster_events_before_phased_restart.rb
View file @
581b3020
...
@@ -5,10 +5,8 @@
...
@@ -5,10 +5,8 @@
#
#
# Follow-up the issue: https://gitlab.com/gitlab-org/gitlab/issues/34107
# Follow-up the issue: https://gitlab.com/gitlab-org/gitlab/issues/34107
if
defined?
(
::
Puma
)
if
Gitlab
::
Runtime
.
puma?
Puma
::
Cluster
.
prepend
(
::
Gitlab
::
Cluster
::
Mixins
::
PumaCluster
)
Puma
::
Cluster
.
prepend
(
::
Gitlab
::
Cluster
::
Mixins
::
PumaCluster
)
end
elsif
Gitlab
::
Runtime
.
unicorn?
if
defined?
(
::
Unicorn
::
HttpServer
)
Unicorn
::
HttpServer
.
prepend
(
::
Gitlab
::
Cluster
::
Mixins
::
UnicornHttpServer
)
Unicorn
::
HttpServer
.
prepend
(
::
Gitlab
::
Cluster
::
Mixins
::
UnicornHttpServer
)
end
end
config/initializers/database_config.rb
View file @
581b3020
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
# when running on puma, scale connection pool size with the number
# when running on puma, scale connection pool size with the number
# of threads per worker process
# of threads per worker process
if
defined?
(
::
Puma
)
if
Gitlab
::
Runtime
.
puma?
db_config
=
Gitlab
::
Database
.
config
||
db_config
=
Gitlab
::
Database
.
config
||
Rails
.
application
.
config
.
database_configuration
[
Rails
.
env
]
Rails
.
application
.
config
.
database_configuration
[
Rails
.
env
]
puma_options
=
Puma
.
cli_config
.
options
puma_options
=
Puma
.
cli_config
.
options
...
...
config/initializers/lograge.rb
View file @
581b3020
# Only use Lograge for Rails
# Only use Lograge for Rails
unless
Sidekiq
.
server
?
unless
Gitlab
::
Runtime
.
sidekiq
?
filename
=
File
.
join
(
Rails
.
root
,
'log'
,
"
#{
Rails
.
env
}
_json.log"
)
filename
=
File
.
join
(
Rails
.
root
,
'log'
,
"
#{
Rails
.
env
}
_json.log"
)
Rails
.
application
.
configure
do
Rails
.
application
.
configure
do
...
...
config/initializers/rack_timeout.rb
View file @
581b3020
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
# and it's used only as the last resort. In such case this termination is
# and it's used only as the last resort. In such case this termination is
# logged and we should fix the potential timeout issue in the code itself.
# logged and we should fix the potential timeout issue in the code itself.
if
defined?
(
::
Puma
)
&&
!
Rails
.
env
.
test?
if
Gitlab
::
Runtime
.
puma?
&&
!
Rails
.
env
.
test?
require
'rack/timeout/base'
require
'rack/timeout/base'
Gitlab
::
Application
.
configure
do
|
config
|
Gitlab
::
Application
.
configure
do
|
config
|
...
...
config/initializers/tracing.rb
View file @
581b3020
...
@@ -13,7 +13,7 @@ if Labkit::Tracing.enabled?
...
@@ -13,7 +13,7 @@ if Labkit::Tracing.enabled?
end
end
# Instrument Sidekiq server calls when running Sidekiq server
# Instrument Sidekiq server calls when running Sidekiq server
if
Sidekiq
.
server
?
if
Gitlab
::
Runtime
.
sidekiq
?
Sidekiq
.
configure_server
do
|
config
|
Sidekiq
.
configure_server
do
|
config
|
config
.
server_middleware
do
|
chain
|
config
.
server_middleware
do
|
chain
|
chain
.
add
Labkit
::
Tracing
::
Sidekiq
::
ServerMiddleware
chain
.
add
Labkit
::
Tracing
::
Sidekiq
::
ServerMiddleware
...
...
config/initializers/validate_puma.rb
View file @
581b3020
# frozen_string_literal: true
# frozen_string_literal: true
if
defined?
(
::
Puma
)
&&
::
Puma
.
cli_config
.
options
[
:workers
].
to_i
.
zero?
if
Gitlab
::
Runtime
.
puma?
&&
::
Puma
.
cli_config
.
options
[
:workers
].
to_i
.
zero?
raise
'Puma is only supported in Cluster-mode: workers > 0'
raise
'Puma is only supported in Cluster-mode: workers > 0'
end
end
ee/lib/gitlab/database/load_balancing.rb
View file @
581b3020
...
@@ -85,7 +85,7 @@ module Gitlab
...
@@ -85,7 +85,7 @@ module Gitlab
# Returns true if load balancing is to be enabled.
# Returns true if load balancing is to be enabled.
def
self
.
enable?
def
self
.
enable?
return
false
unless
::
License
.
feature_available?
(
:db_load_balancing
)
return
false
unless
::
License
.
feature_available?
(
:db_load_balancing
)
return
false
if
program_name
==
'rake'
||
Sidekiq
.
server
?
return
false
if
program_name
==
'rake'
||
Gitlab
::
Runtime
.
sidekiq
?
hosts
.
any?
||
service_discovery_enabled?
hosts
.
any?
||
service_discovery_enabled?
end
end
...
...
ee/spec/lib/gitlab/database/load_balancing_spec.rb
View file @
581b3020
...
@@ -140,7 +140,7 @@ describe Gitlab::Database::LoadBalancing do
...
@@ -140,7 +140,7 @@ describe Gitlab::Database::LoadBalancing do
it
'returns false when Sidekiq is being used'
do
it
'returns false when Sidekiq is being used'
do
allow
(
described_class
).
to
receive
(
:hosts
).
and_return
(
%w(foo)
)
allow
(
described_class
).
to
receive
(
:hosts
).
and_return
(
%w(foo)
)
allow
(
Sidekiq
).
to
receive
(
:server
?
).
and_return
(
true
)
allow
(
Gitlab
::
Runtime
).
to
receive
(
:sidekiq
?
).
and_return
(
true
)
expect
(
described_class
.
enable?
).
to
eq
(
false
)
expect
(
described_class
.
enable?
).
to
eq
(
false
)
end
end
...
@@ -153,14 +153,14 @@ describe Gitlab::Database::LoadBalancing do
...
@@ -153,14 +153,14 @@ describe Gitlab::Database::LoadBalancing do
it
'returns true when load balancing should be enabled'
do
it
'returns true when load balancing should be enabled'
do
allow
(
described_class
).
to
receive
(
:hosts
).
and_return
(
%w(foo)
)
allow
(
described_class
).
to
receive
(
:hosts
).
and_return
(
%w(foo)
)
allow
(
Sidekiq
).
to
receive
(
:server
?
).
and_return
(
false
)
allow
(
Gitlab
::
Runtime
).
to
receive
(
:sidekiq
?
).
and_return
(
false
)
expect
(
described_class
.
enable?
).
to
eq
(
true
)
expect
(
described_class
.
enable?
).
to
eq
(
true
)
end
end
it
'returns true when service discovery is enabled'
do
it
'returns true when service discovery is enabled'
do
allow
(
described_class
).
to
receive
(
:hosts
).
and_return
([])
allow
(
described_class
).
to
receive
(
:hosts
).
and_return
([])
allow
(
Sidekiq
).
to
receive
(
:server
?
).
and_return
(
false
)
allow
(
Gitlab
::
Runtime
).
to
receive
(
:sidekiq
?
).
and_return
(
false
)
allow
(
described_class
)
allow
(
described_class
)
.
to
receive
(
:service_discovery_enabled?
)
.
to
receive
(
:service_discovery_enabled?
)
...
@@ -192,7 +192,7 @@ describe Gitlab::Database::LoadBalancing do
...
@@ -192,7 +192,7 @@ describe Gitlab::Database::LoadBalancing do
it
'is enabled'
do
it
'is enabled'
do
allow
(
described_class
).
to
receive
(
:hosts
).
and_return
(
%w(foo)
)
allow
(
described_class
).
to
receive
(
:hosts
).
and_return
(
%w(foo)
)
allow
(
Sidekiq
).
to
receive
(
:server
?
).
and_return
(
false
)
allow
(
Gitlab
::
Runtime
).
to
receive
(
:sidekiq
?
).
and_return
(
false
)
expect
(
described_class
.
enable?
).
to
eq
(
true
)
expect
(
described_class
.
enable?
).
to
eq
(
true
)
end
end
...
...
lib/gitlab.rb
View file @
581b3020
...
@@ -100,8 +100,8 @@ module Gitlab
...
@@ -100,8 +100,8 @@ module Gitlab
end
end
def
self
.
process_name
def
self
.
process_name
return
'sidekiq'
if
Sidekiq
.
server
?
return
'sidekiq'
if
Gitlab
::
Runtime
.
sidekiq
?
return
'console'
if
defined?
(
Rails
::
Console
)
return
'console'
if
Gitlab
::
Runtime
.
console?
return
'test'
if
Rails
.
env
.
test?
return
'test'
if
Rails
.
env
.
test?
'web'
'web'
...
...
lib/gitlab/cluster/lifecycle_events.rb
View file @
581b3020
...
@@ -149,10 +149,10 @@ module Gitlab
...
@@ -149,10 +149,10 @@ module Gitlab
def
in_clustered_environment?
def
in_clustered_environment?
# Sidekiq doesn't fork
# Sidekiq doesn't fork
return
false
if
Sidekiq
.
server
?
return
false
if
Gitlab
::
Runtime
.
sidekiq
?
# Unicorn always forks
# Unicorn always forks
return
true
if
defined?
(
::
Unicorn
)
return
true
if
Gitlab
::
Runtime
.
unicorn?
# Puma sometimes forks
# Puma sometimes forks
return
true
if
in_clustered_puma?
return
true
if
in_clustered_puma?
...
@@ -162,7 +162,7 @@ module Gitlab
...
@@ -162,7 +162,7 @@ module Gitlab
end
end
def
in_clustered_puma?
def
in_clustered_puma?
return
false
unless
defined?
(
::
Puma
)
return
false
unless
Gitlab
::
Runtime
.
puma?
@puma_options
&&
@puma_options
[
:workers
]
&&
@puma_options
[
:workers
]
>
0
@puma_options
&&
@puma_options
[
:workers
]
&&
@puma_options
[
:workers
]
>
0
end
end
...
...
lib/gitlab/gitaly_client.rb
View file @
581b3020
...
@@ -29,7 +29,7 @@ module Gitlab
...
@@ -29,7 +29,7 @@ module Gitlab
PEM_REGEX
=
/\-+BEGIN CERTIFICATE\-+.+?\-+END CERTIFICATE\-+/m
.
freeze
PEM_REGEX
=
/\-+BEGIN CERTIFICATE\-+.+?\-+END CERTIFICATE\-+/m
.
freeze
SERVER_VERSION_FILE
=
'GITALY_SERVER_VERSION'
SERVER_VERSION_FILE
=
'GITALY_SERVER_VERSION'
MAXIMUM_GITALY_CALLS
=
30
MAXIMUM_GITALY_CALLS
=
30
CLIENT_NAME
=
(
Sidekiq
.
server
?
?
'gitlab-sidekiq'
:
'gitlab-web'
).
freeze
CLIENT_NAME
=
(
Gitlab
::
Runtime
.
sidekiq
?
?
'gitlab-sidekiq'
:
'gitlab-web'
).
freeze
GITALY_METADATA_FILENAME
=
'.gitaly-metadata'
GITALY_METADATA_FILENAME
=
'.gitaly-metadata'
MUTEX
=
Mutex
.
new
MUTEX
=
Mutex
.
new
...
@@ -382,17 +382,13 @@ module Gitlab
...
@@ -382,17 +382,13 @@ module Gitlab
end
end
def
self
.
long_timeout
def
self
.
long_timeout
if
web_
app_server?
if
Gitlab
::
Runtime
.
app_server?
default_timeout
default_timeout
else
else
6
.
hours
6
.
hours
end
end
end
end
def
self
.
web_app_server?
defined?
(
::
Unicorn
)
||
defined?
(
::
Puma
)
end
def
self
.
storage_metadata_file_path
(
storage
)
def
self
.
storage_metadata_file_path
(
storage
)
Gitlab
::
GitalyClient
::
StorageSettings
.
allow_disk_access
do
Gitlab
::
GitalyClient
::
StorageSettings
.
allow_disk_access
do
File
.
join
(
File
.
join
(
...
...
lib/gitlab/gpg.rb
View file @
581b3020
...
@@ -135,7 +135,7 @@ module Gitlab
...
@@ -135,7 +135,7 @@ module Gitlab
end
end
def
cleanup_time
def
cleanup_time
Sidekiq
.
server
?
?
BG_CLEANUP_RUNTIME_S
:
FG_CLEANUP_RUNTIME_S
Gitlab
::
Runtime
.
sidekiq
?
?
BG_CLEANUP_RUNTIME_S
:
FG_CLEANUP_RUNTIME_S
end
end
def
tmp_keychains_created
def
tmp_keychains_created
...
...
lib/gitlab/health_checks/puma_check.rb
View file @
581b3020
...
@@ -18,7 +18,7 @@ module Gitlab
...
@@ -18,7 +18,7 @@ module Gitlab
end
end
def
check
def
check
return
unless
defined?
(
::
Puma
)
return
unless
Gitlab
::
Runtime
.
puma?
stats
=
Puma
.
stats
stats
=
Puma
.
stats
stats
=
JSON
.
parse
(
stats
)
stats
=
JSON
.
parse
(
stats
)
...
...
lib/gitlab/health_checks/unicorn_check.rb
View file @
581b3020
...
@@ -30,7 +30,7 @@ module Gitlab
...
@@ -30,7 +30,7 @@ module Gitlab
# to change so we can cache the list of servers.
# to change so we can cache the list of servers.
def
http_servers
def
http_servers
strong_memoize
(
:http_servers
)
do
strong_memoize
(
:http_servers
)
do
next
unless
defined?
(
::
Unicorn
::
HttpServer
)
next
unless
Gitlab
::
Runtime
.
unicorn?
ObjectSpace
.
each_object
(
::
Unicorn
::
HttpServer
).
to_a
ObjectSpace
.
each_object
(
::
Unicorn
::
HttpServer
).
to_a
end
end
...
...
lib/gitlab/highlight.rb
View file @
581b3020
...
@@ -68,7 +68,7 @@ module Gitlab
...
@@ -68,7 +68,7 @@ module Gitlab
end
end
def
timeout_time
def
timeout_time
Sidekiq
.
server
?
?
TIMEOUT_BACKGROUND
:
TIMEOUT_FOREGROUND
Gitlab
::
Runtime
.
sidekiq
?
?
TIMEOUT_BACKGROUND
:
TIMEOUT_FOREGROUND
end
end
def
link_dependencies
(
text
,
highlighted_text
)
def
link_dependencies
(
text
,
highlighted_text
)
...
...
lib/gitlab/metrics/influx_db.rb
View file @
581b3020
...
@@ -150,7 +150,7 @@ module Gitlab
...
@@ -150,7 +150,7 @@ module Gitlab
# Returns the prefix to use for the name of a series.
# Returns the prefix to use for the name of a series.
def
series_prefix
def
series_prefix
@series_prefix
||=
Sidekiq
.
server
?
?
'sidekiq_'
:
'rails_'
@series_prefix
||=
Gitlab
::
Runtime
.
sidekiq
?
?
'sidekiq_'
:
'rails_'
end
end
# Allow access from other metrics related middlewares
# Allow access from other metrics related middlewares
...
...
lib/gitlab/metrics/samplers/influx_sampler.rb
View file @
581b3020
...
@@ -39,14 +39,10 @@ module Gitlab
...
@@ -39,14 +39,10 @@ module Gitlab
end
end
def
add_metric
(
series
,
values
,
tags
=
{})
def
add_metric
(
series
,
values
,
tags
=
{})
prefix
=
sidekiq?
?
'sidekiq_'
:
'rails_'
prefix
=
Gitlab
::
Runtime
.
sidekiq?
?
'sidekiq_'
:
'rails_'
@metrics
<<
Metric
.
new
(
"
#{
prefix
}#{
series
}
"
,
values
,
tags
)
@metrics
<<
Metric
.
new
(
"
#{
prefix
}#{
series
}
"
,
values
,
tags
)
end
end
def
sidekiq?
Sidekiq
.
server?
end
end
end
end
end
end
end
...
...
lib/gitlab/metrics/samplers/unicorn_sampler.rb
View file @
581b3020
...
@@ -61,7 +61,7 @@ module Gitlab
...
@@ -61,7 +61,7 @@ module Gitlab
# it takes around 80ms. The instances of HttpServers are not a subject
# it takes around 80ms. The instances of HttpServers are not a subject
# to change so we can cache the list of servers.
# to change so we can cache the list of servers.
def
http_servers
def
http_servers
return
[]
unless
defined?
(
::
Unicorn
::
HttpServer
)
return
[]
unless
Gitlab
::
Runtime
.
unicorn?
@http_servers
||=
ObjectSpace
.
each_object
(
::
Unicorn
::
HttpServer
).
to_a
@http_servers
||=
ObjectSpace
.
each_object
(
::
Unicorn
::
HttpServer
).
to_a
end
end
...
...
lib/gitlab/redis/wrapper.rb
View file @
581b3020
...
@@ -22,10 +22,10 @@ module Gitlab
...
@@ -22,10 +22,10 @@ module Gitlab
def
pool_size
def
pool_size
# heuristic constant 5 should be a config setting somewhere -- related to CPU count?
# heuristic constant 5 should be a config setting somewhere -- related to CPU count?
size
=
5
size
=
5
if
Sidekiq
.
server
?
if
Gitlab
::
Runtime
.
sidekiq
?
# the pool will be used in a multi-threaded context
# the pool will be used in a multi-threaded context
size
+=
Sidekiq
.
options
[
:concurrency
]
size
+=
Sidekiq
.
options
[
:concurrency
]
elsif
defined?
(
::
Puma
)
elsif
Gitlab
::
Runtime
.
puma?
size
+=
Puma
.
cli_config
.
options
[
:max_threads
]
size
+=
Puma
.
cli_config
.
options
[
:max_threads
]
end
end
...
...
lib/gitlab/runtime.rb
0 → 100644
View file @
581b3020
# frozen_string_literal: true
module
Gitlab
# Provides routines to identify the current runtime as which the application
# executes, such as whether it is an application server and which one.
module
Runtime
class
<<
self
def
name
matches
=
[]
matches
<<
:puma
if
puma?
matches
<<
:unicorn
if
unicorn?
matches
<<
:console
if
console?
matches
<<
:sidekiq
if
sidekiq?
raise
"Ambiguous process match:
#{
matches
}
"
if
matches
.
size
>
1
matches
.
first
||
:unknown
end
def
puma?
!!
(
defined?
(
::
Puma
)
&&
bin
==
'puma'
)
end
# For unicorn, we need to check for actual server instances to avoid false positives.
def
unicorn?
!!
(
defined?
(
::
Unicorn
)
&&
defined?
(
::
Unicorn
::
HttpServer
))
end
def
sidekiq?
!!
(
defined?
(
::
Sidekiq
)
&&
Sidekiq
.
server?
&&
bin
==
'sidekiq'
)
end
def
console?
!!
defined?
(
::
Rails
::
Console
)
end
def
app_server?
puma?
||
unicorn?
end
def
multi_threaded?
puma?
||
sidekiq?
end
private
# Some example values from my system:
# puma: /data/cache/bundle-2.5/bin/puma
# unicorn: unicorn_rails master -E development -c /tmp/unicorn.rb -l 0.0.0.0:8080
# sidekiq: /data/cache/bundle-2.5/bin/sidekiq
# thin: bin/rails
# console: bin/rails
def
script_name
$0
end
def
bin
File
.
basename
(
script_name
)
end
end
end
end
lib/prometheus/pid_provider.rb
View file @
581b3020
...
@@ -5,11 +5,11 @@ module Prometheus
...
@@ -5,11 +5,11 @@ module Prometheus
extend
self
extend
self
def
worker_id
def
worker_id
if
Sidekiq
.
server
?
if
Gitlab
::
Runtime
.
sidekiq
?
sidekiq_worker_id
sidekiq_worker_id
elsif
defined?
(
Unicorn
::
Worker
)
elsif
Gitlab
::
Runtime
.
unicorn?
unicorn_worker_id
unicorn_worker_id
elsif
defined?
(
::
Puma
)
elsif
Gitlab
::
Runtime
.
puma?
puma_worker_id
puma_worker_id
else
else
unknown_process_id
unknown_process_id
...
...
spec/initializers/database_config_spec.rb
View file @
581b3020
...
@@ -16,6 +16,7 @@ describe 'Database config initializer' do
...
@@ -16,6 +16,7 @@ describe 'Database config initializer' do
let
(
:puma_options
)
{
{
max_threads:
8
}
}
let
(
:puma_options
)
{
{
max_threads:
8
}
}
before
do
before
do
allow
(
Gitlab
::
Runtime
).
to
receive
(
:puma?
).
and_return
(
true
)
stub_const
(
"Puma"
,
puma
)
stub_const
(
"Puma"
,
puma
)
allow
(
puma
).
to
receive_message_chain
(
:cli_config
,
:options
).
and_return
(
puma_options
)
allow
(
puma
).
to
receive_message_chain
(
:cli_config
,
:options
).
and_return
(
puma_options
)
end
end
...
...
spec/lib/gitlab/gitaly_client_spec.rb
View file @
581b3020
...
@@ -26,7 +26,7 @@ describe Gitlab::GitalyClient do
...
@@ -26,7 +26,7 @@ describe Gitlab::GitalyClient do
context
'running in Unicorn'
do
context
'running in Unicorn'
do
before
do
before
do
stub_const
(
'Unicorn'
,
1
)
allow
(
Gitlab
::
Runtime
).
to
receive
(
:unicorn?
).
and_return
(
true
)
end
end
it
{
expect
(
subject
.
long_timeout
).
to
eq
(
55
)
}
it
{
expect
(
subject
.
long_timeout
).
to
eq
(
55
)
}
...
@@ -34,7 +34,7 @@ describe Gitlab::GitalyClient do
...
@@ -34,7 +34,7 @@ describe Gitlab::GitalyClient do
context
'running in Puma'
do
context
'running in Puma'
do
before
do
before
do
stub_const
(
'Puma'
,
1
)
allow
(
Gitlab
::
Runtime
).
to
receive
(
:puma?
).
and_return
(
true
)
end
end
it
{
expect
(
subject
.
long_timeout
).
to
eq
(
55
)
}
it
{
expect
(
subject
.
long_timeout
).
to
eq
(
55
)
}
...
...
spec/lib/gitlab/gpg_spec.rb
View file @
581b3020
...
@@ -236,7 +236,7 @@ describe Gitlab::Gpg do
...
@@ -236,7 +236,7 @@ describe Gitlab::Gpg do
context
'when running in Sidekiq'
do
context
'when running in Sidekiq'
do
before
do
before
do
allow
(
Sidekiq
).
to
receive
(
:server
?
).
and_return
(
true
)
allow
(
Gitlab
::
Runtime
).
to
receive
(
:sidekiq
?
).
and_return
(
true
)
end
end
it_behaves_like
'multiple deletion attempts of the tmp-dir'
,
described_class
::
BG_CLEANUP_RUNTIME_S
it_behaves_like
'multiple deletion attempts of the tmp-dir'
,
described_class
::
BG_CLEANUP_RUNTIME_S
...
...
spec/lib/gitlab/health_checks/puma_check_spec.rb
View file @
581b3020
...
@@ -22,6 +22,7 @@ describe Gitlab::HealthChecks::PumaCheck do
...
@@ -22,6 +22,7 @@ describe Gitlab::HealthChecks::PumaCheck do
context
'when Puma is not loaded'
do
context
'when Puma is not loaded'
do
before
do
before
do
allow
(
Gitlab
::
Runtime
).
to
receive
(
:puma?
).
and_return
(
false
)
hide_const
(
'Puma'
)
hide_const
(
'Puma'
)
end
end
...
@@ -33,6 +34,7 @@ describe Gitlab::HealthChecks::PumaCheck do
...
@@ -33,6 +34,7 @@ describe Gitlab::HealthChecks::PumaCheck do
context
'when Puma is loaded'
do
context
'when Puma is loaded'
do
before
do
before
do
allow
(
Gitlab
::
Runtime
).
to
receive
(
:puma?
).
and_return
(
true
)
stub_const
(
'Puma'
,
Module
.
new
)
stub_const
(
'Puma'
,
Module
.
new
)
end
end
...
...
spec/lib/gitlab/health_checks/unicorn_check_spec.rb
View file @
581b3020
...
@@ -26,6 +26,7 @@ describe Gitlab::HealthChecks::UnicornCheck do
...
@@ -26,6 +26,7 @@ describe Gitlab::HealthChecks::UnicornCheck do
context
'when Unicorn is not loaded'
do
context
'when Unicorn is not loaded'
do
before
do
before
do
allow
(
Gitlab
::
Runtime
).
to
receive
(
:unicorn?
).
and_return
(
false
)
hide_const
(
'Unicorn'
)
hide_const
(
'Unicorn'
)
end
end
...
@@ -39,6 +40,7 @@ describe Gitlab::HealthChecks::UnicornCheck do
...
@@ -39,6 +40,7 @@ describe Gitlab::HealthChecks::UnicornCheck do
let
(
:http_server_class
)
{
Struct
.
new
(
:worker_processes
)
}
let
(
:http_server_class
)
{
Struct
.
new
(
:worker_processes
)
}
before
do
before
do
allow
(
Gitlab
::
Runtime
).
to
receive
(
:unicorn?
).
and_return
(
true
)
stub_const
(
'Unicorn::HttpServer'
,
http_server_class
)
stub_const
(
'Unicorn::HttpServer'
,
http_server_class
)
end
end
...
...
spec/lib/gitlab/highlight_spec.rb
View file @
581b3020
...
@@ -111,7 +111,7 @@ describe Gitlab::Highlight do
...
@@ -111,7 +111,7 @@ describe Gitlab::Highlight do
end
end
it
'utilizes longer timeout for sidekiq'
do
it
'utilizes longer timeout for sidekiq'
do
allow
(
Sidekiq
).
to
receive
(
:server
?
).
and_return
(
true
)
allow
(
Gitlab
::
Runtime
).
to
receive
(
:sidekiq
?
).
and_return
(
true
)
expect
(
Timeout
).
to
receive
(
:timeout
).
with
(
described_class
::
TIMEOUT_BACKGROUND
).
and_call_original
expect
(
Timeout
).
to
receive
(
:timeout
).
with
(
described_class
::
TIMEOUT_BACKGROUND
).
and_call_original
subject
.
highlight
(
"Content"
)
subject
.
highlight
(
"Content"
)
...
...
spec/lib/gitlab/metrics/samplers/influx_sampler_spec.rb
View file @
581b3020
...
@@ -63,7 +63,7 @@ describe Gitlab::Metrics::Samplers::InfluxSampler do
...
@@ -63,7 +63,7 @@ describe Gitlab::Metrics::Samplers::InfluxSampler do
describe
'#add_metric'
do
describe
'#add_metric'
do
it
'prefixes the series name for a Rails process'
do
it
'prefixes the series name for a Rails process'
do
expect
(
sampler
).
to
receive
(
:sidekiq?
).
and_return
(
false
)
expect
(
Gitlab
::
Runtime
).
to
receive
(
:sidekiq?
).
and_return
(
false
)
expect
(
Gitlab
::
Metrics
::
Metric
).
to
receive
(
:new
)
expect
(
Gitlab
::
Metrics
::
Metric
).
to
receive
(
:new
)
.
with
(
'rails_cats'
,
{
value:
10
},
{})
.
with
(
'rails_cats'
,
{
value:
10
},
{})
...
@@ -73,7 +73,7 @@ describe Gitlab::Metrics::Samplers::InfluxSampler do
...
@@ -73,7 +73,7 @@ describe Gitlab::Metrics::Samplers::InfluxSampler do
end
end
it
'prefixes the series name for a Sidekiq process'
do
it
'prefixes the series name for a Sidekiq process'
do
expect
(
sampler
).
to
receive
(
:sidekiq?
).
and_return
(
true
)
expect
(
Gitlab
::
Runtime
).
to
receive
(
:sidekiq?
).
and_return
(
true
)
expect
(
Gitlab
::
Metrics
::
Metric
).
to
receive
(
:new
)
expect
(
Gitlab
::
Metrics
::
Metric
).
to
receive
(
:new
)
.
with
(
'sidekiq_cats'
,
{
value:
10
},
{})
.
with
(
'sidekiq_cats'
,
{
value:
10
},
{})
...
...
spec/lib/gitlab/runtime_spec.rb
0 → 100644
View file @
581b3020
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
Runtime
do
REAL_PATH
=
$0
after
(
:all
)
do
$0
=
REAL_PATH
end
context
"when unknown"
do
it
"identifies as :unknown"
do
expect
(
subject
.
name
).
to
eq
(
:unknown
)
end
end
context
"on multiple matches"
do
before
do
$0
=
'/data/cache/bundle-2.5/bin/puma'
stub_const
(
'::Puma'
,
double
)
stub_const
(
'::Rails::Console'
,
double
)
end
it
"raises an exception when trying to identify"
do
expect
{
subject
.
name
}.
to
raise_error
(
RuntimeError
,
"Ambiguous process match: [:puma, :console]"
)
end
end
context
"puma"
do
let
(
:puma_type
)
{
double
(
'::Puma'
)
}
before
do
$0
=
'/data/cache/bundle-2.5/bin/puma'
stub_const
(
'::Puma'
,
puma_type
)
end
it
"identifies itself"
do
expect
(
subject
.
name
).
to
eq
(
:puma
)
expect
(
subject
.
puma?
).
to
be
(
true
)
end
it
"does not identify as others"
do
expect
(
subject
.
unicorn?
).
to
be
(
false
)
expect
(
subject
.
sidekiq?
).
to
be
(
false
)
expect
(
subject
.
console?
).
to
be
(
false
)
end
end
context
"unicorn"
do
let
(
:unicorn_type
)
{
Module
.
new
}
let
(
:unicorn_server_type
)
{
Class
.
new
}
before
do
$0
=
'unicorn_rails master -E development -c /tmp/unicorn.rb -l 0.0.0.0:8080'
stub_const
(
'::Unicorn'
,
unicorn_type
)
stub_const
(
'::Unicorn::HttpServer'
,
unicorn_server_type
)
end
it
"identifies itself"
do
expect
(
subject
.
name
).
to
eq
(
:unicorn
)
expect
(
subject
.
unicorn?
).
to
be
(
true
)
end
it
"does not identify as others"
do
expect
(
subject
.
puma?
).
to
be
(
false
)
expect
(
subject
.
sidekiq?
).
to
be
(
false
)
expect
(
subject
.
console?
).
to
be
(
false
)
end
end
context
"sidekiq"
do
let
(
:sidekiq_type
)
{
double
(
'::Sidekiq'
)
}
before
do
$0
=
'/data/cache/bundle-2.5/bin/sidekiq'
stub_const
(
'::Sidekiq'
,
sidekiq_type
)
allow
(
sidekiq_type
).
to
receive
(
:server?
).
and_return
(
true
)
end
it
"identifies itself"
do
expect
(
subject
.
name
).
to
eq
(
:sidekiq
)
expect
(
subject
.
sidekiq?
).
to
be
(
true
)
end
it
"does not identify as others"
do
expect
(
subject
.
unicorn?
).
to
be
(
false
)
expect
(
subject
.
puma?
).
to
be
(
false
)
expect
(
subject
.
console?
).
to
be
(
false
)
end
end
context
"console"
do
let
(
:console_type
)
{
double
(
'::Rails::Console'
)
}
before
do
$0
=
'bin/rails'
stub_const
(
'::Rails::Console'
,
console_type
)
end
it
"identifies itself"
do
expect
(
subject
.
name
).
to
eq
(
:console
)
expect
(
subject
.
console?
).
to
be
(
true
)
end
it
"does not identify as others"
do
expect
(
subject
.
unicorn?
).
to
be
(
false
)
expect
(
subject
.
sidekiq?
).
to
be
(
false
)
expect
(
subject
.
puma?
).
to
be
(
false
)
end
end
end
spec/lib/prometheus/pid_provider_spec.rb
View file @
581b3020
...
@@ -6,16 +6,13 @@ describe Prometheus::PidProvider do
...
@@ -6,16 +6,13 @@ describe Prometheus::PidProvider do
describe
'.worker_id'
do
describe
'.worker_id'
do
subject
{
described_class
.
worker_id
}
subject
{
described_class
.
worker_id
}
let
(
:sidekiq_module
)
{
Module
.
new
}
before
do
before
do
allow
(
sidekiq_module
).
to
receive
(
:server?
).
and_return
(
false
)
allow
(
Gitlab
::
Runtime
).
to
receive
(
:sidekiq?
).
and_return
(
false
)
stub_const
(
'Sidekiq'
,
sidekiq_module
)
end
end
context
'when running in Sidekiq server mode'
do
context
'when running in Sidekiq server mode'
do
before
do
before
do
expect
(
Sidekiq
).
to
receive
(
:server
?
).
and_return
(
true
)
allow
(
Gitlab
::
Runtime
).
to
receive
(
:sidekiq
?
).
and_return
(
true
)
end
end
context
'in a clustered setup'
do
context
'in a clustered setup'
do
...
@@ -33,8 +30,7 @@ describe Prometheus::PidProvider do
...
@@ -33,8 +30,7 @@ describe Prometheus::PidProvider do
context
'when running in Unicorn mode'
do
context
'when running in Unicorn mode'
do
before
do
before
do
stub_const
(
'Unicorn::Worker'
,
Class
.
new
)
allow
(
Gitlab
::
Runtime
).
to
receive
(
:unicorn?
).
and_return
(
true
)
hide_const
(
'Puma'
)
expect
(
described_class
).
to
receive
(
:process_name
)
expect
(
described_class
).
to
receive
(
:process_name
)
.
at_least
(
:once
)
.
at_least
(
:once
)
...
@@ -94,8 +90,7 @@ describe Prometheus::PidProvider do
...
@@ -94,8 +90,7 @@ describe Prometheus::PidProvider do
context
'when running in Puma mode'
do
context
'when running in Puma mode'
do
before
do
before
do
stub_const
(
'Puma'
,
Module
.
new
)
allow
(
Gitlab
::
Runtime
).
to
receive
(
:puma?
).
and_return
(
true
)
hide_const
(
'Unicorn::Worker'
)
expect
(
described_class
).
to
receive
(
:process_name
)
expect
(
described_class
).
to
receive
(
:process_name
)
.
at_least
(
:once
)
.
at_least
(
:once
)
...
@@ -116,11 +111,6 @@ describe Prometheus::PidProvider do
...
@@ -116,11 +111,6 @@ describe Prometheus::PidProvider do
end
end
context
'when running in unknown mode'
do
context
'when running in unknown mode'
do
before
do
hide_const
(
'Puma'
)
hide_const
(
'Unicorn::Worker'
)
end
it
{
is_expected
.
to
eq
"process_
#{
Process
.
pid
}
"
}
it
{
is_expected
.
to
eq
"process_
#{
Process
.
pid
}
"
}
end
end
end
end
...
...
spec/services/git/branch_push_service_spec.rb
View file @
581b3020
...
@@ -108,7 +108,7 @@ describe Git::BranchPushService, services: true do
...
@@ -108,7 +108,7 @@ describe Git::BranchPushService, services: true do
end
end
it
'reports an error'
do
it
'reports an error'
do
allow
(
Sidekiq
).
to
receive
(
:server
?
).
and_return
(
true
)
allow
(
Gitlab
::
Runtime
).
to
receive
(
:sidekiq
?
).
and_return
(
true
)
expect
(
Sidekiq
.
logger
).
to
receive
(
:warn
)
expect
(
Sidekiq
.
logger
).
to
receive
(
:warn
)
expect
{
subject
}.
not_to
change
{
Ci
::
Pipeline
.
count
}
expect
{
subject
}.
not_to
change
{
Ci
::
Pipeline
.
count
}
...
...
spec/support/redis/redis_shared_examples.rb
View file @
581b3020
...
@@ -118,7 +118,7 @@ RSpec.shared_examples "redis_shared_examples" do
...
@@ -118,7 +118,7 @@ RSpec.shared_examples "redis_shared_examples" do
context
'when running not on sidekiq workers'
do
context
'when running not on sidekiq workers'
do
before
do
before
do
allow
(
Sidekiq
).
to
receive
(
:server
?
).
and_return
(
false
)
allow
(
Gitlab
::
Runtime
).
to
receive
(
:sidekiq
?
).
and_return
(
false
)
end
end
it
'instantiates a connection pool with size 5'
do
it
'instantiates a connection pool with size 5'
do
...
@@ -130,7 +130,7 @@ RSpec.shared_examples "redis_shared_examples" do
...
@@ -130,7 +130,7 @@ RSpec.shared_examples "redis_shared_examples" do
context
'when running on sidekiq workers'
do
context
'when running on sidekiq workers'
do
before
do
before
do
allow
(
Sidekiq
).
to
receive
(
:server
?
).
and_return
(
true
)
allow
(
Gitlab
::
Runtime
).
to
receive
(
:sidekiq
?
).
and_return
(
true
)
allow
(
Sidekiq
).
to
receive
(
:options
).
and_return
({
concurrency:
18
})
allow
(
Sidekiq
).
to
receive
(
:options
).
and_return
({
concurrency:
18
})
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment