diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /lib/gitlab/cluster | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'lib/gitlab/cluster')
-rw-r--r-- | lib/gitlab/cluster/lifecycle_events.rb | 22 | ||||
-rw-r--r-- | lib/gitlab/cluster/mixins/unicorn_http_server.rb | 34 | ||||
-rw-r--r-- | lib/gitlab/cluster/puma_worker_killer_initializer.rb | 7 |
3 files changed, 9 insertions, 54 deletions
diff --git a/lib/gitlab/cluster/lifecycle_events.rb b/lib/gitlab/cluster/lifecycle_events.rb index b3dc59466ec..6159fb0a811 100644 --- a/lib/gitlab/cluster/lifecycle_events.rb +++ b/lib/gitlab/cluster/lifecycle_events.rb @@ -8,13 +8,13 @@ module Gitlab # LifecycleEvents lets Rails initializers register application startup hooks # that are sensitive to forking. For example, to defer the creation of # watchdog threads. This lets us abstract away the Unix process - # lifecycles of Unicorn, Sidekiq, Puma, Puma Cluster, etc. + # lifecycles of Sidekiq, Puma, Puma Cluster, etc. # # We have the following lifecycle events. # # - on_before_fork (on master process): # - # Unicorn/Puma Cluster: This will be called exactly once, + # Puma Cluster: This will be called exactly once, # on startup, before the workers are forked. This is # called in the PARENT/MASTER process. # @@ -22,7 +22,7 @@ module Gitlab # # - on_master_start (on master process): # - # Unicorn/Puma Cluster: This will be called exactly once, + # Puma Cluster: This will be called exactly once, # on startup, before the workers are forked. This is # called in the PARENT/MASTER process. # @@ -30,7 +30,7 @@ module Gitlab # # - on_before_blackout_period (on master process): # - # Unicorn/Puma Cluster: This will be called before a blackout + # Puma Cluster: This will be called before a blackout # period when performing graceful shutdown of master. # This is called on `master` process. # @@ -38,7 +38,7 @@ module Gitlab # # - on_before_graceful_shutdown (on master process): # - # Unicorn/Puma Cluster: This will be called before a graceful + # Puma Cluster: This will be called before a graceful # shutdown of workers starts happening, but after blackout period. # This is called on `master` process. # @@ -46,11 +46,6 @@ module Gitlab # # - on_before_master_restart (on master process): # - # Unicorn: This will be called before a new master is spun up. - # This is called on forked master before `execve` to become - # a new masterfor Unicorn. This means that this does not really - # affect old master process. - # # Puma Cluster: This will be called before a new master is spun up. # This is called on `master` process. # @@ -58,7 +53,7 @@ module Gitlab # # - on_worker_start (on worker process): # - # Unicorn/Puma Cluster: This is called in the worker process + # Puma Cluster: This is called in the worker process # exactly once before processing requests. # # Sidekiq/Puma Single: This is called immediately. @@ -114,7 +109,7 @@ module Gitlab end # - # Lifecycle integration methods (called from unicorn.rb, puma.rb, etc.) + # Lifecycle integration methods (called from puma.rb, etc.) # def do_worker_start call(:worker_start_hooks, @worker_start_hooks) @@ -167,9 +162,6 @@ module Gitlab # Sidekiq doesn't fork return false if Gitlab::Runtime.sidekiq? - # Unicorn always forks - return true if Gitlab::Runtime.unicorn? - # Puma sometimes forks return true if in_clustered_puma? diff --git a/lib/gitlab/cluster/mixins/unicorn_http_server.rb b/lib/gitlab/cluster/mixins/unicorn_http_server.rb deleted file mode 100644 index 440ed02a355..00000000000 --- a/lib/gitlab/cluster/mixins/unicorn_http_server.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Cluster - module Mixins - module UnicornHttpServer - def self.prepended(base) - unless base.method_defined?(:reexec) && base.method_defined?(:stop) - raise 'missing method Unicorn::HttpServer#reexec or Unicorn::HttpServer#stop' - end - end - - def reexec - Gitlab::Cluster::LifecycleEvents.do_before_graceful_shutdown - - super - end - - # The stop on non-graceful shutdown is executed twice: - # `#stop(false)` and `#stop`. - # - # The first stop will wipe-out all workers, so we need to check - # the flag and a list of workers - def stop(graceful = true) - if graceful && @workers.any? # rubocop:disable Gitlab/ModuleWithInstanceVariables - Gitlab::Cluster::LifecycleEvents.do_before_graceful_shutdown - end - - super - end - end - end - end -end diff --git a/lib/gitlab/cluster/puma_worker_killer_initializer.rb b/lib/gitlab/cluster/puma_worker_killer_initializer.rb index fd9f58a34f3..e634291f894 100644 --- a/lib/gitlab/cluster/puma_worker_killer_initializer.rb +++ b/lib/gitlab/cluster/puma_worker_killer_initializer.rb @@ -12,12 +12,9 @@ module Gitlab require 'puma_worker_killer' PumaWorkerKiller.config do |config| - # Note! ram is expressed in megabytes (whereas GITLAB_UNICORN_MEMORY_MAX is in bytes) - # Importantly RAM is for _all_workers (ie, the cluster), - # not each worker as is the case with GITLAB_UNICORN_MEMORY_MAX worker_count = puma_options[:workers] || 1 - # The Puma Worker Killer checks the total RAM used by both the master - # and worker processes. + # The Puma Worker Killer checks the total memory used by the cluster, + # i.e. both primary and worker processes. # https://github.com/schneems/puma_worker_killer/blob/v0.1.0/lib/puma_worker_killer/puma_memory.rb#L57 # # Additional memory is added when running in `development` |