Search code examples
securitycloud-foundrysap-cloud-foundry

Cloud foundry "cf create-service" appends nonsense to "xsappname"


Trying to create a XSUAA service in the cloud fail because of already existing service. But actually no service exist there.

 -> cf create-service xsuaa application xsuaa-authentication-newsletter -c security/xs-security.json
Creating service instance xsuaa-authentication-newsletter in org CF_Dev_DP / space Customer 
as [email protected]...
Service broker error: Service broker xsuaa failed with: org.springframework.cloud.servicebroker.exception.ServiceBrokerException: Application with xsappname com-fressnapf-microservices-newsletter!t36296 already exists. To create a new service instance, ensure that the xsappname specified in your application's xs-security.json file together with the selected service plan of the UAA service broker lead to a new appid. To update an existing service instance, use the update-service command instead.
FAILED

The error states that there is a service with the name "com-fressnapf-microservices-newsletter!t36296". The contents of xs-security.json are following:

{
   "xsappname": "com-fressnapf-microservices-newsletter",
    ...
}

cf appends a weird "!t36296" at the end of the name. All of the following deletion-attempts result in a "does not exist":

-> cf delete -f 'com-fressnapf-microservices-newsletter!t36296'
App com-fressnapf-microservices-newsletter!t36296 does not exist.

-> cf delete -f 'com-fressnapf-microservices-newsletter'
App com-fressnapf-microservices-newsletter does not exist.

-> cf delete-service -f 'com-fressnapf-microservices-newsletter!t36296'
Service com-fressnapf-microservices-newsletter!t36296 does not exist.

-> cf delete-service -f 'com-fressnapf-microservices-newsletter'
Service com-fressnapf-microservices-newsletter does not exist.

-> cf delete-service -f 'xsuaa-authentication-newsletter'
Service xsuaa-authentication-newsletter does not exist.

Clearly there exist none of the apps or services, but also it could not be created because of already existing one. I could not find any similar problem on the web. I would appreciate every help or hint you could provide.


Solution

    1. This error indicates that there is a XSUAA service instance already created with the same name. However it could be in a different cloud foundry space / org / subaccount, which you don't have access to. Thus you can not view that instance, neither you can delete it.
    2. I would recommend you to add a prefix / suffix to xsappname, which will make it unique. As an example, you can use a prefix of org-space- so that your xsappname looks like this - org-space-com-fressnapf-microservices-newsletter. You can try some other prefix / suffix as well, just make sure that they make the xsappname unique.
    3. The weird thing appended to the xsappname, let's call it suffix, can be broken down into three components. First component - ! is just a delimiter added by XSUAA to get the suffix from xsappname. Secod component - t is an identifier of service plan, in your case it is tenant service plan (You may have b for broker etc.). Third and the last component - 36296 is just a running index added by XSUAA. Overall this suffix is added by XSUAA and utilized by XSUAA for some internal purposes. You can safely ignore it.