Skip to content

Commit

Permalink
Updating a route destination protocol informs backend (#3787)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tcdowney committed May 8, 2024
1 parent 6d32549 commit efc2f4f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
6 changes: 6 additions & 0 deletions app/actions/route_destination_update.rb
Expand Up @@ -14,6 +14,12 @@ def update(destination, message)

destination.save
end

destination.processes.each do |process|
ProcessRouteHandler.new(process).notify_backend_of_route_update
end

destination
end

private
Expand Down
21 changes: 17 additions & 4 deletions spec/unit/actions/route_destination_update_spec.rb
Expand Up @@ -6,12 +6,20 @@ module VCAP::CloudController
subject(:destination_update) { RouteDestinationUpdate }

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

let(:message) do
VCAP::CloudController::RouteDestinationUpdateMessage.new({
protocol: 'http2'
})
VCAP::CloudController::RouteDestinationUpdateMessage.new(
{
protocol: 'http2'
}
)
end

before do
allow(ProcessRouteHandler).to receive(:new).with(process).and_return(process_route_handler)
end

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

it 'notifies the backend of route updates' do
RouteDestinationUpdate.update(destination, message)
expect(process_route_handler).to have_received(:notify_backend_of_route_update)
end

context 'when the given protocol is incompatible' do
context 'for tcp route' do
let(:routing_api_client) { double('routing_api_client', router_group:) }
Expand Down

0 comments on commit efc2f4f

Please sign in to comment.