summaryrefslogtreecommitdiff
path: root/app/models/clusters/applications
diff options
context:
space:
mode:
authorThong Kuah <tkuah@gitlab.com>2019-04-15 16:02:52 +1200
committerStan Hu <stanhu@gmail.com>2019-04-29 22:55:12 -0700
commit024ddcab17517befafc0c5163d66cdcaae1b69e6 (patch)
tree49745142971ae8e930a358ca2eb3318021ee440f /app/models/clusters/applications
parenteae0fc2bcd6f7e2e183a922321ace3380c329adc (diff)
downloadgitlab-ce-024ddcab17517befafc0c5163d66cdcaae1b69e6.tar.gz
Deactivate any prometheus_service upon destroy
Basically does the reverse of after_transition to :installed.
Diffstat (limited to 'app/models/clusters/applications')
-rw-r--r--app/models/clusters/applications/prometheus.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/clusters/applications/prometheus.rb b/app/models/clusters/applications/prometheus.rb
index 1a8543f378e..1a715830953 100644
--- a/app/models/clusters/applications/prometheus.rb
+++ b/app/models/clusters/applications/prometheus.rb
@@ -16,6 +16,8 @@ module Clusters
default_value_for :version, VERSION
+ after_destroy :disable_prometheus_integration
+
state_machine :status do
after_transition any => [:installed] do |application|
application.cluster.projects.each do |project|
@@ -90,6 +92,12 @@ module Clusters
private
+ def disable_prometheus_integration
+ cluster.projects.each do |project|
+ project.prometheus_service&.update(active: false)
+ end
+ end
+
def kube_client
cluster&.kubeclient&.core_client
end