From 508ad1fa49f3ec292915c7715698526206c1faaa Mon Sep 17 00:00:00 2001 From: donoghuc Date: Wed, 25 Mar 2020 08:23:32 -0700 Subject: [PATCH] (maint) Pin concurrent-ruby, puppet 6.14 compat, bump rake This commit addresses some bit rot that has happened in ace. 1. The concurrent-ruby 1.1.6 release triggers a seg fault in MRI ruby 2.5. There is a PR to concurrent ruby https://github.com/ruby-concurrency/concurrent-ruby/pull/856 which I have verified fixes the seg fault but has not been merged/released. For now I pinned to 1.1.5 which does not have the issue. 2. The puppet 6.14.0 release included some changes that were incompatable with ace. First is the code loading for subclassing `Puppet::Configurer`. This was addressed in `ace` by simply loading all of puppet before `puppet/configurer`. The second issue is that previously puppet's logic for figuring out which server to connect to (based on SRV settings, server_list or Puppet[:ca_server] vs Puppet[:server} was spread out all over the place. Puppet switched to using a new http client in 6.14.0 So the logic for resolving which host to connect to is based on a set of resolvers. The change in behavior is that previous ace was pushing `:server` onto the context and puppet would sometimes look that value up when making a connection: https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/connection.rb#L31 3. Rake was bumped due to some CVE that did not really affect our project. --- Gemfile | 2 +- agentless-catalog-executor.gemspec | 7 +++++-- lib/ace/configurer.rb | 7 +++++++ lib/ace/puppet_util.rb | 3 +++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index e9db515..c0cb187 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ group :tests do end group :development do - gem 'bolt', git: 'https://github.com/puppetlabs/bolt', branch: 'master' + # gem 'bolt', git: 'https://github.com/puppetlabs/bolt', branch: 'master' gem 'github_changelog_generator', '~> 1.14' gem 'pry-byebug' gem 'rubocop-rspec' diff --git a/agentless-catalog-executor.gemspec b/agentless-catalog-executor.gemspec index cfc275c..ee57d87 100644 --- a/agentless-catalog-executor.gemspec +++ b/agentless-catalog-executor.gemspec @@ -20,7 +20,10 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency "bolt", "~> 1.31" + # Pin concurrent-ruby to 1.1.5 until https://github.com/ruby-concurrency/concurrent-ruby/pull/856 is released + spec.add_dependency "concurrent-ruby", "1.1.5" + # TODO: migrate to bolt 2.x + spec.add_dependency "bolt", "~> 1.31" # server-side dependencies cargo culted from https://github.com/puppetlabs/bolt/blob/4418da408643aa7eb5ed64f4c9704b941ea878dc/Gemfile#L10-L16 spec.add_dependency "hocon", ">= 1.2.5" @@ -33,7 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bundler", ">= 1.16", "< 3.0.0" spec.add_development_dependency "faraday" spec.add_development_dependency "rack-test", "~> 1.0" - spec.add_development_dependency "rake", "~> 10.0" + spec.add_development_dependency "rake", "~> 13.0" spec.add_development_dependency "rspec", "~> 3.0" spec.add_development_dependency "rubocop", "~> 0.50" end diff --git a/lib/ace/configurer.rb b/lib/ace/configurer.rb index b86aeb9..901a532 100644 --- a/lib/ace/configurer.rb +++ b/lib/ace/configurer.rb @@ -1,5 +1,12 @@ # frozen_string_literal: true +require 'puppet' +# NOTE: Changes in puppet code loading results in simply requiring `puppet/configurer` no longer +# possible. The following requires can make ruby load, however selectively loading code from puppet +# will likely lead to issues in the future. Instead, just load puppet here. +# require 'puppet/util/autoload' +# require 'puppet/parser/compiler' +# require 'puppet/parser' require 'puppet/configurer' module ACE diff --git a/lib/ace/puppet_util.rb b/lib/ace/puppet_util.rb index 55bcd60..59e3fb4 100644 --- a/lib/ace/puppet_util.rb +++ b/lib/ace/puppet_util.rb @@ -66,6 +66,9 @@ def self.isolated_puppet_settings(certname, environment, enforce_environment, en Puppet.settings[:logdir] = File.join(environment_dir, 'log') Puppet.settings[:codedir] = File.join(environment_dir, 'code') Puppet.settings[:plugindest] = File.join(environment_dir, 'plugins') + # With puppet 6.14.0 resolvers no longer set :server for pluginfact download, explicitly set them here + Puppet.settings[:server] = @ssl_settings[:server] + Puppet.settings[:masterport] = @ssl_settings[:serverport] # establish a base_context. This needs to be the first context on the stack, but must not be created # before all settings have been set. For example, this will create a Puppet::Environments::Directories