Skip to content

Commit efc2f4f

Browse files
authored
Updating a route destination protocol informs backend (#3787)
* Updating a route destination protocol informs backend - Updates the RouteDestinationUpdate action to behave like other route update endpoints and notify Diego immediately - Prior to this change users would need to manually restart their app to get a route destination protocol change to take effect Fixes #3687
1 parent 6d32549 commit efc2f4f

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

app/actions/route_destination_update.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ def update(destination, message)
1414

1515
destination.save
1616
end
17+
18+
destination.processes.each do |process|
19+
ProcessRouteHandler.new(process).notify_backend_of_route_update
20+
end
21+
22+
destination
1723
end
1824

1925
private

spec/unit/actions/route_destination_update_spec.rb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@ module VCAP::CloudController
66
subject(:destination_update) { RouteDestinationUpdate }
77

88
describe '#update' do
9-
let!(:destination) { RouteMappingModel.make({ protocol: 'http1' }) }
9+
let(:process) { ProcessModelFactory.make(state: 'STARTED') }
10+
let!(:destination) { RouteMappingModel.make({ protocol: 'http1', app_guid: process.app.guid, process_type: process.type }) }
11+
let(:process_route_handler) { instance_double(ProcessRouteHandler, notify_backend_of_route_update: nil) }
1012

1113
let(:message) do
12-
VCAP::CloudController::RouteDestinationUpdateMessage.new({
13-
protocol: 'http2'
14-
})
14+
VCAP::CloudController::RouteDestinationUpdateMessage.new(
15+
{
16+
protocol: 'http2'
17+
}
18+
)
19+
end
20+
21+
before do
22+
allow(ProcessRouteHandler).to receive(:new).with(process).and_return(process_route_handler)
1523
end
1624

1725
it 'updates the destination record' do
@@ -20,6 +28,11 @@ module VCAP::CloudController
2028
expect(updated_destination.protocol).to eq 'http2'
2129
end
2230

31+
it 'notifies the backend of route updates' do
32+
RouteDestinationUpdate.update(destination, message)
33+
expect(process_route_handler).to have_received(:notify_backend_of_route_update)
34+
end
35+
2336
context 'when the given protocol is incompatible' do
2437
context 'for tcp route' do
2538
let(:routing_api_client) { double('routing_api_client', router_group:) }

0 commit comments

Comments
 (0)