Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
GitLab
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
需求
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
测试用例
产物
部署
发布
Package registry
Container registry
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
洞察
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
gitlab-cn
GitLab
提交
d07e9d1b
提交
d07e9d1b
编辑于
2 years ago
作者:
Nikola Milojevic
提交者:
Matthias Käppler
2 years ago
浏览文件
操作
下载
补丁
差异文件
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
标签 包含提交
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
lib/gitlab/memory/watchdog.rb
+12
-6
12 个添加, 6 个删除
lib/gitlab/memory/watchdog.rb
spec/lib/gitlab/memory/watchdog_spec.rb
+2
-1
2 个添加, 1 个删除
spec/lib/gitlab/memory/watchdog_spec.rb
有
14 个添加
和
7 个删除
lib/gitlab/memory/watchdog.rb
+
12
−
6
浏览文件 @
d07e9d1b
...
@@ -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
此差异已折叠。
点击以展开。
spec/lib/gitlab/memory/watchdog_spec.rb
+
2
−
1
浏览文件 @
d07e9d1b
...
@@ -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.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录