Commit 6fb6fac6 authored by Thong Kuah's avatar Thong Kuah

Merge branch '356505-fix-race-condition' into 'master'

Fix metrics related race condition in sidekiq-cluster

See merge request gitlab-org/gitlab!83720
parents e9725a0f d8bb4fca
......@@ -100,6 +100,11 @@ module Gitlab
unless @dryrun
@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
start_and_supervise_workers(queue_groups)
......@@ -118,11 +123,6 @@ module Gitlab
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
supervisor = SidekiqProcessSupervisor.instance(
......
......@@ -303,8 +303,9 @@ RSpec.describe Gitlab::SidekiqCluster::CLI, stub_settings_source: true do # rubo
allow(Gitlab::SidekiqCluster).to receive(:start).and_return([])
end
it 'wipes the metrics directory' do
expect(metrics_cleanup_service).to receive(:execute)
it 'wipes the metrics directory before starting workers' do
expect(metrics_cleanup_service).to receive(:execute).ordered
expect(Gitlab::SidekiqCluster).to receive(:start).ordered.and_return([])
cli.run(%w(foo))
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment