cloudfoundry / cf-crd-explorations

Apache License 2.0
3 stars 2 forks source link

Spike: Add endpoints for getting a single Process and listing Processes for an App #61

Open tcdowney opened 3 years ago

tcdowney commented 3 years ago

Context / Background

At the end of cf push the CF CLI will list all of the Processes for an App and then fetch each individual Process to discover information about its health check, scaling properties, etc.

Desired outcomes

Implement the GET /v3/apps/:guid/processes and GET /v3/processes/:guid to discover any unknown issues around fetching Processes so that we have confidence that the CF CLI will be able to successfully push an app.

Acceptance Criteria / Scenarios

Fetching a single Process

GIVEN I have a Process CR on the cluster WHEN I make the following request

curl "https://api-shim.example.org/v3/processes/<process-guid-here>" \
  -X GET

THEN I get information about the Process back in the response that matches the existing CF API response. Example:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "guid": "6a901b7c-9417-4dc1-8189-d3234aa0ab82",
  "type": "web",
  "command": "rackup",
  "instances": 5,
  "memory_in_mb": 256,
  "disk_in_mb": 1024,
  "health_check": {
    "type": "port",
    "data": {
      "timeout": null
    }
  },
  "relationships": {
    "app": {
      "data": {
        "guid": "ccc25a0f-c8f4-4b39-9f1b-de9f328d0ee5"
      }
    },
    "revision": {
      "data": {
        "guid": "885735b5-aea4-4cf5-8e44-961af0e41920"
      }
    }
  },
  "metadata": {
    "labels": { },
    "annotations": { }
  },
  "created_at": "2016-03-23T18:48:22Z",
  "updated_at": "2016-03-23T18:48:42Z",
  "links": {
    "self": {
      "href": "https://api.example.org/v3/processes/6a901b7c-9417-4dc1-8189-d3234aa0ab82"
    },
    "scale": {
      "href": "https://api.example.org/v3/processes/6a901b7c-9417-4dc1-8189-d3234aa0ab82/actions/scale",
      "method": "POST"
    },
    "app": {
      "href": "https://api.example.org/v3/apps/ccc25a0f-c8f4-4b39-9f1b-de9f328d0ee5"
    },
    "space": {
      "href": "https://api.example.org/v3/spaces/2f35885d-0c9d-4423-83ad-fd05066f8576"
    },
    "stats": {
      "href": "https://api.example.org/v3/processes/6a901b7c-9417-4dc1-8189-d3234aa0ab82/stats"
    }
  }
}

Listing Processes for an App with Processes

GIVEN I have multiple Process CRs for different Apps WHEN I make the following request

curl "https://api.example.org/v3/apps/<app-guid-here>/processes" \
  -X GET

THEN I receive a response containing a list of processes associated with that App (and no others)

See the docs for an example response.

Listing Processes for an App with NO Processes

GIVEN I have Process CRs, but they are associated with some other App WHEN I make the following request

curl "https://api.example.org/v3/apps/<app-guid-here>/processes" \
  -X GET

THEN I receive a response containing an empty list of Processes


Notes

Add any additional notes