cloud_controller_ng icon indicating copy to clipboard operation
cloud_controller_ng copied to clipboard

Add current droplet guid in apps relationships

Open gmllt opened this issue 1 year ago • 1 comments

Issue

There is no way to bundle current droplets and applications using /v3/apps and /v3/droplets.

Context

The only way to retrieve the current droplet of an application via the API is to go through the /v3/apps/:app_guid/droplets/current or /v3/apps/:app_guid/relationships/current_droplet endpoints.

In a context where we want to retrieve all the applications (more than 3000 in my case) and their current droplet, it is therefore necessary to make one request per application (more than 3000 requests).

Possible Fix

Add relationship information with a current droplet in API responses displaying apps.

{
...,
  "relationships": {
    "current_droplet": {
      "data": {
        "guid": "<droplet-guid>"
      }
    }
  },
...
}

This can be added quickly by making the droplet_guid field of the apps table visible via the API, but this field is not updated when the current droplet is deleted and at this point, I don't know how to handle this correctly in the DeleteActionJob.

Example :

  • I push a new application
  • I delete the droplet
  • The droplet_guid field in the database is still here, even if the droplet no longer exists.

gmllt avatar Jun 25 '24 09:06 gmllt

[...] this field is not updated when the current droplet is deleted [...]

The question is, if it should be allowed to delete the current droplet at all?

@stephanme @Gerg @sethboyles - I think it might make sense to add a check to DELETE /v3/droplets/:guid that prevents the deletion of the "current droplet". What do you think?

philippthun avatar Jun 28 '24 08:06 philippthun

I've created a PR (#3926) that clears the droplet_guid of an app when the corresponding droplet gets deleted.

philippthun avatar Aug 09 '24 10:08 philippthun

I've created a PR (#3960) that prevents the deletion of the current app droplet.

philippthun avatar Sep 09 '24 15:09 philippthun