cloudfoundry / bosh

Cloud Foundry BOSH is an open source tool chain for release engineering, deployment and lifecycle management of large scale distributed services.
https://bosh.io
Apache License 2.0
2.03k stars 657 forks source link

Api endpoint to get deployment manifest with expanded runtime config #2532

Open gberche-orange opened 3 weeks ago

gberche-orange commented 3 weeks ago

Is your feature request related to a problem? Please describe.

As a bosh operator, in order to record a reliable current state of a bosh deployment, I need a deployment manifest with the applied runtime config. Then I archive this deployment manifest (typically in git) in order to track history of changes applied by my automation pipelines.

Currently, the runtime config may change, but the current endpoint has not yet options to render the applied runtime config. For cloud-config, it does support indicating the cloud-config within the deployment is outdated, see https://github.com/cloudfoundry/bosh/blob/69dea967cf0a45f1468d749b651fa1b84d894a73/src/bosh-director/spec/unit/api/controllers/deployments_controller_spec.rb#L1073-L1100

Describe the solution you'd like

A new param to the /deployments/<deployment> endpoint to render the deployment manifest along with the add-ons.

Describe alternatives you've considered

I looked for existing task debug traces and could not find a dumped rendered manifest.

Looking at source code, the planner below seems to perform the manifest merge but does not yet dump it https://github.com/cloudfoundry/bosh/blob/4f0656826132d4794d4e5070381717ba067f9cc4/src/bosh-director/lib/bosh/director/deployment_plan/planner_factory.rb#L50-L126 A clear and concise description of what you want to happen.

I'm also considering fetching the full manifest directly from the director db, but would need guidance into the current director db schema, as https://github.com/cloudfoundry/bosh/tree/main/docs/director_schema seems outdated

jpalermo commented 2 weeks ago

The /deployments/:deployment/diff endpoint does use runtime configs to generate the diff between the old manifest and the new manifest.

https://github.com/cloudfoundry/bosh/blob/6b40dfc6db5d4e6b1764bd05884cbc92a30ba951/src/bosh-director/lib/bosh/director/api/controllers/deployments_controller.rb#L469-L489

Seems like a lot of that code could be used to do what you want on /deployments/:deployment.

Since that endpoint currently renders the "currently deployed manifest", if you're adding an option to add runtime configs, it feels correct that the option should have a flag for "currently deployed manifest + runtime configs", but also adding a flag for "currently deployed manifest + new runtime configs" seems like a fine option too.

You might also be able to just use the diff endpoint to achieve what you want without any changes, but I'll leave that up to you.

gberche-orange commented 2 weeks ago

Thanks @jpalermo for your detailed analysis and suggestion for contribution !