cloudfoundry / cloudfoundry/bosh-cli

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

Open
#619 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
186
Forks
170
Avg merge
21h 48m
Merged PRs (30d)
3

Description

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")
		}
	}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at cloudStemcell.Delete and trace cloud.DeleteStemcell during CreateEnv cleanup. Inspect how the returned bicloud.Error is typed for a missing AMI. Done means an already-missing stemcell is ignored and the create-env run does not fail because of that cleanup operation.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.