Commit 9494936e authored by Thong Kuah's avatar Thong Kuah

Do not update helm version when externally_installed

If need be, we create the helm record. We assume the helm record is also
externally installed.
parent bedde99a
...@@ -97,13 +97,21 @@ module Clusters ...@@ -97,13 +97,21 @@ 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|
# When installing any application we are also performing an update unless ::Gitlab::Kubernetes::Helm.local_tiller_enabled? || application.is_a?(Clusters::Applications::Helm)
# of tiller (see Gitlab::Kubernetes::Helm::ClientCommand) so if transition.event == :make_externally_installed
# therefore we need to reflect that in the database. # If an application is externally installed
# We assume the helm application is externally installed too
unless ::Gitlab::Kubernetes::Helm.local_tiller_enabled? helm = application.cluster.application_helm || application.cluster.build_application_helm
application.cluster.application_helm.update!(version: Gitlab::Kubernetes::Helm::HELM_VERSION)
helm.make_externally_installed!
else
# When installing any application we are also performing an update
# of tiller (see Gitlab::Kubernetes::Helm::ClientCommand) so
# therefore we need to reflect that in the database.
application.cluster.application_helm.update!(version: Gitlab::Kubernetes::Helm::HELM_VERSION)
end
end end
end end
......
...@@ -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