diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-21 15:09:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-21 15:09:04 +0300 |
commit | aac38cc2bd884cb979f1bbf7050c3f8692403cf3 (patch) | |
tree | 42c31b0dc05c63c11ac78171758d02fb9aa7cccf /lib/gitlab/memory | |
parent | 47a3dc65512c6eb3f88e6ba6842f58db3f03413c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/memory')
-rw-r--r-- | lib/gitlab/memory/watchdog.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/gitlab/memory/watchdog.rb b/lib/gitlab/memory/watchdog.rb index 25af5bd781a..3682d6e4462 100644 --- a/lib/gitlab/memory/watchdog.rb +++ b/lib/gitlab/memory/watchdog.rb @@ -68,12 +68,11 @@ module Gitlab monitor if Feature.enabled?(:gitlab_memory_watchdog, type: :ops) end - event_reporter.stopped(log_labels(memwd_reason: @reason).compact) + event_reporter.stopped(log_labels(memwd_reason: @stop_reason).compact) end - def stop(reason: nil) - @reason = reason - @alive = false + def stop + stop_working(reason: 'background task stopped') end private @@ -84,7 +83,7 @@ module Gitlab def monitor if monitors.empty? - stop(reason: 'monitors are not configured') + stop_working(reason: 'monitors are not configured') return end @@ -106,7 +105,7 @@ module Gitlab Gitlab::Memory::Reports::HeapDump.enqueue! - stop(reason: 'successfully handled') if handler.call + stop_working(reason: 'successfully handled') if handler.call end def handler @@ -123,6 +122,13 @@ module Gitlab memwd_sleep_time_s: sleep_time_seconds ) end + + def stop_working(reason:) + return unless @alive + + @stop_reason = reason + @alive = false + end end end end |