v3 asynchronous endpoint flow - cloudfoundry/cloud_controller_ng GitHub Wiki
Using AppApplyManifest as an example:
Controller flow
(Follow along in app_manifests_controller.rb)
- hit endpoint
/apply_manifest - construct message from request values
- validations on message
- fetch models required —> the resource, app, and others (space, org)
- raise errors if the resource is not found or if user is not authorized
- initialize the action we want
- initialize the job we want with the action, message, and any other necessary parameters
- record an audit event
- enqueue the job
- this enqueues it in the
Delayed::Jobtable, possibly with a timeout, run by the worker process on the scheduler VM —> in contrast to jobs run inline/immediately, which would be run on the worker processes on the API VM
- this enqueues it in the
- build the url using the job guid and return that to the user
Action flow
(Follow along in app_apply_manifest.rb)
- load the model needed from the db -
App, in this case - apply side effects - apply all process updates and scales
- update the model -
AppUpdate.update- go into a transaction
- update the resource
- save
- record event as necessary
- apply any changes to associated models, eg.
- patch environment variables
- create service bindings if there are services on the message
- return the modified model