Commit 8ba06918 authored by Dhiraj Bodicherla's avatar Dhiraj Bodicherla Committed by Peter Leitzen

Do not override #editable? in PrometheusService

- Also add specs to ensure that #fields method always returns the
fields, even when there is a cluster present with Prometheus installed.

- This is being done so that the Prometheus manual configuration is
editable even when there is a Prometheus managed app installed on a
cluster.
parent 7b5ad03d
...@@ -36,10 +36,6 @@ class PrometheusService < MonitoringService ...@@ -36,10 +36,6 @@ class PrometheusService < MonitoringService
false false
end end
def editable?
manual_configuration? || !prometheus_available?
end
def title def title
'Prometheus' 'Prometheus'
end end
...@@ -53,8 +49,6 @@ class PrometheusService < MonitoringService ...@@ -53,8 +49,6 @@ class PrometheusService < MonitoringService
end end
def fields def fields
return [] unless editable?
[ [
{ {
type: 'checkbox', type: 'checkbox',
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
.col-lg-9 .col-lg-9
= form_for(@service, as: :service, url: scoped_integration_path(@service), method: :put, html: { class: 'gl-show-field-errors integration-settings-form js-integration-settings-form', data: { 'can-test' => @service.can_test?, 'test-url' => test_project_service_path(@project, @service) } }) do |form| = form_for(@service, as: :service, url: scoped_integration_path(@service), method: :put, html: { class: 'gl-show-field-errors integration-settings-form js-integration-settings-form', data: { 'can-test' => @service.can_test?, 'test-url' => test_project_service_path(@project, @service) } }) do |form|
= render 'shared/service_settings', form: form, service: @service = render 'shared/service_settings', form: form, service: @service
- if @service.editable?
.footer-block.row-content-block .footer-block.row-content-block
= service_save_button(@service) = service_save_button(@service)
&nbsp; &nbsp;
......
...@@ -3,7 +3,5 @@ ...@@ -3,7 +3,5 @@
%h4.append-bottom-default %h4.append-bottom-default
= s_('PrometheusService|Manual configuration') = s_('PrometheusService|Manual configuration')
%p
- unless @service.editable? = s_('PrometheusService|Select the Active checkbox to override the Auto Configuration with custom settings. If unchecked, Auto Configuration settings are used.')
.info-well
= s_('PrometheusService|To enable manual configuration, uninstall Prometheus from your clusters')
...@@ -13,7 +13,5 @@ ...@@ -13,7 +13,5 @@
%b.append-bottom-default %b.append-bottom-default
= s_('PrometheusService|Manual configuration') = s_('PrometheusService|Manual configuration')
%p
- unless service.editable? = s_('PrometheusService|Select the Active checkbox to override the Auto Configuration with custom settings. If unchecked, Auto Configuration settings are used.')
.info-well
= s_('PrometheusService|To enable manual configuration, uninstall Prometheus from your clusters')
---
title: Make manual prometheus configuration section always editable
merge_request: 29209
author:
type: changed
...@@ -16342,13 +16342,13 @@ msgstr "" ...@@ -16342,13 +16342,13 @@ msgstr ""
msgid "PrometheusService|Prometheus is being automatically managed on your clusters" msgid "PrometheusService|Prometheus is being automatically managed on your clusters"
msgstr "" msgstr ""
msgid "PrometheusService|These metrics will only be monitored after your first deployment to an environment" msgid "PrometheusService|Select the Active checkbox to override the Auto Configuration with custom settings. If unchecked, Auto Configuration settings are used."
msgstr "" msgstr ""
msgid "PrometheusService|Time-series monitoring service" msgid "PrometheusService|These metrics will only be monitored after your first deployment to an environment"
msgstr "" msgstr ""
msgid "PrometheusService|To enable manual configuration, uninstall Prometheus from your clusters" msgid "PrometheusService|Time-series monitoring service"
msgstr "" msgstr ""
msgid "PrometheusService|To enable the installation of Prometheus on your clusters, deactivate the manual configuration below" msgid "PrometheusService|To enable the installation of Prometheus on your clusters, deactivate the manual configuration below"
......
...@@ -19,6 +19,14 @@ describe Gitlab::Prometheus::Adapter do ...@@ -19,6 +19,14 @@ describe Gitlab::Prometheus::Adapter do
it 'return prometheus service as prometheus adapter' do it 'return prometheus service as prometheus adapter' do
expect(subject.prometheus_adapter).to eq(prometheus_service) expect(subject.prometheus_adapter).to eq(prometheus_service)
end end
context 'with cluster with prometheus available' do
let!(:prometheus) { create(:clusters_applications_prometheus, :installed, cluster: cluster) }
it 'returns prometheus service' do
expect(subject.prometheus_adapter).to eq(prometheus_service)
end
end
end end
context "prometheus service can't execute queries" do context "prometheus service can't execute queries" do
......
...@@ -418,4 +418,48 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do ...@@ -418,4 +418,48 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
end end
end end
end end
describe '#editable?' do
it 'is editable' do
expect(service.editable?).to be(true)
end
context 'when cluster exists with prometheus installed' do
let(:cluster) { create(:cluster, projects: [project]) }
before do
service.update!(manual_configuration: false)
create(:clusters_applications_prometheus, :installed, cluster: cluster)
end
it 'remains editable' do
expect(service.editable?).to be(true)
end
end
end
describe '#fields' do
let(:expected_fields) do
[
{
type: 'checkbox',
name: 'manual_configuration',
title: s_('PrometheusService|Active'),
required: true
},
{
type: 'text',
name: 'api_url',
title: 'API URL',
placeholder: s_('PrometheusService|Prometheus API Base URL, like http://prometheus.example.com/'),
required: true
}
]
end
it 'returns fields' do
expect(service.fields).to eq(expected_fields)
end
end
end end
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