Repository navigation
Add --skip-delete-unused-stemcells flag to create-env - #744
gowrisankar22 wants to merge 1 commit into
Conversation
bosh create-env deletes the old stemcell image from the IaaS at the end of the deploy flow via DeleteUnused. Its FindUnused only sees the local *-state.json, so it treats any non-current stemcell as garbage and deletes it from the IaaS. Only the create-env director is migrated to the new stemcell during that flow; other deployments that reuse the same image (e.g. an inner director) are not rolled through and still reference the old image. Once it is deleted, any later VM recreate -- explicit or via scan-and-fix resurrection -- fails with a 404 stemcell-not-found. The CLI cannot see those other deployments, so it cannot auto-detect shared usage. This adds an operator opt-out flag that skips DeleteUnused and keeps the old image in place. Defaults to false, preserving existing behavior, and mirrors the --fix-stemcell "orphan, don't delete" pattern.
|
No actionable comments were generated in the recent review.
|
AJLfleos
left a comment
There was a problem hiding this comment.
I think this PR is a good improvement to close a gap in BOSH CLI
rkoster
left a comment
There was a problem hiding this comment.
CPI instances must own their stemcell resources independently. create-env should be able to delete a stemcell it no longer uses without affecting resources managed by a director.
The existing on-prem CPIs follow this model:
- vSphere’s
create_stemcellgenerates a freshsc-<UUID>name, imports the stemcell, and returns that name as its CID. Its datastore replicas belong to that CID’s lifecycle; separate uploads of the same stemcell receive distinct CIDs. - OpenStack’s stemcell creator creates a new image, uploads the stemcell into it, and returns the resulting image ID.
The GDC CPI breaks this isolation: CreateStemcell searches for existing images by version using a common CPI label and returns the existing image’s CID. Independent CPI instances targeting the same project can therefore acquire the same resource, while DeleteStemcell deletes it without any shared-ownership handling.
The failure described here is a consequence of that GDC CPI behavior. We should fix stemcell ownership in the GDC CPI rather than add a CLI flag to accommodate cross-instance sharing. The CLI’s local state is the appropriate scope for cleanup when CPI resource ownership is implemented correctly.
|
@rkoster GDC has a different problem which we will take a look. However, BOSH cli still has a fundamental gap: a single BOSH Director manages hundreds of deployments and if it uses create-env to manage director lifecycle, this issue can occur across everywhere. So, this is not specific to GDC; it is a general BOSH limitation that also affects SAP. default you can delete but certain cases we want to avoid this so it should be configurable and bosh cleanup command is used later to Cleanup the orphaned this case. |
Could you elaborate on the cases so we can discuss them in detail? |
|
Example from the SAP side(should be same for others too) We create the BOSH Director using create-env. The same Director manages few other deployments, such as CredHub and others. When we roll out a new stemcell, the BOSH Director deployment managed through create-env is updated first with the new stemcell. At the end of its lifecycle, create-env also cleans up the reference to the old stemcell. However, the same BOSH Director manages several other deployments that may still reference the old stemcell. This creates a problem if any of these deployments encounter an issue and require VM recreation. If the deployment has not been fully migrated to the new stemcell (for example, if the deployment failed halfway through and some VMs are still running with the old stemcell), BOSH Resurrection or a manual VM recreation will attempt to recreate those VMs using the old stemcell. Since create-env has already removed the old stemcell, the recreation will fail. This is the gap we want to address. By default, the PR will preserve the existing behavior across all infrastructures, with no changes to the current state. However, if an infrastructure needs to retain the old stemcell and prevent create-env from deleting it, this can be explicitly requested through an optional parameter. |
The distinction here is between the same stemcell name/version and the same cloud resource CID. Updating the director VM through The SAP environment described here uses the GDC CPI, whose reuse-by-version behavior we have already identified as violating that boundary. It returns an existing image’s CID across independent CPI instances, coupling resource lifecycles that must remain separate. This example is another consequence of that same GDC CPI issue, not evidence of a general BOSH limitation. Please address stemcell ownership in the GDC CPI. Adding a CLI flag to skip cleanup would work around the symptom without correcting the ownership violation. My request for changes stands. |
You are right. The GDC implementation was designed this way due to the long image import time (2.5 hours per import). Since we need to perform three imports, this adds up to 7.5 hours. Supporting multiple stemcells increases the total time even further. |
|
I close the PR as discussed #744 (comment) |
Summary
Adds an opt-out flag --skip-delete-unused-stemcells to bosh create-env so operators can prevent the CLI from deleting stemcell images that are still referenced by another deployment.
Problem
Changes