Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Dependencies #133

Merged
merged 4 commits into from
May 4, 2016
Merged

Simplify Dependencies #133

merged 4 commits into from
May 4, 2016

Conversation

coreyti
Copy link

@coreyti coreyti commented Apr 26, 2016

PR Overview (three changes):

  1. Packaging and installation of gem dependencies now use a custom vendor/package path. The vendor/cache path is not used, as that is a special path managed by Bundler and, when present, will include all of the gems referenced by the project, including the development gems that we want to exclude in the built release.
  2. Switches to using Bosh::Cpi::RegistryClient, so we can remove the dependency on bosh-registry, thereby also removing many transitive dependencies that are not actually need for the CPI.
  3. Removes the publication the CPI as a gem, as that is unnecessary for this library.

Notes of Interest:

  • For the time being, we need to lock the bosh_cpi dependency to a slightly older version. This is because the newest versions at this point in time were build from "hotfixes" and do not include the Bosh::Cpi::RegistryClient change. Once that change makes it to "master", and subsequent gems are published, this version lock should be removed (along with the bosh-common lock).
  • It is possible (likely?) that the version of Bundler included in the CPI release needs to be updated for these changes to work when deployed. I could not make that change as part of this PR, as I wouldn't have been able to sync the blobs without blobstore access. While this might not actually be required (all of the relevant Bundler ENV config options are found in version 1.8.2), I recommend that the version be bumped to latest: 1.11.2

Context/Details from an Earlier Conversation with Abel:

"vendor/cache" is a special/magical path that bundler (and/or rubygems) recognizes as a place to install (cache) gems. The simple presence of that directory path will make bundle install update the gems therein.

<current directory>/.bundle/config is also a special path/file where bundler will store configuration of custom options you provide for bundler commands executed.

Given the typical workflow of a developer, bundler will respect and update any provided options from/to .bundle/config, and it will add/remove gems at the vendor/cache path, simply because that path exists.

So, in order to allow the typical developer workflow to remain, we need to continue to allow all gems to be updated in that special path, and all options to be respected/updated in the configuration file.

However, because we want to have a "production" subset of gems included in the published release, we want to ignore those developer gems and developer settings.

So we:

  • A) set a custom BUNDLE_CACHE_PATH to install non-dev/-test gems to some other path
  • B) execute bundle package with BUNDLE_WITHOUT set, so we exclude dev and test gems when "packaged" to that path,
  • C) set BUNDLE_APP_CONFIG to a temporary path so we don't update the local .bundle/config settings for the developer, but rather write to a configuration file that we can subsequently throw away.

The result of all of that is that we have two caches:

  • A) vendor/cache with all of the gems needed for working on the project
  • B) vendor/package with only those gems needed for production

(the specific gem versions for the two caches are kept in sync by way of the Gemfile.lock)

So, our developers can have whatever special configuration they want or need (in .bundle/config) without affecting or being affected by the vendor_gems script. And that script packages only the gems we need for production into (the git-committed vendor/package path)

Then of course, on the BOSH release packaging side, we want to be sure we are:

  • A) in fact only including the production gems (those in vendor/package) in the built release... hence the customization of paths in the spec file
  • B) able to install the gems from our custom package/cache path... hence the matching bundler configuration in the packaging script.

Corey Innis added 4 commits April 26, 2016 11:08
- For development, continue to `bundle install` to update gem dependencies.
- For building a release, continue to `./vendor_gems` to update gem
  dependencies.

However:

- `vendor/cache` is now git-ignored, as it is not used in the packaging
  of the release. `Gemfile.lock` will continue to ensure developers
  share the same gem versions.
- The CPI spec, packaging script, and `vendor_gems` script are updated
  to package non-development gems to `vendor/package` and, subsequently,
  include only those in the packaging for the release.

Note that we specifically choose `vendor/package` as the custom gem
packaging path, because `vendor/cache` is a special path recognized by
Bundler and the simple presence of that path means that Bundler will
update gems there. This is fine for development, but we need to be more
selective for the "production" gem set.
- Updates `bosh_cpi` dependency to pull in `Bosh::Cpi::RegistryClient`,
  which was extracted from the `bosh-registry` gem.
- Removes dependency on `bosh-registry` gem, as we don't need any of the
  BOSH Registry server components, and the client was extracted.
- Updates packaged vendor gems, removing many unnecessary gems that were
  pulled in transitively through `bosh-registry`.
- Switches from `Yajl` to `JSON`, removing another system dependency.
The BOSH external CPIs do not need to be packaged as gems, so the
gemspec has been remove and all dependency definitions moved to
`Gemfile`. Rubygems updates the `LOAD_PATH` to add <project_dir>/lib`. So,
this change means that "entry points" (bin files and `spec_helper.rb`) need
to perform that modification for the CPI implementation to be found.
- This directory might still be around for developers and, if so, will
  be updated when executing `bundle install` and includes *all* gems.
  Whether or not "vendor/cache" exists no longer matters to the build of
  the CPI release. Instead...
- We use "vendor/package" for the packaging of non-development/-test
  gems.
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.

2 participants