Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
GitLab
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
需求
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
测试用例
产物
部署
发布
Package registry
容器镜像库
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
洞察
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
gitlab-cn
GitLab
提交
2302ca66
提交
2302ca66
编辑于
5 years ago
作者:
Stan Hu
浏览文件
操作
下载
差异文件
Merge branch 'bvl-remove-cleanup-feature-flag' into 'master'
Remove feature flag for GPG cleanup See merge request gitlab-org/gitlab!20718
上级
b503f808
62820dd7
No related branches found
No related tags found
无相关合并请求
变更
3
隐藏空白变更内容
行内
左右并排
显示
3 个更改的文件
changelogs/unreleased/bvl-remove-cleanup-feature-flag.yml
+6
-0
6 个添加, 0 个删除
changelogs/unreleased/bvl-remove-cleanup-feature-flag.yml
lib/gitlab/gpg.rb
+3
-4
3 个添加, 4 个删除
lib/gitlab/gpg.rb
spec/lib/gitlab/gpg_spec.rb
+19
-9
19 个添加, 9 个删除
spec/lib/gitlab/gpg_spec.rb
有
28 个添加
和
13 个删除
changelogs/unreleased/bvl-remove-cleanup-feature-flag.yml
0 → 100644
+
6
−
0
浏览文件 @
2302ca66
---
title
:
Try longer to clean up after using a gpg-keychain and raise exption if the
cleanup fails
merge_request
:
20718
author
:
type
:
fixed
此差异已折叠。
点击以展开。
lib/gitlab/gpg.rb
+
3
−
4
浏览文件 @
2302ca66
...
@@ -5,7 +5,7 @@ module Gpg
...
@@ -5,7 +5,7 @@ module Gpg
extend
self
extend
self
CleanupError
=
Class
.
new
(
StandardError
)
CleanupError
=
Class
.
new
(
StandardError
)
BG_CLEANUP_RUNTIME_S
=
2
BG_CLEANUP_RUNTIME_S
=
10
FG_CLEANUP_RUNTIME_S
=
0.5
FG_CLEANUP_RUNTIME_S
=
0.5
MUTEX
=
Mutex
.
new
MUTEX
=
Mutex
.
new
...
@@ -107,19 +107,18 @@ def optimistic_using_tmp_keychain
...
@@ -107,19 +107,18 @@ def optimistic_using_tmp_keychain
begin
begin
cleanup_tmp_dir
(
tmp_dir
)
cleanup_tmp_dir
(
tmp_dir
)
rescue
CleanupError
=>
e
rescue
CleanupError
=>
e
folder_contents
=
Dir
.
children
(
tmp_dir
)
# This means we left a GPG-agent process hanging. Logging the problem in
# This means we left a GPG-agent process hanging. Logging the problem in
# sentry will make this more visible.
# sentry will make this more visible.
Gitlab
::
Sentry
.
track_exception
(
e
,
Gitlab
::
Sentry
.
track_exception
(
e
,
issue_url:
'https://gitlab.com/gitlab-org/gitlab/issues/20918'
,
issue_url:
'https://gitlab.com/gitlab-org/gitlab/issues/20918'
,
extra:
{
tmp_dir:
tmp_dir
})
extra:
{
tmp_dir:
tmp_dir
,
contents:
folder_contents
})
end
end
tmp_keychains_removed
.
increment
unless
File
.
exist?
(
tmp_dir
)
tmp_keychains_removed
.
increment
unless
File
.
exist?
(
tmp_dir
)
end
end
def
cleanup_tmp_dir
(
tmp_dir
)
def
cleanup_tmp_dir
(
tmp_dir
)
return
FileUtils
.
remove_entry
(
tmp_dir
,
true
)
if
Feature
.
disabled?
(
:gpg_cleanup_retries
)
# Retry when removing the tmp directory failed, as we may run into a
# Retry when removing the tmp directory failed, as we may run into a
# race condition:
# race condition:
# The `gpg-agent` agent process may clean up some files as well while
# The `gpg-agent` agent process may clean up some files as well while
...
...
此差异已折叠。
点击以展开。
spec/lib/gitlab/gpg_spec.rb
+
19
−
9
浏览文件 @
2302ca66
...
@@ -177,6 +177,25 @@
...
@@ -177,6 +177,25 @@
end
.
not_to
raise_error
end
.
not_to
raise_error
end
end
it
'tracks an exception when cleaning up the tmp dir fails'
do
expected_exception
=
described_class
::
CleanupError
.
new
(
'cleanup failed'
)
expected_tmp_dir
=
nil
expect
(
described_class
).
to
receive
(
:cleanup_tmp_dir
).
and_raise
(
expected_exception
)
allow
(
Gitlab
::
Sentry
).
to
receive
(
:track_exception
)
described_class
.
using_tmp_keychain
do
expected_tmp_dir
=
described_class
.
current_home_dir
FileUtils
.
touch
(
File
.
join
(
expected_tmp_dir
,
'dummy.file'
))
end
expect
(
Gitlab
::
Sentry
).
to
have_received
(
:track_exception
).
with
(
expected_exception
,
issue_url:
'https://gitlab.com/gitlab-org/gitlab/issues/20918'
,
extra:
{
tmp_dir:
expected_tmp_dir
,
contents:
[
'dummy.file'
]
}
)
end
shared_examples
'multiple deletion attempts of the tmp-dir'
do
|
seconds
|
shared_examples
'multiple deletion attempts of the tmp-dir'
do
|
seconds
|
let
(
:tmp_dir
)
do
let
(
:tmp_dir
)
do
tmp_dir
=
Dir
.
mktmpdir
tmp_dir
=
Dir
.
mktmpdir
...
@@ -211,15 +230,6 @@
...
@@ -211,15 +230,6 @@
expect
(
File
.
exist?
(
tmp_dir
)).
to
be
false
expect
(
File
.
exist?
(
tmp_dir
)).
to
be
false
end
end
it
'does not retry when the feature flag is disabled'
do
stub_feature_flags
(
gpg_cleanup_retries:
false
)
expect
(
FileUtils
).
to
receive
(
:remove_entry
).
with
(
tmp_dir
,
true
).
and_call_original
expect
(
Retriable
).
not_to
receive
(
:retriable
)
described_class
.
using_tmp_keychain
{}
end
end
end
it_behaves_like
'multiple deletion attempts of the tmp-dir'
,
described_class
::
FG_CLEANUP_RUNTIME_S
it_behaves_like
'multiple deletion attempts of the tmp-dir'
,
described_class
::
FG_CLEANUP_RUNTIME_S
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录