summaryrefslogtreecommitdiff
path: root/lib/api/ci
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 15:40:28 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 15:40:28 +0000
commitb595cb0c1dec83de5bdee18284abe86614bed33b (patch)
tree8c3d4540f193c5ff98019352f554e921b3a41a72 /lib/api/ci
parent2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff)
downloadgitlab-ce-b595cb0c1dec83de5bdee18284abe86614bed33b.tar.gz
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'lib/api/ci')
-rw-r--r--lib/api/ci/helpers/runner.rb13
1 files changed, 13 insertions, 0 deletions
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