How to identify and clean/delete orphaned Spring Cloud Service 3.x service instances
search cancel

How to identify and clean/delete orphaned Spring Cloud Service 3.x service instances

book

Article ID: 367207

calendar_today

Updated On:

Products

VMware Tanzu Application Service

Issue/Introduction

This article covers how to verify that all backend apps for Spring Cloud Service (SCS) 3.x are valid and how to clean orphaned services.

Environment

Tanzu Application Services: Spring Cloud Service v3.x

Cause

When a Spring Cloud Services (SCS) service instance is created a backend application is also deployed. The backend application is a config-server or service-registry. They are located in org/space p-spring-cloud-services/<SERVICE_INSTANCE_GUID>

where: SERVICE_INSTANCE_GUID is the guid of the config-server or service-registry service. Retrieve by executing

  • cf service <MY_SERVICE> --guid

There are cases in which the backend application are no longer available. This document will help on cleaning up the orphaned service instance.

 

Resolution

Following are the steps to clean up orphaned SCS service instance. Note that Admin role is required.

 

1) Identify which service instance to verify using cf services command

example:

$ cf services
Getting services in org test / space test as admin...

name       service           plan       bound apps     last operation     broker                   upgrade available
myconfig   p.config-server   standard                  update succeeded   scs-service-broker

service name (MY_SERVICE) is myconfig

 

2) Retrieve the GUID of the service instance using

cf service <MY_SERVICE> --guid 

example:

$ cf service myconfig --guid
9d3cb2d1-ce6c-468a-974e-bcab45eec3d9

 

3) Target the backend org/space using

cf target -o <ORG> -s <SPACE>

example 1: Space exists

$ cf target -o p-spring-cloud-services -s 9d3cb2d1-ce6c-468a-974e-bcab45eec3d9
API endpoint:   https://api.run-35.slot-35.tanzu-gss-labs.vmware.com
API version:    3.160.0
user:           admin
org:            p-spring-cloud-services
space:          9d3cb2d1-ce6c-468a-974e-bcab45eec3d9

 

example 2: Space DO NOT exists - no backend space means this is an orphaned service instance. Jump to the clean up steps - Step #5

cf target -o p-spring-cloud-services -s 9d3cb2d1-ce6c-468a-974e-bcab45eec3d9
Space '9d3cb2d1-ce6c-468a-974e-bcab45eec3d9' not found.
FAILED

 

4) Check application using

cf apps 

example 1: Backend application exists and in started state - this is NOT an orphaned service instance. STOP no cleanup is necessary.  If having other issues, please open a support case.

$ cf apps
Getting apps in org p-spring-cloud-services / space 9d3cb2d1-ce6c-468a-974e-bcab45eec3d9 as admin...

name            requested state   processes           routes
config-server   started           web:1/1, task:0/0   config-server-9d3cb2d1-ce6c-468a-974e-bcab45eec3d9.cfapps-35.slot-35.tanzu-gss-labs.vmware.com

 

example 2: Backend application missing - no backend application means this is an orphaned service instance. Jump to the clean up steps - Step #5

$ cf apps
Getting apps in org p-spring-cloud-services / space 9d3cb2d1-ce6c-468a-974e-bcab45eec3d9 as admin...

No apps found

 

5) Clean up steps. The following steps are only executed if the backend space or backend application are missing (do not exists)

  1. For config-server, delete mirror service if present
    cf delete mirror-svc

  2. Delete backend space
    cf delete-space <SERVICE_INSTANCE_GUID>
     
    example: cf delete-space 9d3cb2d1-ce6c-468a-974e-bcab45eec3d9
  3. Target user org/space where the service instance is located
    cf target -o <USER-ORG> -s <USER-SPACE>
      example: cf target -o test -s test

  4. Purge service instance, make sure no apps are bound this is service instance. Unbind the apps if any.
    cf purge-service-instance <MY_SERVICE>
      example: cf purge-service-instance myconfig

 

This completes the cleanup of an SCS service instance.

 

Additional Information

References:

https://cli.cloudfoundry.org/es-ES/v6/purge-service-instance.html