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

Commit aac120e

Browse files
author
Derik Evangelista
authored
v3(bindings): cant create bindings while SI operations are in progress (cloudfoundry#1862)
[#174257929](https://www.pivotaltracker.com/story/show/174257929)
1 parent a64417e commit aac120e

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

app/actions/service_credential_binding_create.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def validate!(service_instance, app, volume_mount_services_enabled)
7979
service_not_bindable! unless service_instance.service_plan.bindable?
8080
service_not_available! unless service_instance.service_plan.active?
8181
volume_mount_not_enabled! if service_instance.volume_service? && !volume_mount_services_enabled
82+
operation_in_progress! if service_instance.operation_in_progress?
8283
end
8384
end
8485

@@ -90,6 +91,10 @@ def event_repository
9091
Repositories::ServiceBindingEventRepository
9192
end
9293

94+
def operation_in_progress!
95+
raise UnprocessableCreate.new('There is an operation in progress for the service instance')
96+
end
97+
9398
def app_is_required!
9499
raise UnprocessableCreate.new('No app was specified')
95100
end

spec/request/service_credential_bindings_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,17 @@ def check_filtered_bindings(*bindings)
11861186
'code' => 10008,
11871187
}))
11881188
end
1189+
1190+
it 'responds with 422 when there is an operation in progress for the service instance' do
1191+
service_instance.save_with_new_operation({}, { type: 'guacamole', state: 'in progress' })
1192+
api_call.call admin_headers
1193+
expect(last_response).to have_status_code(422)
1194+
expect(parsed_response['errors']).to include(include({
1195+
'detail' => include('There is an operation in progress for the service instance'),
1196+
'title' => 'CF-UnprocessableEntity',
1197+
'code' => 10008,
1198+
}))
1199+
end
11891200
end
11901201

11911202
context 'when the service instance and the app are not in the same space' do

spec/unit/actions/service_credential_binding_create_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,19 @@ module V3
119119
end
120120
end
121121

122+
context 'when there is an operation in progress for the service instance' do
123+
it 'raises an error' do
124+
service_instance.save_with_new_operation({}, { type: 'tacos', state: 'in progress' })
125+
126+
expect {
127+
action.precursor(service_instance, app: app, volume_mount_services_enabled: false)
128+
}.to raise_error(
129+
ServiceCredentialBindingCreate::UnprocessableCreate,
130+
'There is an operation in progress for the service instance'
131+
)
132+
end
133+
end
134+
122135
context 'when the service is a volume service and service volume mounting is enabled' do
123136
let(:service_instance) { ManagedServiceInstance.make(:volume_mount, **details) }
124137

0 commit comments

Comments
 (0)