cloudfoundry-community / autosleep

Auto sleep service for CloudFoundry
Apache License 2.0
39 stars 21 forks source link

SQL syntax error when unbinding app due to app deletion #293

Closed lodener closed 6 years ago

lodener commented 6 years ago

We're making use of the MySQL for PCF v2 tile (2.2.5-build.25) service for autosleep, and whenever we delete an app that has been auto-enrolled into the autosleep service, the deletion fails due to autosleep failing on unbinding it.

The deployed autosleep version was built using the development branch (1.1.0), with the show-sql option enabled. Some relevant logging:

   2018-06-14T10:14:50.27+0000 [RTR/0] OUT autosleep.apps.domain.nl - [2018-06-14T10:14:49.842+0000] "DELETE /v2/service_instances/d1c83966-c627-4248-bf93-93de5d912466/service_bindings/61688de3-e7b4-4950-a0c5-d76e4f00d477?plan_id=autosleep-default&service_id=autosleep HTTP/1.1" 500 0 150 "-" "HTTPClient/1.0 (2.8.3, ruby 2.4.2 (2017-09-14))" "10.253.20.30:35358" "10.253.20.42:61004" x_forwarded_for:"10.253.20.30" x_forwarded_proto:"https" vcap_request_id:"b89fb917-9c04-4a71-5276-ec80da3c0288" response_time:0.4340807 app_id:"e56de999-419c-4b44-a997-cc92148e3a4c" app_index:"0" x_client_ip:"-" x_b3_traceid:"f2ae2cf6cd4fb23f" x_b3_spanid:"f2ae2cf6cd4fb23f" x_b3_parentspanid:"-"
   2018-06-14T10:14:50.27+0000 [RTR/0] OUT
   2018-06-14T10:14:50.05+0000 [APP/PROC/WEB/0] OUT DEBUG - http-nio-8080-exec-6 - o.s.w.f.CommonsRequestLoggingFilter(47) - Before request [uri=/v2/service_instances/d1c83966-c627-4248-bf93-93de5d912466/service_bindings/61688de3-e7b4-4950-a0c5-d76e4f00d477?plan_id=autosleep-default&service_id=autosleep;client=10.253.20.30;session=57569D18D1E7DA4DA0EFFB445A3511F6;user=pcf-autosleep]
   2018-06-14T10:14:50.10+0000 [APP/PROC/WEB/0] OUT  Hibernate: select binding0_.service_binding_id as service_1_1_0_, binding0_.resource_id as resource2_1_0_, binding0_.resource_type as resource3_1_0_, binding0_.service_instance_id as service_4_1_0_ from binding binding0_ where binding0_.service_binding_id=?
   2018-06-14T10:14:50.11+0000 [APP/PROC/WEB/0] OUT INFO  - http-nio-8080-exec-6 - o.c.a.u.s.s.AutosleepBindingService(146) - Unbinding app 8ec5982a-d121-4795-9b39-64c739eff58d (binding 61688de3-e7b4-4950-a0c5-d76e4f00d477)
   2018-06-14T10:14:50.12+0000 [APP/PROC/WEB/0] OUT  Hibernate: select spaceenrol0_.id as id1_4_0_, spaceenrol0_.enrollment as enrollme2_4_0_, spaceenrol0_.exclude_from_auto_enrollment as exclude_3_4_0_, spaceenrol0_.idle_duration as idle_dur4_4_0_, spaceenrol0_.ignore_route_service_error as ignore_r5_4_0_, spaceenrol0_.organization_id as organiza6_4_0_, spaceenrol0_.plan_id as plan_id7_4_0_, spaceenrol0_.secret as secret8_4_0_, spaceenrol0_.service_definition_id as service_9_4_0_, spaceenrol0_.space_id as space_i10_4_0_ from space_enroller_config spaceenrol0_ where spaceenrol0_.id=?
   2018-06-14T10:14:50.22+0000 [APP/PROC/WEB/0] OUT Hibernate: select binding0_.service_binding_id as service_1_1_, binding0_.resource_id as resource2_1_, binding0_.resource_type as resource3_1_, binding0_.service_instance_id as service_4_1_ from binding binding0_ where (binding0_.resource_id in ()) and binding0_.resource_type=?
   2018-06-14T10:14:50.23+0000 [APP/PROC/WEB/0] OUT WARN  - http-nio-8080-exec-6 - o.h.e.j.s.SqlExceptionHelper(144) - SQL Error: 1064, SQLState: 42000
   2018-06-14T10:14:50.23+0000 [APP/PROC/WEB/0] OUT  ERROR - http-nio-8080-exec-6 - o.h.e.j.s.SqlExceptionHelper(146) - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) and binding0_.resource_type=1' at line 1
   2018-06-14T10:14:50.28+0000 [APP/PROC/WEB/0] OUT  WARN  - http-nio-8080-exec-6 - o.h.e.j.s.SqlExceptionHelper(232) - SQL Warning Code: 1064, SQLState: 42000
   2018-06-14T10:14:50.28+0000 [APP/PROC/WEB/0] OUT  WARN  - http-nio-8080-exec-6 - o.h.e.j.s.SqlExceptionHelper(233) - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) and binding0_.resource_type=1' at line 1
   2018-06-14T10:14:50.28+0000 [APP/PROC/WEB/0] OUT  DEBUG - http-nio-8080-exec-6 - o.s.w.f.CommonsRequestLoggingFilter(55) - After request [uri=/v2/service_instances/d1c83966-c627-4248-bf93-93de5d912466/service_bindings/61688de3-e7b4-4950-a0c5-d76e4f00d477?plan_id=autosleep-default&service_id=autosleep;client=10.253.20.30;session=57569D18D1E7DA4DA0EFFB445A3511F6;user=pcf-autosleep]

Deletion of the app fails, manually unbinding the app from the autosleep service now also fails:

$ cf us testapp2 autosleep-panzer
Unbinding app testapp2 from service autosleep-panzer in org it4it-org / space panzer-space as admin...
Unexpected Response
Response code: 502
CC code:       0
CC error code:
Request ID:    6e22b256-4434-4898-590e-324f9abaf36a::decca753-a026-4b46-b10b-5b3137fb6f2c
Description:   {
  "description": "Service instance autosleep-panzer: Service broker error: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet",
  "error_code": "CF-ServiceBrokerBadResponse",
  "code": 10001,
  "http": {
    "uri": "https://autosleep.apps.domain.nl/v2/service_instances/d1c83966-c627-4248-bf93-93de5d912466/service_bindings/61688de3-e7b4-4950-a0c5-d76e4f00d477",
    "method": "DELETE",
    "status": 500
  }
}
gberche-orange commented 6 years ago

closed by #294