Commit a0f45336 authored by Thong Kuah's avatar Thong Kuah

Make prometheus always use VERSION when running upgrade_command, similar to install_command.

We cannot use `version` as there are instances which may have
incompatible values, eg. 2.0.0.

Technially this method is not a way to upgrade the helm chart to a later
version - it was introduced to allow config maps to be updated. We are
yet to address changing helm chart versions
parent f03d7237
...@@ -7,7 +7,7 @@ module EE ...@@ -7,7 +7,7 @@ module EE
prepended do prepended do
state_machine :status do state_machine :status do
after_transition any => :updating do |application| after_transition any => :updating do |application|
application.update(last_update_started_at: Time.now) application.update(last_update_started_at: Time.now, version: application.class.const_get(:VERSION))
end end
end end
end end
...@@ -34,11 +34,12 @@ module EE ...@@ -34,11 +34,12 @@ module EE
::Gitlab::Kubernetes::Helm::GetCommand.new(name) ::Gitlab::Kubernetes::Helm::GetCommand.new(name)
end end
# TODO allow users to chose which version to upgrade to.
def upgrade_command(values) def upgrade_command(values)
::Gitlab::Kubernetes::Helm::UpgradeCommand.new( ::Gitlab::Kubernetes::Helm::UpgradeCommand.new(
name, name,
version: self.class.const_get(:VERSION),
chart: chart, chart: chart,
version: version,
values: values values: values
) )
end end
......
...@@ -12,6 +12,16 @@ describe Clusters::Applications::Prometheus do ...@@ -12,6 +12,16 @@ describe Clusters::Applications::Prometheus do
expect { subject.make_updating }.to change { subject.reload.last_update_started_at }.to be_within(1.second).of(Time.now) expect { subject.make_updating }.to change { subject.reload.last_update_started_at }.to be_within(1.second).of(Time.now)
end end
end end
context 'application install previously errored with older version' do
subject { create(:clusters_applications_prometheus, :installed, cluster: cluster, version: '6.7.2') }
it 'updates the application version' do
subject.make_updating
expect(subject.reload.version).to eq('6.7.3')
end
end
end end
describe '#ready' do describe '#ready' do
...@@ -118,6 +128,7 @@ describe Clusters::Applications::Prometheus do ...@@ -118,6 +128,7 @@ describe Clusters::Applications::Prometheus do
expect(command.name).to eq('prometheus') expect(command.name).to eq('prometheus')
expect(command.chart).to eq('stable/prometheus') expect(command.chart).to eq('stable/prometheus')
expect(command.version).to eq('6.7.3')
expect(command.values).to eq(values) expect(command.values).to eq(values)
end end
end end
......
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