diff options
Diffstat (limited to 'lib/gitlab/sidekiq_daemon/memory_killer.rb')
-rw-r--r-- | lib/gitlab/sidekiq_daemon/memory_killer.rb | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/gitlab/sidekiq_daemon/memory_killer.rb b/lib/gitlab/sidekiq_daemon/memory_killer.rb index 24e2eca420e..b8f86b92844 100644 --- a/lib/gitlab/sidekiq_daemon/memory_killer.rb +++ b/lib/gitlab/sidekiq_daemon/memory_killer.rb @@ -51,9 +51,10 @@ module Gitlab def refresh_state(phase) @phase = PHASE.fetch(phase) - @current_rss = get_rss - @soft_limit_rss = get_soft_limit_rss - @hard_limit_rss = get_hard_limit_rss + @current_rss = get_rss_kb + @soft_limit_rss = get_soft_limit_rss_kb + @hard_limit_rss = get_hard_limit_rss_kb + @memory_total = get_memory_total_kb # track the current state as prometheus gauges @metrics[:sidekiq_memory_killer_phase].set({}, @phase) @@ -107,6 +108,8 @@ module Gitlab end def restart_sidekiq + return if Feature.enabled?(:sidekiq_memory_killer_read_only_mode, type: :ops) + # Tell Sidekiq to stop fetching new jobs # We first SIGNAL and then wait given time # We also monitor a number of running jobs and allow to restart early @@ -176,6 +179,7 @@ module Gitlab current_rss: @current_rss, soft_limit_rss: @soft_limit_rss, hard_limit_rss: @hard_limit_rss, + memory_total_kb: @memory_total, reason: reason, running_jobs: running_jobs) @@ -212,18 +216,19 @@ module Gitlab end end - def get_rss - output, status = Gitlab::Popen.popen(%W(ps -o rss= -p #{pid}), Rails.root.to_s) - return 0 unless status&.zero? + def get_memory_total_kb + Gitlab::Metrics::System.memory_total / 1.kilobytes + end - output.to_i + def get_rss_kb + Gitlab::Metrics::System.memory_usage_rss / 1.kilobytes end - def get_soft_limit_rss + def get_soft_limit_rss_kb SOFT_LIMIT_RSS_KB + rss_increase_by_jobs end - def get_hard_limit_rss + def get_hard_limit_rss_kb HARD_LIMIT_RSS_KB end |