diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2019-07-02 13:00:00 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2019-07-02 13:00:00 +0000 |
commit | a7cc29c89f71c8f80806115a70c92750d4350a92 (patch) | |
tree | 14d568eee2e7b9be3524bb05efcfdbd2daa17f89 | |
parent | 34a22b831135faeb8f4c70a3b8a3b8d525ccd164 (diff) | |
parent | 637e510da147f73587faa0414c67638c2e4729f7 (diff) | |
download | gitlab-ce-a7cc29c89f71c8f80806115a70c92750d4350a92.tar.gz |
Merge branch 'feature/uninstall_cluster_ingress' into 'master'
Feature/uninstall cluster ingress
See merge request gitlab-org/gitlab-ce!29977
-rw-r--r-- | app/models/clusters/applications/ingress.rb | 15 | ||||
-rw-r--r-- | app/models/clusters/applications/jupyter.rb | 4 | ||||
-rw-r--r-- | app/models/clusters/applications/prometheus.rb | 8 | ||||
-rw-r--r-- | changelogs/unreleased/feature-uninstall_cluster_ingress.yml | 5 | ||||
-rw-r--r-- | doc/user/clusters/applications.md | 1 | ||||
-rw-r--r-- | spec/features/projects/clusters/applications_spec.rb | 23 | ||||
-rw-r--r-- | spec/models/clusters/applications/ingress_spec.rb | 16 |
7 files changed, 42 insertions, 30 deletions
diff --git a/app/models/clusters/applications/ingress.rb b/app/models/clusters/applications/ingress.rb index a1023f44049..1430b82c2f2 100644 --- a/app/models/clusters/applications/ingress.rb +++ b/app/models/clusters/applications/ingress.rb @@ -35,11 +35,8 @@ module Clusters 'stable/nginx-ingress' end - # We will implement this in future MRs. - # Basically we need to check all dependent applications are not installed - # first. def allowed_to_uninstall? - false + external_ip_or_hostname? && application_jupyter_nil_or_installable? end def install_command @@ -52,6 +49,10 @@ module Clusters ) end + def external_ip_or_hostname? + external_ip.present? || external_hostname.present? + end + def schedule_status_update return unless installed? return if external_ip @@ -63,6 +64,12 @@ module Clusters def ingress_service cluster.kubeclient.get_service('ingress-nginx-ingress-controller', Gitlab::Kubernetes::Helm::NAMESPACE) end + + private + + def application_jupyter_nil_or_installable? + cluster.application_jupyter.nil? || cluster.application_jupyter&.installable? + end end end end diff --git a/app/models/clusters/applications/jupyter.rb b/app/models/clusters/applications/jupyter.rb index 9e4b87d0993..9ede0615fa3 100644 --- a/app/models/clusters/applications/jupyter.rb +++ b/app/models/clusters/applications/jupyter.rb @@ -23,9 +23,7 @@ module Clusters return unless cluster&.application_ingress_available? ingress = cluster.application_ingress - if ingress.external_ip || ingress.external_hostname - self.status = 'installable' - end + self.status = 'installable' if ingress.external_ip_or_hostname? end def chart diff --git a/app/models/clusters/applications/prometheus.rb b/app/models/clusters/applications/prometheus.rb index a6b7617b830..805c8a73f8c 100644 --- a/app/models/clusters/applications/prometheus.rb +++ b/app/models/clusters/applications/prometheus.rb @@ -49,14 +49,6 @@ module Clusters ) end - def uninstall_command - Gitlab::Kubernetes::Helm::DeleteCommand.new( - name: name, - rbac: cluster.platform_kubernetes_rbac?, - files: files - ) - end - def upgrade_command(values) ::Gitlab::Kubernetes::Helm::InstallCommand.new( name: name, diff --git a/changelogs/unreleased/feature-uninstall_cluster_ingress.yml b/changelogs/unreleased/feature-uninstall_cluster_ingress.yml new file mode 100644 index 00000000000..c3f8464c4b4 --- /dev/null +++ b/changelogs/unreleased/feature-uninstall_cluster_ingress.yml @@ -0,0 +1,5 @@ +--- +title: Allow Ingress to be uninstalled from the UI +merge_request: 29977 +author: +type: added diff --git a/doc/user/clusters/applications.md b/doc/user/clusters/applications.md index f2516c6db0c..469a7c09250 100644 --- a/doc/user/clusters/applications.md +++ b/doc/user/clusters/applications.md @@ -251,6 +251,7 @@ The applications below can be uninstalled. | Application | GitLab version | Notes | | ----------- | -------------- | ----- | +| Ingress | 12.1+ | The associated load balancer and IP will be deleted and cannot be restored. Furthermore, it can only be uninstalled if JupyterHub is not installed. | | JupyterHub | 12.1+ | All data not committed to GitLab will be deleted and cannot be restored. | | Prometheus | 11.11+ | All data will be deleted and cannot be restored. | diff --git a/spec/features/projects/clusters/applications_spec.rb b/spec/features/projects/clusters/applications_spec.rb index 527508b3519..c75259d1b0c 100644 --- a/spec/features/projects/clusters/applications_spec.rb +++ b/spec/features/projects/clusters/applications_spec.rb @@ -21,8 +21,7 @@ describe 'Clusters Applications', :js do it 'user is unable to install applications' do page.within('.js-cluster-application-row-helm') do - expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') - expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Install') + expect(page).to have_css('.js-cluster-application-install-button[disabled]', exact_text: 'Install') end end end @@ -53,19 +52,16 @@ describe 'Clusters Applications', :js do it 'they see status transition' do page.within('.js-cluster-application-row-helm') do # FE sends request and gets the response, then the buttons is "Installing" - expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') - expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing') + expect(page).to have_css('.js-cluster-application-install-button[disabled]', exact_text: 'Installing') Clusters::Cluster.last.application_helm.make_installing! # FE starts polling and update the buttons to "Installing" - expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') - expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing') + expect(page).to have_css('.js-cluster-application-install-button[disabled]', exact_text: 'Installing') Clusters::Cluster.last.application_helm.make_installed! - expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') - expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installed') + expect(page).to have_css('.js-cluster-application-install-button[disabled]', exact_text: 'Installed') end expect(page).to have_content('Helm Tiller was successfully installed on your Kubernetes cluster') @@ -212,26 +208,25 @@ describe 'Clusters Applications', :js do it 'they see status transition' do page.within('.js-cluster-application-row-ingress') do # FE sends request and gets the response, then the buttons is "Installing" - expect(page).to have_css('.js-cluster-application-install-button[disabled]') - expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing') + expect(page).to have_css('.js-cluster-application-install-button[disabled]', exact_text: 'Installing') Clusters::Cluster.last.application_ingress.make_installing! # FE starts polling and update the buttons to "Installing" - expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing') - expect(page).to have_css('.js-cluster-application-install-button[disabled]') + expect(page).to have_css('.js-cluster-application-install-button[disabled]', exact_text: 'Installing') # The application becomes installed but we keep waiting for external IP address Clusters::Cluster.last.application_ingress.make_installed! - expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installed') - expect(page).to have_css('.js-cluster-application-install-button[disabled]') + expect(page).to have_css('.js-cluster-application-install-button[disabled]', exact_text: 'Installed') expect(page).to have_selector('.js-no-endpoint-message') expect(page).to have_selector('.js-ingress-ip-loading-icon') # We receive the external IP address and display Clusters::Cluster.last.application_ingress.update!(external_ip: '192.168.1.100') + expect(page).not_to have_css('.js-cluster-application-install-button') + expect(page).to have_css('.js-cluster-application-uninstall-button:not([disabled])', exact_text: 'Uninstall') expect(page).not_to have_selector('.js-no-endpoint-message') expect(page.find('.js-endpoint').value).to eq('192.168.1.100') end diff --git a/spec/models/clusters/applications/ingress_spec.rb b/spec/models/clusters/applications/ingress_spec.rb index 292ddabd2d8..057517d3820 100644 --- a/spec/models/clusters/applications/ingress_spec.rb +++ b/spec/models/clusters/applications/ingress_spec.rb @@ -21,7 +21,21 @@ describe Clusters::Applications::Ingress do describe '#can_uninstall?' do subject { ingress.can_uninstall? } - it { is_expected.to be_falsey } + it 'returns true if application_jupyter_nil_or_installable? AND external_ip_or_hostname? are true' do + ingress.external_ip = 'IP' + + is_expected.to be_truthy + end + + it 'returns false if application_jupyter_nil_or_installable? is false' do + create(:clusters_applications_jupyter, :installed, cluster: ingress.cluster) + + is_expected.to be_falsey + end + + it 'returns false if external_ip_or_hostname? is false' do + is_expected.to be_falsey + end end describe '#make_installed!' do |