sensu / sensu-omnibus

Build full-stack platform-specific Sensu packages
12 stars 16 forks source link

rubygems-2.7.9 breaks --source option #293

Closed russellshackleford closed 4 years ago

russellshackleford commented 5 years ago

The bump of rubygem between 1.7.0-1 and 1.7.0-2 breaks how rubygems used to work.

Scenario: We build nokogiri (among others) and host it privately as our nodes don't have compilers.

Either of these works in 1.7.0-1 (sensu-plugins-aws used as example as it pulls in nokogiri) sensu-install --plugins sensu-plugins-aws --source https://private.repo /opt/sensu/embedded/bin/gem install nokogiri --source https://private.repo

In 1.7.0-2, both fail. For manual use of gem, I can add --clear-sources before the --source https://private.repo and then additionally add --source https://rubygems.org after. However, sensu-install doesn't accept the --clear-sources option nor does it allow for multiple --source options.

russellshackleford commented 5 years ago

I am not sure where to place this diff. It changes sensu-install, but that change is only needed because of sensu-omnibus. This allows me to run sensu-install --plugins sensu-plugins-aws --clear-sources --source https://private.repo --source https://rubygems.org without failure:

--- /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-1.7.0/exe/sensu-install  2019-03-18 22:59:34.000000000 +0000
+++ sensu-install   2019-03-21 22:39:02.056970142 +0000
@@ -33,8 +33,12 @@
           opts.on("-E", "--extensions EXTENSION[,EXT]", "EXTENSION or comma-delimited list of Sensu extensions to install") do |extensions|
             options[:extensions].concat(extensions.split(","))
           end
+          opts.on("--clear-sources", "Clear the gem sources") do
+            options[:clearsources] = true
+          end
           opts.on("-s", "--source SOURCE", "Install Sensu plugins and extensions from a custom SOURCE") do |source|
-            options[:source] = source
+            options[:source] ||= []
+            options[:source] << source
           end
           opts.on("-c", "--clean", "Clean up (remove) other installed versions of the plugin(s) and/or extension(s)") do
             options[:clean] = true
@@ -73,7 +77,12 @@
         gem_command << " --version '#{gem_version}'" if gem_version
         gem_command << " --no-ri --no-rdoc"
         gem_command << " --verbose" if options[:verbose]
-        gem_command << " --source #{options[:source]}" if options[:source]
+        gem_command << " --clear-sources" if options[:clearsources]
+        if options[:source]
+          options[:source].each do |src|
+            gem_command << " --source #{src}"
+          end
+        end
         gem_command << " --http-proxy #{options[:proxy]}" if options[:proxy]
         log gem_command if options[:verbose]
         unless system(gem_command)
amdprophet commented 4 years ago

Closing as Sensu Classic is EOL. Please switch to Sensu Go.