Commit 0d5165a4 authored by Alishan Ladhani's avatar Alishan Ladhani

Refactor scheduling of ClusterConfigureIstioWorker

Move scheduling of the worker out of BaseService and make it
part of a state transition (after make_install happens). This
ensures that Knative is installed before we attempt to update it.
parent 6a135d60
...@@ -33,6 +33,12 @@ module Clusters ...@@ -33,6 +33,12 @@ module Clusters
FETCH_IP_ADDRESS_DELAY, application.name, application.id) FETCH_IP_ADDRESS_DELAY, application.name, application.id)
end end
end end
after_transition any => [:installed, :updated] do |application|
application.run_after_commit do
ClusterConfigureIstioWorker.perform_async(application.cluster_id)
end
end
end end
default_value_for :version, VERSION default_value_for :version, VERSION
......
...@@ -17,8 +17,6 @@ module Serverless ...@@ -17,8 +17,6 @@ module Serverless
knative.pages_domain = knative.find_available_domain(pages_domain_id) knative.pages_domain = knative.find_available_domain(pages_domain_id)
knative.serverless_domain_cluster.update(creator: creator) if knative.pages_domain knative.serverless_domain_cluster.update(creator: creator) if knative.pages_domain
ClusterConfigureIstioWorker.perform_async(knative.cluster_id)
end end
private private
......
...@@ -14,6 +14,7 @@ describe Clusters::Applications::Knative do ...@@ -14,6 +14,7 @@ describe Clusters::Applications::Knative do
before do before do
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_in) allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_in)
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_async) allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_async)
allow(ClusterConfigureIstioWorker).to receive(:perform_async)
end end
describe 'associations' do describe 'associations' do
...@@ -47,6 +48,32 @@ describe Clusters::Applications::Knative do ...@@ -47,6 +48,32 @@ describe Clusters::Applications::Knative do
end end
end end
describe 'configuring istio ingress gateway' do
context 'after installed' do
let(:application) { create(:clusters_applications_knative, :installing) }
before do
application.make_installed!
end
it 'schedules a ClusterConfigureIstioWorker' do
expect(ClusterConfigureIstioWorker).to have_received(:perform_async).with(application.cluster_id)
end
end
context 'after updated' do
let(:application) { create(:clusters_applications_knative, :updating) }
before do
application.make_installed!
end
it 'schedules a ClusterConfigureIstioWorker' do
expect(ClusterConfigureIstioWorker).to have_received(:perform_async).with(application.cluster_id)
end
end
end
describe '#can_uninstall?' do describe '#can_uninstall?' do
subject { knative.can_uninstall? } subject { knative.can_uninstall? }
......
...@@ -13,12 +13,6 @@ describe Serverless::AssociateDomainService do ...@@ -13,12 +13,6 @@ describe Serverless::AssociateDomainService do
context 'when the domain is unchanged' do context 'when the domain is unchanged' do
let(:creator) { create(:user) } let(:creator) { create(:user) }
it 'does not schedule a ClusterConfigureIstioWorker' do
expect(ClusterConfigureIstioWorker).not_to receive(:perform_async)
subject.execute
end
it 'does not update creator' do it 'does not update creator' do
expect { subject.execute }.not_to change { sdc.reload.creator } expect { subject.execute }.not_to change { sdc.reload.creator }
end end
...@@ -35,12 +29,6 @@ describe Serverless::AssociateDomainService do ...@@ -35,12 +29,6 @@ describe Serverless::AssociateDomainService do
it 'does not attempt to update creator' do it 'does not attempt to update creator' do
expect { subject.execute }.not_to raise_error expect { subject.execute }.not_to raise_error
end end
it 'schedules a ClusterConfigureIstioWorker for the cluster' do
expect(ClusterConfigureIstioWorker).to receive(:perform_async).with(knative.cluster_id)
subject.execute
end
end end
context 'when a new domain is associated' do context 'when a new domain is associated' do
...@@ -51,12 +39,6 @@ describe Serverless::AssociateDomainService do ...@@ -51,12 +39,6 @@ describe Serverless::AssociateDomainService do
expect { subject.execute }.to change { knative.pages_domain.id }.from(sdc.pages_domain.id).to(pages_domain_id) expect { subject.execute }.to change { knative.pages_domain.id }.from(sdc.pages_domain.id).to(pages_domain_id)
end end
it 'schedules a ClusterConfigureIstioWorker for the cluster' do
expect(ClusterConfigureIstioWorker).to receive(:perform_async).with(knative.cluster_id)
subject.execute
end
it 'updates creator' do it 'updates creator' do
expect { subject.execute }.to change { sdc.reload.creator }.from(sdc.creator).to(creator) expect { subject.execute }.to change { sdc.reload.creator }.from(sdc.creator).to(creator)
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