Commit 4acaaeb9 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'gitaly-client-identity' into 'master'

Propagate client identity to gitaly

See merge request gitlab-org/gitlab!50161
parents d7a20305 39eeac29
......@@ -311,7 +311,7 @@ gem 'gitlab-pg_query', '~> 1.3.1', require: 'pg_query'
gem 'premailer-rails', '~> 1.10.3'
# LabKit: Tracing and Correlation
gem 'gitlab-labkit', '0.13.3'
gem 'gitlab-labkit', '0.13.5'
# I18n
gem 'ruby_parser', '~> 3.15', require: false
......
......@@ -435,7 +435,7 @@ GEM
fog-json (~> 1.2.0)
mime-types
ms_rest_azure (~> 0.12.0)
gitlab-labkit (0.13.3)
gitlab-labkit (0.13.5)
actionpack (>= 5.0.0, < 6.1.0)
activesupport (>= 5.0.0, < 6.1.0)
gitlab-pg_query (~> 1.3)
......@@ -1356,7 +1356,7 @@ DEPENDENCIES
gitlab-chronic (~> 0.10.5)
gitlab-experiment (~> 0.4.4)
gitlab-fog-azure-rm (~> 1.0)
gitlab-labkit (= 0.13.3)
gitlab-labkit (= 0.13.5)
gitlab-license (~> 1.0)
gitlab-mail_room (~> 0.0.8)
gitlab-markup (~> 1.7.1)
......
......@@ -468,6 +468,7 @@ class ApplicationController < ActionController::Base
project: -> { @project if @project&.persisted? },
namespace: -> { @group if @group&.persisted? },
caller_id: caller_id,
remote_ip: request.ip,
feature_category: feature_category) do
yield
ensure
......
---
title: Propagate client identity to gitaly
merge_request: 50161
author:
type: other
......@@ -134,6 +134,11 @@ input AdminSidekiqQueuesDeleteJobsInput {
"""
relatedClass: String
"""
Delete jobs matching remote_ip in the context metadata
"""
remoteIp: String
"""
Delete jobs matching root_namespace in the context metadata
"""
......
......@@ -371,6 +371,16 @@
},
"defaultValue": null
},
{
"name": "remoteIp",
"description": "Delete jobs matching remote_ip in the context metadata",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "relatedClass",
"description": "Delete jobs matching related_class in the context metadata",
......@@ -12,6 +12,7 @@ module Gitlab
Attribute.new(:namespace, Namespace),
Attribute.new(:user, User),
Attribute.new(:caller_id, String),
Attribute.new(:remote_ip, String),
Attribute.new(:related_class, String),
Attribute.new(:feature_category, String)
].freeze
......@@ -45,6 +46,7 @@ module Gitlab
hash[:project] = -> { project_path } if set_values.include?(:project)
hash[:root_namespace] = -> { root_namespace_path } if include_namespace?
hash[:caller_id] = caller_id if set_values.include?(:caller_id)
hash[:remote_ip] = remote_ip if set_values.include?(:remote_ip)
hash[:related_class] = related_class if set_values.include?(:related_class)
hash[:feature_category] = feature_category if set_values.include?(:feature_category)
end
......
......@@ -215,12 +215,16 @@ module Gitlab
'client_name' => CLIENT_NAME
}
context_data = Labkit::Context.current&.to_h
feature_stack = Thread.current[:gitaly_feature_stack]
feature = feature_stack && feature_stack[0]
metadata['call_site'] = feature.to_s if feature
metadata['gitaly-servers'] = address_metadata(remote_storage) if remote_storage
metadata['x-gitlab-correlation-id'] = Labkit::Correlation::CorrelationId.current_id if Labkit::Correlation::CorrelationId.current_id
metadata['gitaly-session-id'] = session_id
metadata['username'] = context_data['meta.user'] if context_data&.fetch('meta.user', nil)
metadata['remote_ip'] = context_data['meta.remote_ip'] if context_data&.fetch('meta.remote_ip', nil)
metadata.merge!(Feature::Gitaly.server_feature_flags)
deadline_info = request_deadline(timeout)
......
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