From 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 19 May 2021 15:44:42 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-12-stable-ee --- lib/api/internal/base.rb | 4 ++-- lib/api/internal/kubernetes.rb | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'lib/api/internal') diff --git a/lib/api/internal/base.rb b/lib/api/internal/base.rb index 4dcfc0cf7eb..e16149185c9 100644 --- a/lib/api/internal/base.rb +++ b/lib/api/internal/base.rb @@ -158,7 +158,7 @@ module API status 200 unless actor.key_or_user - raise ActiveRecord::RecordNotFound.new('User not found!') + raise ActiveRecord::RecordNotFound, 'User not found!' end actor.update_last_used_at! @@ -336,4 +336,4 @@ module API end end -API::Internal::Base.prepend_if_ee('EE::API::Internal::Base') +API::Internal::Base.prepend_mod_with('API::Internal::Base') diff --git a/lib/api/internal/kubernetes.rb b/lib/api/internal/kubernetes.rb index af2c53dd778..c28e2181873 100644 --- a/lib/api/internal/kubernetes.rb +++ b/lib/api/internal/kubernetes.rb @@ -107,18 +107,18 @@ module API detail 'Updates usage metrics for agent' end params do - requires :gitops_sync_count, type: Integer, desc: 'The count to increment the gitops_sync metric by' + optional :gitops_sync_count, type: Integer, desc: 'The count to increment the gitops_sync metric by' + optional :k8s_api_proxy_request_count, type: Integer, desc: 'The count to increment the k8s_api_proxy_request_count metric by' end post '/' do - gitops_sync_count = params[:gitops_sync_count] + events = params.slice(:gitops_sync_count, :k8s_api_proxy_request_count) + events.transform_keys! { |event| event.to_s.chomp('_count') } - if gitops_sync_count < 0 - bad_request!('gitops_sync_count must be greater than or equal to zero') - else - Gitlab::UsageDataCounters::KubernetesAgentCounter.increment_gitops_sync(gitops_sync_count) + Gitlab::UsageDataCounters::KubernetesAgentCounter.increment_event_counts(events) - no_content! - end + no_content! + rescue ArgumentError => e + bad_request!(e.message) end end end @@ -126,4 +126,4 @@ module API end end -API::Internal::Kubernetes.prepend_if_ee('EE::API::Internal::Kubernetes') +API::Internal::Kubernetes.prepend_mod_with('API::Internal::Kubernetes') -- cgit v1.2.1