Commit e0e6c034 authored by Stan Hu's avatar Stan Hu

Merge branch 'externally_installed_helm_dependency' into 'master'

Externally installed helm dependency

See merge request gitlab-org/gitlab!32935
parents f5e603b6 9494936e
...@@ -97,15 +97,23 @@ module Clusters ...@@ -97,15 +97,23 @@ module Clusters
application.status_reason = status_reason if status_reason application.status_reason = status_reason if status_reason
end end
before_transition any => [:installed, :updated] do |application, _| before_transition any => [:installed, :updated] do |application, transition|
unless ::Gitlab::Kubernetes::Helm.local_tiller_enabled? || application.is_a?(Clusters::Applications::Helm)
if transition.event == :make_externally_installed
# If an application is externally installed
# We assume the helm application is externally installed too
helm = application.cluster.application_helm || application.cluster.build_application_helm
helm.make_externally_installed!
else
# When installing any application we are also performing an update # When installing any application we are also performing an update
# of tiller (see Gitlab::Kubernetes::Helm::ClientCommand) so # of tiller (see Gitlab::Kubernetes::Helm::ClientCommand) so
# therefore we need to reflect that in the database. # therefore we need to reflect that in the database.
unless ::Gitlab::Kubernetes::Helm.local_tiller_enabled?
application.cluster.application_helm.update!(version: Gitlab::Kubernetes::Helm::HELM_VERSION) application.cluster.application_helm.update!(version: Gitlab::Kubernetes::Helm::HELM_VERSION)
end end
end end
end
after_transition any => [:uninstalling], :use_transactions => false do |application, _| after_transition any => [:uninstalling], :use_transactions => false do |application, _|
application.prepare_uninstall application.prepare_uninstall
......
...@@ -197,12 +197,73 @@ RSpec.shared_examples 'cluster application status specs' do |application_name| ...@@ -197,12 +197,73 @@ RSpec.shared_examples 'cluster application status specs' do |application_name|
describe '#make_externally_installed' do describe '#make_externally_installed' do
subject { create(application_name, :installing) } subject { create(application_name, :installing) }
let(:old_helm) { create(:clusters_applications_helm, version: '1.2.3') }
it 'is installed' do it 'is installed' do
subject.make_externally_installed subject.make_externally_installed
expect(subject).to be_installed expect(subject).to be_installed
end end
context 'local tiller flag enabled' do
before do
stub_feature_flags(managed_apps_local_tiller: true)
end
context 'helm record does not exist' do
subject { build(application_name, :installing, :no_helm_installed) }
it 'does not create a helm record' do
subject.make_externally_installed!
subject.cluster.reload
expect(subject.cluster.application_helm).to be_nil
end
end
context 'helm record exists' do
subject { build(application_name, :installing, cluster: old_helm.cluster) }
it 'does not update helm version' do
subject.make_externally_installed!
subject.cluster.application_helm.reload
expect(subject.cluster.application_helm.version).to eq('1.2.3')
end
end
end
context 'local tiller flag disabled' do
before do
stub_feature_flags(managed_apps_local_tiller: false)
end
context 'helm record does not exist' do
subject { build(application_name, :installing, :no_helm_installed) }
it 'creates a helm record' do
subject.make_externally_installed!
subject.cluster.reload
expect(subject.cluster.application_helm).to be_present
expect(subject.cluster.application_helm).to be_persisted
end
end
context 'helm record exists' do
subject { build(application_name, :installing, cluster: old_helm.cluster) }
it 'does not update helm version' do
subject.make_externally_installed!
subject.cluster.application_helm.reload
expect(subject.cluster.application_helm.version).to eq('1.2.3')
end
end
end
context 'application is updated' do context 'application is updated' do
subject { create(application_name, :updated) } subject { create(application_name, :updated) }
......
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