diff options
author | Matt Kasa <mkasa@gitlab.com> | 2019-09-05 14:53:51 -0700 |
---|---|---|
committer | Matt Kasa <mkasa@gitlab.com> | 2019-09-05 16:23:35 -0700 |
commit | af83cd2ae154877104c76db1c3271f04265bd4a4 (patch) | |
tree | 04da8bd05da01271a74941520ecc9a1125ac0974 | |
parent | 9d38778f4146fec734695be02f1e63c58f6d78db (diff) | |
download | gitlab-ce-af83cd2ae154877104c76db1c3271f04265bd4a4.tar.gz |
Fix setting cluster application statuses
- Add status_states method to get list of states with their values
- Change applications to set status to status_states values
-rw-r--r-- | app/models/clusters/applications/helm.rb | 2 | ||||
-rw-r--r-- | app/models/clusters/applications/jupyter.rb | 2 | ||||
-rw-r--r-- | app/models/clusters/applications/knative.rb | 2 | ||||
-rw-r--r-- | app/models/clusters/concerns/application_core.rb | 2 | ||||
-rw-r--r-- | app/models/clusters/concerns/application_status.rb | 6 |
5 files changed, 10 insertions, 4 deletions
diff --git a/app/models/clusters/applications/helm.rb b/app/models/clusters/applications/helm.rb index 455cf200fbc..261f6ce8987 100644 --- a/app/models/clusters/applications/helm.rb +++ b/app/models/clusters/applications/helm.rb @@ -27,7 +27,7 @@ module Clusters def set_initial_status return unless not_installable? - self.status = 'installable' if cluster&.platform_kubernetes_active? + self.status = status_states[:installable] if cluster&.platform_kubernetes_active? end # It can only be uninstalled if there are no other applications installed diff --git a/app/models/clusters/applications/jupyter.rb b/app/models/clusters/applications/jupyter.rb index ec65482a846..ca93bc15be0 100644 --- a/app/models/clusters/applications/jupyter.rb +++ b/app/models/clusters/applications/jupyter.rb @@ -23,7 +23,7 @@ module Clusters return unless cluster&.application_ingress_available? ingress = cluster.application_ingress - self.status = 'installable' if ingress.external_ip_or_hostname? + self.status = status_states[:installable] if ingress.external_ip_or_hostname? end def chart diff --git a/app/models/clusters/applications/knative.rb b/app/models/clusters/applications/knative.rb index a9b9374622d..1069ba9cbef 100644 --- a/app/models/clusters/applications/knative.rb +++ b/app/models/clusters/applications/knative.rb @@ -21,7 +21,7 @@ module Clusters return unless not_installable? return unless verify_cluster? - self.status = 'installable' + self.status = status_states[:installable] end state_machine :status do diff --git a/app/models/clusters/concerns/application_core.rb b/app/models/clusters/concerns/application_core.rb index 803a65726d3..c16908c9ea9 100644 --- a/app/models/clusters/concerns/application_core.rb +++ b/app/models/clusters/concerns/application_core.rb @@ -15,7 +15,7 @@ module Clusters def set_initial_status return unless not_installable? - self.status = 'installable' if cluster&.application_helm_available? + self.status = status_states[:installable] if cluster&.application_helm_available? end def can_uninstall? diff --git a/app/models/clusters/concerns/application_status.rb b/app/models/clusters/concerns/application_status.rb index 342d766f723..f62e60871a9 100644 --- a/app/models/clusters/concerns/application_status.rb +++ b/app/models/clusters/concerns/application_status.rb @@ -90,6 +90,12 @@ module Clusters end end + def status_states + self.class.state_machines[:status].states.each_with_object({}) do |state, states| + states[state.name] = state.value + end + end + def updateable? installed? || updated? || update_errored? end |