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.

Requirements

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

Instructions

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'
irb(main):000:0> i.save!

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> '127.0.0.1:3000/v2/service_instances/<guid_at_tenant>?service_id=<service_gui d>&plan_id=<plan_guid>'

Example:

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"]') '127.0.0.1:3000/v2/service_instances/5e91ac75-e2b2-44d1-a68c- 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