Cleanup Purged Service Instances

I some situations it might be necessary to purge a service instance from Cloud Foundry (cf purge-service-instance <guid>). This manual will guide you through manual cleanup.


GUID of the a9s Data Service instance (this guide uses 5e91ac75-e2b2-44d1-a68c-4043527023fc as an example)


On the respective a9s Service Broker VM, get details about the a9s Data Service instance:

$ sudo -i
# /var/vcap/jobs/anynines-service-broker/bin/rails_c
irb(main):001:0> i=Anynines::Instance.find_by(guid_at_tenant: '5e91ac75-e2b2- 44d1-a68c-4043527023fc')
irb(main):002:0> i.state
=> "provisioned"
irb(main):003:0> i.plan.service.guid
=> "a2251d58-c8b0-4da2-bbd3-a4319e88b1e7"
irb(main):004:0> i.plan.guid
=> "d4f3dbb8-83f1-4027-b604-519ce75b71a9"

Optional: If above i.state is unprovisioned or if the a9s Deployer doesn't know the instance, set the deployment_strategy to none to prevent the a9s Service Broker from talking to the a9s Deployer. It will then talk to BOSH directly.

irb(main):000:0> i.deployment_strategy='none'

Recommendation: Leave the Interactive Ruby (IRB) shell open and connect to the a9s Service Broker with a second session! With the a9s Service Broker credentials at hand (can be found on the a9s Service Broker VM in /var/vcap/jobs/anynines-service-broker/config/config.yml, e.g.:

/var/vcap/jobs/anynines-service-broker/packages/ruby/bin/ruby -r yaml -e 'puts YAML.load_file("/var/vcap/jobs/anynines-service-broker/config/config.yml")["production"]["authentication"]["password"]')

Then call the delete endpoint on the a9s Service Broker, filling out the details:

curl -X DELETE --user admin:<broker_password> '<guid_at_tenant>?service_id=<service_gui d>&plan_id=<plan_guid>'


curl -X DELETE --user admin:$(/var/vcap/jobs/anynines-service- broker/packages/ruby/bin/ruby -r yaml -e 'puts YAML.load_file("/var/vcap/jobs/anynines-service- broker/config/config.yml")["production"]["authentication"]["password"]') ' 4043527023fc?service_id=a2251d58-c8b0-4da2-bbd3- a4319e88b1e7&plan_id=d4f3dbb8-83f1-4027-b604-519ce75b71a9'

You can see the state by just updating the instance reference and getting the state in the IRB:

irb(main):005:0> i=Anynines::Instance.find_by(guid_at_tenant: '5e91ac75-e2b2- 44d1-a68c-4043527023fc')
irb(main):006:0> i.state