Skip to content

delete_stemcell is causing bosh CLI to fail when stemcell already does not exist #619

Description

@ryanmichaelsmith

This code snip is the end of a bosh create-env run where it's trying to clean up an unused stemcell. I'm not sure why it's trying to clean up a stemcell that doesn't exist, however this operation shouldn't cause the command to fail.

Deleting unused stemcell 'ami-092de32f5f076d587'... Failed (00:00:03)
Cleaning up rendered CPI jobs... Finished (00:00:00)


Deleting stemcell from cloud:
  CPI 'delete_stemcell' method responded with error: CmdError{"type":"Bosh::Clouds::CloudError","message":"could not find AMI 'ami-092de32f5f076d587'","ok_to_retry":false}
Exit code 1
===== 2023-05-10 03:43:09 UTC Finished "/usr/local/bin/bosh --no-color --non-interactive --tty create-env /var/tempest/workspaces/default/deployments/bosh.yml"; Duration: 1234s; Exit Status: 1
{"type":"step_finished","id":"bosh_product.deploying","description":"Installing BOSH"}

I believe delete_stemcell is already supposed to ignore this error, but this doesn't appear to be working as expected. At least in the context of CreateEnv.

func (s *cloudStemcell) Delete() error {
	deleteErr := s.cloud.DeleteStemcell(s.cid)
	if deleteErr != nil {
		// allow StemcellNotFoundError for idempotency
		cloudErr, ok := deleteErr.(bicloud.Error)
		if !ok || cloudErr.Type() != bicloud.StemcellNotFoundError {
			return bosherr.WrapError(deleteErr, "Deleting stemcell from cloud")
		}
	}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions