Fix bundler 4.x incompatibility and switchblade multi-stack deletion#1131
Open
tnikolova82 wants to merge 4 commits intomasterfrom
Open
Fix bundler 4.x incompatibility and switchblade multi-stack deletion#1131tnikolova82 wants to merge 4 commits intomasterfrom
tnikolova82 wants to merge 4 commits intomasterfrom
Conversation
Rubygems 4.0.9 ships bundler 4.x as a default gem. When UpdateRubygems() runs 'ruby setup.rb', it installs bundler 4.0.9 which overwrites the buildpack's bundler 2.x. Bundler 4.x changed 'bundle version' output format (omits 'Bundler version' prefix), breaking GetBundlerVersion(). Changes: - GetBundlerVersion() regex: handle both bundler 2.x and 4.x output formats - UpdateRubygems(): re-install manifest bundler after 'ruby setup.rb' - InstallBundler(): invert version selection to default to 2.x.x - VendorBundlePath(): only bundler 1.x uses nested path (future-proof) - InstallGems(): only bundler 1.x skips BUNDLED WITH removal (future-proof) - Tests: add bundler 2.x/4.x test cases, update UpdateRubygems test
The unconditional re-install caused the integration cache test to fail: on first deploy, the second InstallBundler() call (from UpdateRubygems) produced a 'Copy' line since libbuildpack had already cached the tarball from the initial Download, violating the cache test assertion that no Copy lines appear on first deploy. Fix: only re-install bundler when rubygems major version >= 4, since only rubygems 4.x ships bundler 4.x as a default gem. Rubygems 3.x ships bundler 2.x which doesn't overwrite the buildpack's bundler.
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.
Replace vendored switchblade patch with upstream fix from cloudfoundry/switchblade#126, released as v0.9.5.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes two issues blocking the CF integration tests with cflinuxfs4 + cflinuxfs5:
1. Bundler 4.x incompatibility (Bug 5)
Rubygems 4.0.9 ships bundler 4.x as a default gem. When
UpdateRubygems()runsruby setup.rb, it installs bundler 4.0.9 which overwrites the buildpack's bundler 2.7.2.Changes:
src/ruby/versions/ruby.go— UpdatedGetBundlerVersion()regex to handle bothBundler version X.Y.Z(bundler 2.x) andX.Y.Z (date hash)(bundler 4.x) formatssupply/supply.goUpdateRubygems()— Re-install bundler 2.x after rubygems updatewhen rubygems major version >= 4
supply/supply.goInstallBundler()— Fixed version selection: bundler 1.x uses"1.x.x"dependency, everything else uses"2.x.x"supply/supply.goVendorBundlePath()— Only bundler 1.x uses nested vendor pathsupply/supply.goInstallGems()— Bundler removal applies to bundler 2+rubygems 4.x re-install scenarios
2. Switchblade multi-stack buildpack deletion (Bug 8)
When CF has both cflinuxfs4 and cflinuxfs5 stacks deployed, multiple buildpacks share
the same name (e.g.,
ruby_buildpackfor each stack). The switchbladeInitialize()method called
cf delete-buildpack -f <name>without-s <stack>, which fails with:Changes:
vendor/.../switchblade/internal/cloudfoundry/initialize.go— Parsestackfieldfrom
/v3/buildpacksAPI response and iterate over all resources, deleting eachwith the appropriate
-s <stack>flag. Handles null-stack buildpacks by omittingthe
-sflag when stack is empty.This is a vendored fix; the upstream switchblade repo (v0.9.4) has the same bug.