diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2019-08-02 19:02:57 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-08-02 19:02:57 +0000 |
commit | 5027979b9ba0ebfb6376cfa78114e942f5054c5c (patch) | |
tree | 3a5f5c44fc2f3960569aec6d5e98ce382172dfd2 /app/models | |
parent | 2d697018ca7ea63cbbdf7879bc93b8fa1b2ae678 (diff) | |
download | gitlab-ce-5027979b9ba0ebfb6376cfa78114e942f5054c5c.tar.gz |
Implement Helm ResetCommand for removing Tiller
Also creates specs
Only allow Helm to be uninstalled if it's the only app
- Remove Tiller leftovers after reser command
- Fixes specs and offenses
Adds changelog file
Fix reset_command specs
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/clusters/applications/helm.rb | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/app/models/clusters/applications/helm.rb b/app/models/clusters/applications/helm.rb index a83d06c4b00..3a175fec148 100644 --- a/app/models/clusters/applications/helm.rb +++ b/app/models/clusters/applications/helm.rb @@ -14,6 +14,7 @@ module Clusters include ::Clusters::Concerns::ApplicationCore include ::Clusters::Concerns::ApplicationStatus + include ::Gitlab::Utils::StrongMemoize default_value_for :version, Gitlab::Kubernetes::Helm::HELM_VERSION @@ -29,11 +30,22 @@ module Clusters self.status = 'installable' if cluster&.platform_kubernetes_active? end - # We will implement this in future MRs. - # Basically we need to check all other applications are not installed - # first. + # It can only be uninstalled if there are no other applications installed + # or with intermitent installation statuses in the database. def allowed_to_uninstall? - false + strong_memoize(:allowed_to_uninstall) do + applications = nil + + Clusters::Cluster::APPLICATIONS.each do |application_name, klass| + next if application_name == 'helm' + + extra_apps = Clusters::Applications::Helm.where('EXISTS (?)', klass.select(1).where(cluster_id: cluster_id)) + + applications = applications.present? ? applications.or(extra_apps) : extra_apps + end + + !applications.exists? + end end def install_command @@ -44,6 +56,14 @@ module Clusters ) end + def uninstall_command + Gitlab::Kubernetes::Helm::ResetCommand.new( + name: name, + files: files, + rbac: cluster.platform_kubernetes_rbac? + ) + end + def has_ssl? ca_key.present? && ca_cert.present? end |