spring-cloud / spring-cloud-open-service-broker

Spring Cloud project for creating service brokers that conform to the Open Server Broker API specification
https://spring.io/projects/spring-cloud-open-service-broker
Apache License 2.0
167 stars 118 forks source link

ServiceBrokerCreateOperationInProgressException should accept and return operation state #284

Closed gberche-orange closed 4 years ago

gberche-orange commented 4 years ago

Expected behavior

https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md#response-3 mentions

Status Code Description

[..] 202 Accepted | MUST be returned if the Service Instance provisioning is in progress. The operation string MUST match that returned for the original request. This triggers the Platform to poll the Last Operation for Service Instances endpoint for operation status. Note that a re-sent PUT request MUST return a 202 Accepted, not a 200 OK, if the Service Instance is not yet fully provisioned.

Observed behavior

Currently the operation string does not seem to be returned in the response body in a parseable json string

https://github.com/spring-cloud/spring-cloud-open-service-broker/blob/a8fa63fdfcbf0f2f6e103ae1f9082ff3c59e7a90/spring-cloud-open-service-broker-core/src/main/java/org/springframework/cloud/servicebroker/exception/ServiceBrokerCreateOperationInProgressException.java#L28

https://github.com/spring-cloud/spring-cloud-open-service-broker/blob/a8fa63fdfcbf0f2f6e103ae1f9082ff3c59e7a90/spring-cloud-open-service-broker-core/src/main/java/org/springframework/cloud/servicebroker/controller/ServiceBrokerExceptionHandler.java#L181-L185

As a workaround, don't use ServiceBrokerCreateOperationInProgressException, and directly control status code and response body.

return Mono.just(CreateServiceInstanceResponse.builder()
                        .dashboardUrl(dashboard)
                        .operation(operation)
                        .async(true)
                        .instanceExisted(false)
                        .build());
royclarkson commented 4 years ago

Thanks for reporting!

royclarkson commented 4 years ago

This is part of the OSBAPI 2.15 spec, so will need to be back ported to 3.1.x.

https://github.com/openservicebrokerapi/servicebroker/blob/v2.15/spec.md#response-3

royclarkson commented 4 years ago

There are five scenarios where this applies with three different exception objects: