Skip to content

Fix switchblade Initialize() multi-stack buildpack deletion#1136

Closed
tnikolova82 wants to merge 1 commit intomasterfrom
fix-switchblade-multistack-delete
Closed

Fix switchblade Initialize() multi-stack buildpack deletion#1136
tnikolova82 wants to merge 1 commit intomasterfrom
fix-switchblade-multistack-delete

Conversation

@tnikolova82
Copy link
Copy Markdown
Contributor

Summary

Fix cf delete-buildpack failure in switchblade Initialize() when multiple
buildpacks share the same name across different stacks (cflinuxfs4 + cflinuxfs5).

Problem

When CF has both cflinuxfs4 and cflinuxfs5 stacks deployed, buildpacks like
ruby_buildpack exist once per stack. The switchblade Initialize() method
called cf delete-buildpack -f <name> without -s <stack>, causing:

Multiple buildpacks named ruby_buildpack found.
Specify a stack name by using a '-s' flag and/or lifecycle using a '-l' flag.
FAILED

This broke the create-cf-infrastructure-and-execute-integration-test-for-ruby
pipeline job — all 5 retry attempts failed identically at platform.Initialize().

Fix

In the vendored switchblade/internal/cloudfoundry/initialize.go:

  • Parse the stack field from the /v3/buildpacks API response
  • Iterate over all resources (one per stack) and delete each with -s <stack>
  • Guard with if resource.Stack != "" to handle any-stack buildpacks (null stack)

This is a vendored fix — the same bug exists in upstream switchblade v0.9.4.

Testing

  • go build ./... passes
  • Docker-based switchblade tests are unaffected (different code path)
  • CF integration tests should now pass with both cflinuxfs4 and cflinuxfs5

When multiple buildpacks share the same name across different stacks
(e.g. ruby_buildpack for cflinuxfs4 and cflinuxfs5), cf delete-buildpack
requires -s <stack> to disambiguate. Without it, the command fails with:
'Multiple buildpacks named ruby_buildpack found. Specify a stack name
by using a -s flag.'

Parse the stack field from the /v3/buildpacks API response and iterate
over all resources, deleting each with the appropriate -s flag. This
fixes the CF integration test failure in Initialize() when both
cflinuxfs4 and cflinuxfs5 stacks are deployed.
@tnikolova82
Copy link
Copy Markdown
Contributor Author

Closing: the switchblade multi-stack fix has been merged upstream (cloudfoundry/switchblade#126) and released as v0.9.5. PR #1131 now includes the proper upstream dependency update instead of a vendored patch.

@tnikolova82 tnikolova82 closed this Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant