Commit 9de23c57 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents fe2896f6 95bbcf08
...@@ -7,9 +7,9 @@ class Projects::Environments::PrometheusApiController < Projects::ApplicationCon ...@@ -7,9 +7,9 @@ class Projects::Environments::PrometheusApiController < Projects::ApplicationCon
def proxy def proxy
result = Prometheus::ProxyService.new( result = Prometheus::ProxyService.new(
environment, environment,
request.method, proxy_method,
params[:proxy_path], proxy_path,
params.permit! proxy_params
).execute ).execute
if result.nil? if result.nil?
...@@ -31,7 +31,30 @@ class Projects::Environments::PrometheusApiController < Projects::ApplicationCon ...@@ -31,7 +31,30 @@ class Projects::Environments::PrometheusApiController < Projects::ApplicationCon
private private
def query_context
Gitlab::Prometheus::QueryVariables.call(environment)
end
def environment def environment
@environment ||= project.environments.find(params[:id]) @environment ||= project.environments.find(params[:id])
end end
def proxy_method
request.method
end
def proxy_path
params[:proxy_path]
end
def proxy_params
substitute_query_variables(params).permit!
end
def substitute_query_variables(params)
query = params[:query]
return params unless query
params.merge(query: query % query_context)
end
end end
---
title: Remove deadline for Git fsck
merge_request: 27299
author:
type: fixed
...@@ -190,7 +190,7 @@ module Gitlab ...@@ -190,7 +190,7 @@ module Gitlab
def fsck def fsck
request = Gitaly::FsckRequest.new(repository: @gitaly_repo) request = Gitaly::FsckRequest.new(repository: @gitaly_repo)
response = GitalyClient.call(@storage, :repository_service, :fsck, request) response = GitalyClient.call(@storage, :repository_service, :fsck, request, timeout: GitalyClient.no_timeout)
if response.error.empty? if response.error.empty?
return "", 0 return "", 0
......
...@@ -14,6 +14,7 @@ describe Projects::Environments::PrometheusApiController do ...@@ -14,6 +14,7 @@ describe Projects::Environments::PrometheusApiController do
describe 'GET #proxy' do describe 'GET #proxy' do
let(:prometheus_proxy_service) { instance_double(Prometheus::ProxyService) } let(:prometheus_proxy_service) { instance_double(Prometheus::ProxyService) }
let(:expected_params) do let(:expected_params) do
ActionController::Parameters.new( ActionController::Parameters.new(
environment_params( environment_params(
...@@ -47,6 +48,38 @@ describe Projects::Environments::PrometheusApiController do ...@@ -47,6 +48,38 @@ describe Projects::Environments::PrometheusApiController do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq(prometheus_json_body) expect(json_response).to eq(prometheus_json_body)
end end
context 'with format string' do
before do
expected_params[:query] = %{up{environment="#{environment.slug}"}}
end
it 'replaces variables with values' do
get :proxy, params: environment_params.merge(query: 'up{environment="%{ci_environment_slug}"}')
expect(Prometheus::ProxyService).to have_received(:new)
.with(environment, 'GET', 'query', expected_params)
end
context 'with nil query' do
let(:params_without_query) do
params = environment_params
params.delete(:query)
params
end
before do
expected_params.delete(:query)
end
it 'does not raise error' do
get :proxy, params: params_without_query
expect(Prometheus::ProxyService).to have_received(:new)
.with(environment, 'GET', 'query', expected_params)
end
end
end
end end
context 'with nil result' do context 'with nil result' do
......
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