Skip to content

Updating Ruby Package in CAPI Release

Seth Boyles edited this page Jan 8, 2021 · 25 revisions

Updating the ruby package in CAPI release will allow CAPI jobs to use an updated version of ruby.

A ruby package spec file contains metadata providing which version of ruby, rubygems, and other supportive libraries. The packaging scripts specifies un-compressing these dependencies and installing them on our instances. (Q: Where does bosh get the ruby source code from?)

Steps to update ruby package (metadata for the ruby run for capi jobs) Steps to update ruby package (metadata for the ruby run for capi jobs)

  1. Get the most up-to-date version of bosh ruby-release:
git clone https://github.com/bosh-packages/ruby-release
-or-
cd ~/workspace/ruby-release && git pull
  1. cd ~/workspace/capi-release
  2. touch config/private.yml
  3. Populate the new private.yml with the blobstore credentials found in LastPass under "Shared CF-CAPI / capi-release private.yml"
  4. Run the vendor-package command to create 2 new directories that point to the updated ruby package
bosh vendor-package ruby-2.4.6-r0.7.0 ~/workspace/ruby-release/
# creates .final_builds/packages/ruby-2.4.6-r0.9.0/ and packages/ruby-2.4.6-r0.9.0/
  1. Delete the old ruby package rm -rf packages/ruby-2.4-r5/ # or not???
  2. In capi-release/src/cloud_controller_ng/.ruby-version change 2.4.5 to 2.4.6.
  3. Go to cap-release/packages. For each instance of ruby-2.4-r5, change to ruby-2.4.6-r0.9.0
  4. Go into the capi-release/jobs directory. For each instance of ruby-2.4-r5, change to ruby-2.4.6-r0.9.0
  5. If you run git status you should see:
 2019-05-16 12:15:23 ⛅️  ruby 2.4.5p335 Alaskan in ~/workspace/capi-release
± td+cb |develop ↑1 U:1 ?:2 ✗| → git status`
On branch develop
Your branch is ahead of 'origin/develop' by 1 commit.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	deleted:    packages/ruby-OLD-VERSION/spec.lock

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   jobs/...
	modified:   packages/...
	modified:   src/cloud_controller_ng (new commits)

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	.final_builds/packages/ruby-NEW-VERSION/
	packages/ruby-NEW-VERSION/
  1. Target a bosh-lite. run deploy_only_new_capi. This creates and uploads capi-release, and does a bosh deploy.
  2. Validate that it works:
bosh ssh api
cd /var/vcap/jobs/cloud_controller_ng/bin
. ruby_version.sh
ruby -v
# Should see "ruby NEW-VERSION"

Updating the capi-ruby-units dockerfile

Without updating the capi-ruby-units Dockerfile, our pipeline might fail, as the unit tests will not have access to the new version of ruby (or possibly the correct version of Bundler).

Note that is may cause additional failures, as different linux releases may install different versions of dependencies in the following apt-get install command. In particular, look out for upgrades in MariaDB (mysql) and Postgres.

To update your Dockerfile, follow these steps:

  1. cd ~/workspace/capi-dockerfiles/capi-ruby-units
  2. Open Dockerfile. check the official ruby docker images for an appropriate base image, and replaced the existing one (e.g. replace FROM ruby:2.5-stretch with FROM ruby:2.7-buster).
  3. Update any other steps as necessary (e.g. replace RUN gem install bundler -v 1.17.3 with RUN gem install bundler -v 2.2.4)
  4. run docker build . to see if the docker image builds successfully
  5. Test the resulting dockerfile. To do so, run the image in interactive mode: docker run -it <image_name> /bin/bash
  6. clone CCNG: `git clone https://github.com/cloudfoundry/cloud_controller_ng.git'
  7. cd cloud_controller_ng
  8. start mysql: service mysql start
  9. run unit tests for MySql: DB=mysql ./bin/bundle rake spec
  10. start postgres: service postgresql start
  11. run unit tests for PostgreSql: DB=postgres ./bin/bundle rake spec

If both unit tests for mysql and postgres pass, then you may be ready to push the updated Dockerfile. However, beware that the pipeline actually runs this script: https://github.com/cloudfoundry/capi-ci/blob/d358203acbd0e5be4a5ce6ecb61e2c9115118dc2/ci/test-unit/run_cc_unit_tests. You may see failures depending on any differences from the above commands do to what this script runs.

Updating Capi-workspace

  1. Update this file: https://github.com/cloudfoundry/capi-workspace/blob/ebf062d2037b3fc788993aa49d03026bddc2e84f/install-scripts/ruby.sh#L6
Clone this wiki locally