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
FETCH_IP_ADDRESS_DELAY, application.name, application.id)
end
end
after_transition any => [:installed, :updated] do |application|
application.run_after_commit do
ClusterConfigureIstioWorker.perform_async(application.cluster_id)
end
end
end
default_value_for :version, VERSION
......
......@@ -17,8 +17,6 @@ module Serverless
knative.pages_domain = knative.find_available_domain(pages_domain_id)
knative.serverless_domain_cluster.update(creator: creator) if knative.pages_domain
ClusterConfigureIstioWorker.perform_async(knative.cluster_id)
end
private
......
......@@ -14,6 +14,7 @@ describe Clusters::Applications::Knative do
before do
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_in)
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_async)
allow(ClusterConfigureIstioWorker).to receive(:perform_async)
end
describe 'associations' do
......@@ -47,6 +48,32 @@ describe Clusters::Applications::Knative do
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
subject { knative.can_uninstall? }
......
......@@ -13,12 +13,6 @@ describe Serverless::AssociateDomainService do
context 'when the domain is unchanged' do
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
expect { subject.execute }.not_to change { sdc.reload.creator }
end
......@@ -35,12 +29,6 @@ describe Serverless::AssociateDomainService do
it 'does not attempt to update creator' do
expect { subject.execute }.not_to raise_error
end
it 'schedules a ClusterConfigureIstioWorker for the cluster' do
expect(ClusterConfigureIstioWorker).to receive(:perform_async).with(knative.cluster_id)
subject.execute
end
end
context 'when a new domain is associated' 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)
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
expect { subject.execute }.to change { sdc.reload.creator }.from(sdc.creator).to(creator)
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