From b595cb0c1dec83de5bdee18284abe86614bed33b Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 20 Jul 2022 15:40:28 +0000 Subject: Add latest changes from gitlab-org/gitlab@15-2-stable-ee --- lib/api/ci/helpers/runner.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/api/ci') diff --git a/lib/api/ci/helpers/runner.rb b/lib/api/ci/helpers/runner.rb index 72e36d95dc5..fe49074afed 100644 --- a/lib/api/ci/helpers/runner.rb +++ b/lib/api/ci/helpers/runner.rb @@ -12,6 +12,7 @@ module API JOB_TOKEN_PARAM = :token def authenticate_runner! + track_runner_authentication forbidden! unless current_runner current_runner @@ -42,6 +43,14 @@ module API end end + def track_runner_authentication + if current_runner + metrics.increment_runner_authentication_success_counter(runner_type: current_runner.runner_type) + else + metrics.increment_runner_authentication_failure_counter + end + end + # HTTP status codes to terminate the job on GitLab Runner: # - 403 def authenticate_job!(require_running: true, heartbeat_runner: false) @@ -149,6 +158,10 @@ module API def request_using_running_job_token? current_job.present? && current_authenticated_job.present? && current_job != current_authenticated_job end + + def metrics + strong_memoize(:metrics) { ::Gitlab::Ci::Runner::Metrics.new } + end end end end -- cgit v1.2.1