Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions app/actions/service_credential_binding_app_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
module VCAP::CloudController
module V3
class ServiceCredentialBindingAppCreate < V3::ServiceBindingCreate
class UnprocessableCreate < StandardError
end

class Unimplemented < StandardError
end

Expand Down Expand Up @@ -81,14 +78,6 @@ def event_repository
Repositories::ServiceGenericBindingEventRepository::SERVICE_APP_CREDENTIAL_BINDING)
end

def operation_in_progress!
raise UnprocessableCreate.new('There is an operation in progress for the service instance')
end

def service_instance_not_found!
raise UnprocessableCreate.new('Service instance not found')
end

def app_is_required!
raise UnprocessableCreate.new('No app was specified')
end
Expand Down
10 changes: 2 additions & 8 deletions app/actions/service_credential_binding_key_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ module V3
class ServiceCredentialBindingKeyCreate < V3::ServiceBindingCreate
include ServiceCredentialBindingCreateMixin

class UnprocessableCreate < StandardError
end

def initialize(user_audit_info, audit_hash)
super()
@user_audit_info = user_audit_info
Expand Down Expand Up @@ -52,6 +49,7 @@ def validate_service_instance!(service_instance)
if service_instance.managed_instance?
service_not_bindable! unless service_instance.service_plan.bindable?
service_not_available! unless service_instance.service_plan.active?
service_instance_not_found! if service_instance.create_failed?
operation_in_progress! if service_instance.operation_in_progress?
else
key_not_supported_for_user_provided_service!
Expand Down Expand Up @@ -87,10 +85,6 @@ def key_incomplete_deletion!(key_name)
"The service instance already has a key binding with the name '#{key_name}' that is getting deleted or its deletion failed.")
end

def operation_in_progress!
raise UnprocessableCreate.new('There is an operation in progress for the service instance.')
end

def service_not_bindable!
raise UnprocessableCreate.new('Service plan does not allow bindings.')
end
Expand All @@ -105,7 +99,7 @@ def volume_mount_not_enabled!

class ValidationErrorHandler
def error!(message)
raise UnprocessableCreate.new(message)
raise ServiceCredentialBindingKeyCreate::UnprocessableCreate.new(message)
end
end
end
Expand Down
11 changes: 4 additions & 7 deletions app/actions/service_route_binding_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ def precursor(service_instance, route, message:)
end
end

class UnprocessableCreate < StandardError; end

class RouteBindingAlreadyExists < StandardError; end

private
Expand All @@ -51,7 +49,10 @@ def validate!(service_instance, route)
space_mismatch! unless route.space == service_instance.space
already_exists! if route.service_instance == service_instance
already_bound! if route.service_instance
operation_in_progress! if service_instance.operation_in_progress?
if service_instance.managed_instance?
service_instance_not_found! if service_instance.create_failed?
operation_in_progress! if service_instance.operation_in_progress?
end
end

def permitted_binding_attributes
Expand All @@ -62,10 +63,6 @@ def post_bind_action(binding)
binding.notify_diego
end

def operation_in_progress!
raise UnprocessableCreate.new('There is an operation in progress for the service instance')
end

def route_is_internal!
raise UnprocessableCreate.new('Route services cannot be bound to internal routes')
end
Expand Down
11 changes: 11 additions & 0 deletions app/actions/v3/service_binding_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class LastOperationFailedState < StandardError
end

class ServiceBindingCreate
class UnprocessableCreate < StandardError
end

PollingStatus = Struct.new(:finished, :retry_after).freeze
PollingFinished = PollingStatus.new(true, nil).freeze
ContinuePolling = ->(retry_after) { PollingStatus.new(false, retry_after) }
Expand Down Expand Up @@ -124,6 +127,14 @@ def bindings_retrievable?(binding)
def not_retrievable!
raise BindingNotRetrievable.new('The broker responded asynchronously but does not support fetching binding data')
end

def service_instance_not_found!
raise UnprocessableCreate.new('Service instance not found')
end

def operation_in_progress!
raise UnprocessableCreate.new('There is an operation in progress for the service instance')
end
end
end
end
2 changes: 1 addition & 1 deletion spec/request/service_instances_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2748,7 +2748,7 @@ def check_filtered_instances(*instances)
end
end

context 'and it is an delete operation' do
context 'and it is a delete operation' do
before do
service_instance.save_with_new_operation({}, { type: 'delete', state: 'in progress', description: 'almost there, I promise' })
end
Expand Down
15 changes: 14 additions & 1 deletion spec/unit/actions/service_credential_binding_key_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,20 @@ module V3
action.precursor(service_instance, message: message)
}.to raise_error(
ServiceCredentialBindingKeyCreate::UnprocessableCreate,
'There is an operation in progress for the service instance.'
'There is an operation in progress for the service instance'
)
end
end

context "when the service instance is in state 'create failed'" do
it 'raises an error' do
service_instance.save_with_new_operation({}, { type: 'create', state: 'failed' })

expect {
action.precursor(service_instance, message: message)
}.to raise_error(
ServiceCredentialBindingKeyCreate::UnprocessableCreate,
'Service instance not found'
)
end
end
Expand Down
13 changes: 13 additions & 0 deletions spec/unit/actions/service_route_binding_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,19 @@ module V3
)
end
end

context "when the service instance is in state 'create failed'" do
it 'raises an error' do
service_instance.save_with_new_operation({}, { type: 'create', state: 'failed' })

expect {
action.precursor(service_instance, route, message: message)
}.to raise_error(
ServiceRouteBindingCreate::UnprocessableCreate,
'Service instance not found'
)
end
end
end

context 'user-provided service instance' do
Expand Down