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

Commit 7dadb29

Browse files
authored
v3(services): Retry-After header type conversion (cloudfoundry#1824)
The Retry-After header is always a string, so we should convert it to a number [#174398274](https://www.pivotaltracker.com/story/show/174398274)
1 parent 2f57de6 commit 7dadb29

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

app/jobs/v3/create_route_binding_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def perform
5454
finish
5555
when ServiceRouteBindingCreate::PollingNotComplete
5656
unless polling_status.retry_after.nil?
57-
self.polling_interval_seconds = polling_status.retry_after
57+
self.polling_interval_seconds = polling_status.retry_after.to_i
5858
end
5959
end
6060
rescue ServiceRouteBindingCreate::BindingNotRetrievable

app/jobs/v3/service_instance_async_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def operation_completed?
132132

133133
def fetch_last_operation(client)
134134
last_operation_result = client.fetch_service_instance_last_operation(service_instance)
135-
self.polling_interval_seconds = last_operation_result[:retry_after] if last_operation_result[:retry_after]
135+
self.polling_interval_seconds = last_operation_result[:retry_after].to_i if last_operation_result[:retry_after]
136136

137137
operation_failed!(last_operation_result.dig(:last_operation)[:description]) if last_operation_result[:http_status_code] == HTTP::Status::BAD_REQUEST
138138

spec/unit/jobs/v3/create_route_binding_job_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ module V3
132132

133133
context 'retry interval' do
134134
def test_retry_after(value, expected)
135-
allow(action).to receive(:poll).and_return(ServiceRouteBindingCreate::PollingNotComplete.new(value))
135+
allow(action).to receive(:poll).and_return(ServiceRouteBindingCreate::PollingNotComplete.new(value.to_s))
136136
subject.perform
137137
expect(subject.polling_interval_seconds).to eq(expected)
138138
end

spec/unit/jobs/v3/service_instance_async_job_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,11 @@ def send_broker_request(_) end
458458
[
459459
{
460460
last_operation: { state: 'in progress', type: operation },
461-
retry_after: 95
461+
retry_after: '95'
462462
},
463463
{
464464
last_operation: { state: 'in progress', type: operation },
465-
retry_after: 180
465+
retry_after: '180'
466466
},
467467
]
468468
}

0 commit comments

Comments
 (0)