Fix rubocop warnings
This commit is contained in:
parent
09473b192c
commit
57c1f7cae0
4 changed files with 19 additions and 13 deletions
|
@ -23,7 +23,7 @@ class PrometheusService < MonitoringService
|
||||||
|
|
||||||
def initialize_properties
|
def initialize_properties
|
||||||
if properties.nil?
|
if properties.nil?
|
||||||
self.properties = { }
|
self.properties = {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,7 +45,8 @@ class PrometheusService < MonitoringService
|
||||||
|
|
||||||
def fields
|
def fields
|
||||||
[
|
[
|
||||||
{ type: 'fieldset',
|
{
|
||||||
|
type: 'fieldset',
|
||||||
legend: 'Manual Configuration',
|
legend: 'Manual Configuration',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
@ -100,6 +101,7 @@ class PrometheusService < MonitoringService
|
||||||
# Cache metrics for specific environment
|
# Cache metrics for specific environment
|
||||||
def calculate_reactive_cache(query_class_name, environment_id, *args)
|
def calculate_reactive_cache(query_class_name, environment_id, *args)
|
||||||
return unless active? && project && !project.pending_delete?
|
return unless active? && project && !project.pending_delete?
|
||||||
|
|
||||||
client = client(environment_id)
|
client = client(environment_id)
|
||||||
|
|
||||||
data = Kernel.const_get(query_class_name).new(client).query(environment_id, *args)
|
data = Kernel.const_get(query_class_name).new(client).query(environment_id, *args)
|
||||||
|
@ -118,9 +120,10 @@ class PrometheusService < MonitoringService
|
||||||
else
|
else
|
||||||
cluster = cluster_with_prometheus(environment_id)
|
cluster = cluster_with_prometheus(environment_id)
|
||||||
raise Gitlab::PrometheusError, "couldn't find cluster with Prometheus installed" unless cluster
|
raise Gitlab::PrometheusError, "couldn't find cluster with Prometheus installed" unless cluster
|
||||||
rest_client = client_from_cluster(cluster)
|
|
||||||
|
|
||||||
|
rest_client = client_from_cluster(cluster)
|
||||||
raise Gitlab::PrometheusError, "couldn't create proxy Prometheus client" unless rest_client
|
raise Gitlab::PrometheusError, "couldn't create proxy Prometheus client" unless rest_client
|
||||||
|
|
||||||
Gitlab::PrometheusClient.new(rest_client)
|
Gitlab::PrometheusClient.new(rest_client)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,6 +32,6 @@ describe Gitlab::Prometheus::Queries::DeploymentQuery do
|
||||||
time: stop_time)
|
time: stop_time)
|
||||||
|
|
||||||
expect(subject.query(environment.id, deployment.id)).to eq(memory_values: nil, memory_before: nil, memory_after: nil,
|
expect(subject.query(environment.id, deployment.id)).to eq(memory_values: nil, memory_before: nil, memory_after: nil,
|
||||||
cpu_values: nil, cpu_before: nil, cpu_after: nil)
|
cpu_values: nil, cpu_before: nil, cpu_after: nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -51,13 +51,16 @@ describe Clusters::Applications::Prometheus do
|
||||||
|
|
||||||
context 'cluster has kubeclient' do
|
context 'cluster has kubeclient' do
|
||||||
let(:kubernetes_url) { 'http://example.com' }
|
let(:kubernetes_url) { 'http://example.com' }
|
||||||
let(:k8s_discover_response) { {
|
let(:k8s_discover_response) do
|
||||||
resources: [
|
{
|
||||||
{
|
resources: [
|
||||||
name: 'service',
|
{
|
||||||
kind: 'Service'
|
name: 'service',
|
||||||
}]
|
kind: 'Service'
|
||||||
} }
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
let(:kube_client) { Kubeclient::Client.new(kubernetes_url) }
|
let(:kube_client) { Kubeclient::Client.new(kubernetes_url) }
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
|
||||||
context 'with cluster for all environments without prometheus installed' do
|
context 'with cluster for all environments without prometheus installed' do
|
||||||
context 'without environment supplied' do
|
context 'without environment supplied' do
|
||||||
it 'raises PrometheusError because cluster was not found' do
|
it 'raises PrometheusError because cluster was not found' do
|
||||||
expect{service.client}.to raise_error(Gitlab::PrometheusError, /couldn't find cluster with Prometheus installed/)
|
expect { service.client }.to raise_error(Gitlab::PrometheusError, /couldn't find cluster with Prometheus installed/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
|
||||||
let!(:environment) { create(:environment, project: project, name: 'prod') }
|
let!(:environment) { create(:environment, project: project, name: 'prod') }
|
||||||
|
|
||||||
it 'raises PrometheusError because cluster was not found' do
|
it 'raises PrometheusError because cluster was not found' do
|
||||||
expect{service.client}.to raise_error(Gitlab::PrometheusError, /couldn't find cluster with Prometheus installed/)
|
expect { service.client }.to raise_error(Gitlab::PrometheusError, /couldn't find cluster with Prometheus installed/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue