summaryrefslogtreecommitdiff
path: root/lib/api/internal
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 15:44:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 15:44:42 +0000
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /lib/api/internal
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
downloadgitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'lib/api/internal')
-rw-r--r--lib/api/internal/base.rb4
-rw-r--r--lib/api/internal/kubernetes.rb18
2 files changed, 11 insertions, 11 deletions
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')