Skip to content
代码片段 群组 项目
提交 d07e9d1b 编辑于 作者: Nikola Milojevic's avatar Nikola Milojevic 提交者: Matthias Käppler
浏览文件

Fix watchdog stop logging

This handles a case where the reason field
was missing from logs.
上级 2dbc45c5
No related branches found
No related tags found
无相关合并请求
...@@ -68,12 +68,11 @@ def call ...@@ -68,12 +68,11 @@ def call
monitor if Feature.enabled?(:gitlab_memory_watchdog, type: :ops) monitor if Feature.enabled?(:gitlab_memory_watchdog, type: :ops)
end end
event_reporter.stopped(log_labels(memwd_reason: @reason).compact) event_reporter.stopped(log_labels(memwd_reason: @stop_reason).compact)
end end
def stop(reason: nil) def stop
@reason = reason stop_working(reason: 'background task stopped')
@alive = false
end end
private private
...@@ -84,7 +83,7 @@ def stop(reason: nil) ...@@ -84,7 +83,7 @@ def stop(reason: nil)
def monitor def monitor
if monitors.empty? if monitors.empty?
stop(reason: 'monitors are not configured') stop_working(reason: 'monitors are not configured')
return return
end end
...@@ -106,7 +105,7 @@ def strike_exceeded_callback(monitor_name, monitor_payload) ...@@ -106,7 +105,7 @@ def strike_exceeded_callback(monitor_name, monitor_payload)
Gitlab::Memory::Reports::HeapDump.enqueue! Gitlab::Memory::Reports::HeapDump.enqueue!
stop(reason: 'successfully handled') if handler.call stop_working(reason: 'successfully handled') if handler.call
end end
def handler def handler
...@@ -123,6 +122,13 @@ def log_labels(extra = {}) ...@@ -123,6 +122,13 @@ def log_labels(extra = {})
memwd_sleep_time_s: sleep_time_seconds memwd_sleep_time_s: sleep_time_seconds
) )
end end
def stop_working(reason:)
return unless @alive
@stop_reason = reason
@alive = false
end
end end
end end
end end
...@@ -98,7 +98,8 @@ def self.name ...@@ -98,7 +98,8 @@ def self.name
expect(reporter).to receive(:stopped).once expect(reporter).to receive(:stopped).once
.with( .with(
memwd_handler_class: handler.class.name, memwd_handler_class: handler.class.name,
memwd_sleep_time_s: sleep_time_seconds memwd_sleep_time_s: sleep_time_seconds,
memwd_reason: 'background task stopped'
) )
watchdog.call watchdog.call
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册