Can't make my broker unbind or de-provision services.

222 views
Skip to first unread message

Ricardo Sousa

unread,
Jun 17, 2014, 10:26:35 PM6/17/14
to vcap...@cloudfoundry.org
While writing my first service broker for CF, I managed to successfully implement the catalog, provision and binding end-points w/o problems. The unbinding and deprovisioning endpoints are somehow tricky in the sense that I think I'm replying with what's is required by the documentation available at http://docs.cloudfoundry.org/services/api.html, I keep getting status code 404. CC says my broker answered with NotFound for a given service instance even though I can GET that same instance using cf curl. ( logs bellow)  

curl -v  -X GET /v2/service_instances/051dc4e4-7c03-4324-aa42-924caca995e1


REQUEST: [2014-06-17T23:20:58-03:00]

GET /v2/service_instances/051dc4e4-7c03-4324-aa42-924caca995e1 HTTP/1.1

Host: api.stackato-fz7h.local

Accept: application/json

Authorization: [PRIVATE DATA HIDDEN]

Content-Type: application/json

User-Agent: go-cli 6.1.2-6a013ca / darwin




RESPONSE: [2014-06-17T23:20:58-03:00]

HTTP/1.1 200 OK

Connection: close

Content-Length: 742

Content-Type: application/json;charset=utf-8

Date: Mon, 16 Jun 2014 07:46:55 GMT

Server: thin 1.6.1 codename Death Proof

X-Content-Type-Options: nosniff

X-Vcap-Request-Id: a7da0c03-3f5a-4fa4-aeb6-d40525e27872


{"metadata":{"guid":"051dc4e4-7c03-4324-aa42-924caca995e1","url":"/v2/service_instances/051dc4e4-7c03-4324-aa42-924caca995e1","created_at":"2014-06-15T20:14:33-07:00","updated_at":null},"entity":{"name":"custom-mysql-224a7","credentials":{},"service_plan_guid":"b4f382e2-5b34-41fe-b3da-f27ab0d308b0","space_guid":"0bb487bb-b2fc-4122-ab4e-29dcb48227c6","gateway_data":null,"dashboard_url":"mysql://xxxxxxxxxx:xxxxxxxxxxxx@host/dbxxxxxxxxxxxxx","type":"managed_service_instance","space_url":"/v2/spaces/0bb487bb-b2fc-4122-ab4e-29dcb48227c6","service_plan_url":"/v2/service_plans/b4f382e2-5b34-41fe-b3da-f27ab0d308b0","service_bindings_url":"/v2/service_instances/051dc4e4-7c03-4324-aa42-924caca995e1/service_bindings"}}





cf curl -v  -X DELETE /v2/service_instances/051dc4e4-7c03-4324-aa42-924caca995e1


REQUEST: [2014-06-17T23:04:43-03:00]

DELETE /v2/service_instances/051dc4e4-7c03-4324-aa42-924caca995e1 HTTP/1.1

Host: api.stackato-fz7h.local

Accept: application/json

Authorization: [PRIVATE DATA HIDDEN]

Content-Type: application/json

User-Agent: go-cli 6.1.2-6a013ca / darwin




RESPONSE: [2014-06-17T23:04:44-03:00]

HTTP/1.1 500 Internal Server Error

Connection: close

Content-Length: 450

Content-Type: application/json;charset=utf-8

Date: Mon, 16 Jun 2014 07:30:41 GMT

Server: thin 1.6.1 codename Death Proof

X-Content-Type-Options: nosniff

X-Vcap-Request-Id: 9b1aec3d-5655-4f84-9713-90c475db61cf


{"code":10001,"description":"The service broker API returned an error from http://www.rcsousa.com.br/custom_mysql_broker//v2/service_instances/051dc4e4-7c03-4324-aa42-924caca995e1: 404 NOT FOUND","error_code":"CF-ServiceBrokerBadResponse","types":["ServiceBrokerBadResponse","HttpResponseError"],"http":{"uri":"http://www.rcsousa.com.br/custom_mysql_broker//v2/service_instances/051dc4e4-7c03-4324-aa42-924caca995e1","method":"DELETE","status":404}}


If I try to send a DELETE request using a Rest client, I can get a status code 200, which makes me think the broker is working fine..


Any ideas what could be the problem ? I'm using Stackato 3.2.1

Thanks in advance, 

Ricardo


Aristoteles Neto

unread,
Jun 17, 2014, 11:33:38 PM6/17/14
to vcap...@cloudfoundry.org
Judging by the error, it sounds like the broker responded with a 404 ...status:404...

Are you sure you’re returning a 200 to the DELETE request?

Aristoteles Neto



--
You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/e77cacb1-dc4e-4a78-85fe-5199d2994a5f%40cloudfoundry.org.

To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.

Noburou Taniguchi

unread,
Jun 18, 2014, 12:56:58 PM6/18/14
to vcap...@cloudfoundry.org
I have recently happened to the same issue and am about to send a pull request to fix CC.

The cause is the absence of targetted service instance or binding at service gateway, while there exists the instance or binding in CCDB.

As I wrote "service gateway", this problem only occurs with v1 services. For a v2 service (service broker), it should return "410 Gone" with a DELETE request to non-existent entry [1][2]. And a v2 service client of CC ignores the response code for DELETE requests [3].

[1] http://docs.gopivotal.com/pivotalcf/services/api.html#unbinding
[2] http://docs.gopivotal.com/pivotalcf/services/api.html#deprovisioning
[3] https://github.com/cloudfoundry/cloud_controller_ng/blob/68ef79eb6c91358436d2082cc0b5eed9654e4abc/lib/services/service_brokers/v2/client.rb#L102-L106

But there is no such code in the current v1 service client implementation. Once it happens, a user cannot delete not only the service instance or the service binding, but also related apps, space, and (even) organization. So I think a v1 service client should behave the same way as v2 client, when a DELETE request returns "404 Not found".

I think the only solution of this state (with the current CC implementation) is to delete the service instance or binding in question manually (using SQL statement, I mean) from the CCDB of your CF environment.

2014年6月18日水曜日 11時26分35秒 UTC+9 Ricardo Sousa:

Ricardo Sousa

unread,
Jun 19, 2014, 9:02:39 PM6/19/14
to vcap...@cloudfoundry.org
I guess I got to the actual problem... I'm running Stackato 3.2.1 and I managed to get a weird message from the cc log stream. cc.service_broker.v2.http_client doesn't parse the broker URI correctly :

[2014-06-19 17:55:58 -0700] cc.service_broker.v2.http_client - pid=2525  DEBUG -- Sending Delete to http://www.rcsousa.com.br/custom_mysql_broker/custom_mysql_broker/v2/service_instances/e3c21ab1-0eeb-4dde-aaeb-7158de9c8ac7?plan_id=883be36f-48bc-409f-8ffa-b47ecfcdaa6a&service_id=b3e78d12-947f-4cd4-a9d8-9616631ede57, BODY: nil, HEADERS: {"accept"=>["application/json"], "user-agent"=>["Ruby"], "authorization"=>["xxxxxxxxxxxx"], "x-vcap-request-id"=>["b88a32c6-d6dc-4035-b724-97008d0881a0"], "x-broker-api-version"=>["2.1"]}, data: {"request_guid"=>"b88a32c6-d6dc-4035-b724-97008d0881a0"}

the client is adding my controller twice. 

Ricardo

Ricardo Sousa

unread,
Jun 19, 2014, 10:25:20 PM6/19/14
to vcap...@cloudfoundry.org
A workaround to my problem was an updated on http_client.rb from :

      def delete(path, message)

        uri = uri_for(path)

        uri.query = message.to_query

        make_request(:delete, uri.request_uri, nil, nil)

      end


to:

      def delete(path, message)

        uri = uri_for(path)

        uri.query = message.to_query

        make_request(:delete, path, nil, nil)

end

Not sure if this is specific to Stackato implementation , but I also created an entry o ActiveState forum and thought it would be worthing bringing up here for the benefit of the community.

Thank you for everybody's assistance.

Ricardo

Alan Morán

unread,
Jun 20, 2014, 1:54:05 AM6/20/14
to vcap...@cloudfoundry.org
Hi ,
the only strange thing I notice in this request is those double bars. Can that be related with your problem?

- - - -
Alan Moran
 
Altoros — Cloud Foundry deployment, training and integration

http://bonzofenix.com/ 

On Jun 17, 2014, at 7:26 PM, Ricardo Sousa <ricardo...@gmail.com> wrote:

{"code":10001,"description":"The service broker API returned an error fromhttp://www.rcsousa.com.br/custom_mysql_broker//v2/service_instances/051dc4e4-7c03-4324-aa42-924caca995e1: 404 NOT FOUND","error_code":"CF-ServiceBrokerBadResponse","types":["ServiceBrokerBadResponse","HttpResponseError"],"http":{"uri":"http://www.rcsousa.com.br/custom_mysql_broker//v2/service_instances/051dc4e4-7c03-4324-aa42-924caca995e1","method":"DELETE","status":404}}

Ricardo Sousa

unread,
Jun 20, 2014, 5:37:59 AM6/20/14
to vcap...@cloudfoundry.org, alan....@altoros.com
Hey Alan, 

At first I thought that could be a problem (actually Aristoteles pointed that out)! I registered the broker with a ending slash ... But when I updated it without it the problem was still there. I guess the real problem was what I reported in my previous post. After I updated http_client.rb things worked as expected.

Thank you for your help.

Ricardo
Reply all
Reply to author
Forward
0 new messages