Skip to content
代码片段 群组 项目
提交 d8bb4fca 编辑于 作者: Matthias Kaeppler's avatar Matthias Kaeppler
浏览文件

Fix metrics related race condition in sidekiq-cluster

There was a slight chance that the metrics directory got
wiped after workers had started up, which would result
in their metrics missing.
上级 1d6f5ca0
No related branches found
No related tags found
无相关合并请求
...@@ -100,6 +100,11 @@ def run(argv = ARGV) ...@@ -100,6 +100,11 @@ def run(argv = ARGV)
unless @dryrun unless @dryrun
@logger.info("Starting cluster with #{queue_groups.length} processes") @logger.info("Starting cluster with #{queue_groups.length} processes")
# Make sure we reset the metrics directory prior to:
# - starting a metrics server process
# - starting new workers
::Prometheus::CleanupMultiprocDirService.new(@metrics_dir).execute
end end
start_and_supervise_workers(queue_groups) start_and_supervise_workers(queue_groups)
...@@ -118,11 +123,6 @@ def start_and_supervise_workers(queue_groups) ...@@ -118,11 +123,6 @@ def start_and_supervise_workers(queue_groups)
return if @dryrun return if @dryrun
# Make sure we reset the metrics directory prior to:
# - starting a metrics server process
# - starting new workers
::Prometheus::CleanupMultiprocDirService.new(@metrics_dir).execute
ProcessManagement.write_pid(@pid) if @pid ProcessManagement.write_pid(@pid) if @pid
supervisor = SidekiqProcessSupervisor.instance( supervisor = SidekiqProcessSupervisor.instance(
......
...@@ -303,8 +303,9 @@ ...@@ -303,8 +303,9 @@
allow(Gitlab::SidekiqCluster).to receive(:start).and_return([]) allow(Gitlab::SidekiqCluster).to receive(:start).and_return([])
end end
it 'wipes the metrics directory' do it 'wipes the metrics directory before starting workers' do
expect(metrics_cleanup_service).to receive(:execute) expect(metrics_cleanup_service).to receive(:execute).ordered
expect(Gitlab::SidekiqCluster).to receive(:start).ordered.and_return([])
cli.run(%w(foo)) cli.run(%w(foo))
end end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册