cloudfoundry / cloud_controller_ng

Cloud Foundry Cloud Controller
Apache License 2.0
191 stars 357 forks source link

Add current droplet guid in apps relationships #3860

Closed gmllt closed 1 week ago

gmllt commented 3 months ago

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 :

philippthun commented 3 months ago

[...] 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 commented 1 month ago

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

philippthun commented 3 weeks ago

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