Commit 3337253e authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Remove memoization of counters in Gitlab::Gpg

This causes issues when the Prometheus registry is reset. The class may
be holding stale references.

This is not an issue in production but this caused issues in specs
because we clear the registry before Prometheus related specs.
parent f20d70eb
......@@ -142,13 +142,11 @@ module Gitlab
end
def tmp_keychains_created
@tmp_keychains_created ||= Gitlab::Metrics.counter(:gpg_tmp_keychains_created_total,
'The number of temporary GPG keychains created')
Gitlab::Metrics.counter(:gpg_tmp_keychains_created_total, 'The number of temporary GPG keychains created')
end
def tmp_keychains_removed
@tmp_keychains_removed ||= Gitlab::Metrics.counter(:gpg_tmp_keychains_removed_total,
'The number of temporary GPG keychains removed')
Gitlab::Metrics.counter(:gpg_tmp_keychains_removed_total, 'The number of temporary GPG keychains removed')
end
end
end
......@@ -143,11 +143,6 @@ RSpec.describe Gitlab::Gpg do
end
it 'keeps track of created and removed keychains in counters' do
# Gitlab::Gpg may be memoizing stale counters if a preceding spec resets the Prometheus registry
# https://gitlab.com/gitlab-org/gitlab/-/issues/286874
described_class.remove_instance_variable(:@tmp_keychains_created)
described_class.remove_instance_variable(:@tmp_keychains_removed)
created = Gitlab::Metrics.counter(:gpg_tmp_keychains_created_total, 'The number of temporary GPG keychains')
removed = Gitlab::Metrics.counter(:gpg_tmp_keychains_removed_total, 'The number of temporary GPG keychains')
......
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