Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 3d00d22

Browse files
v3(services): Update last_operation when job exceeds max_polling_duration
[#174398273](https://www.pivotaltracker.com/story/show/174398273)
1 parent a044502 commit 3d00d22

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

app/jobs/v3/create_route_binding_job.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ def perform
6666
raise CloudController::Errors::ApiError.new_from_details('UnableToPerform', 'bind', e.message)
6767
end
6868

69+
def handle_timeout
70+
route_binding.save_with_new_operation(
71+
{},
72+
{
73+
type: operation_type,
74+
state: 'failed',
75+
description: "Service Broker failed to #{operation} within the required time.",
76+
}
77+
)
78+
end
79+
6980
private
7081

7182
def route_binding

spec/unit/jobs/v3/create_route_binding_job_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,16 @@ def test_retry_after(value, expected)
233233
expect(subject.operation_type).to eq('create')
234234
end
235235
end
236+
237+
describe '#handle_timeout' do
238+
it 'updates the last operation to failed' do
239+
subject.handle_timeout
240+
binding.reload
241+
expect(binding.last_operation.type).to eq('create')
242+
expect(binding.last_operation.state).to eq('failed')
243+
expect(binding.last_operation.description).to eq('Service Broker failed to bind within the required time.')
244+
end
245+
end
236246
end
237247
end
238248
end

0 commit comments

Comments
 (0)