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

Feat: conservative plugin (dependency) updates by default #13794

Merged
merged 3 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/bootstrap/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def bundler_arguments(options = {})
arguments << "update"
arguments << expand_logstash_mixin_dependencies(options[:update])
arguments << "--local" if options[:local]
arguments << "--conservative" if options[:conservative]
elsif options[:clean]
arguments << "clean"
elsif options[:package]
Expand Down
6 changes: 4 additions & 2 deletions lib/pluginmanager/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class LogStash::PluginManager::Install < LogStash::PluginManager::Command
option "--preserve", :flag, "preserve current gem options", :default => false
option "--development", :flag, "install all development dependencies of currently installed plugins", :default => false
option "--local", :flag, "force local-only plugin installation. see bin/logstash-plugin package|unpack", :default => false
option "--[no-]conservative", :flag, "do a conservative update of plugin's dependencies", :default => true

# the install logic below support installing multiple plugins with each a version specification
# but the argument parsing does not support it for now so currently if specifying --version only
Expand Down Expand Up @@ -190,8 +191,9 @@ def update_logstash_mixin_dependencies(install_list)

if unlock_dependencies.any?
puts "Updating mixin dependencies #{unlock_dependencies.join(', ')}"
options = {:update => unlock_dependencies, :rubygems_source => gemfile.gemset.sources}
LogStash::Bundler.invoke!(options)
LogStash::Bundler.invoke! update: unlock_dependencies,
rubygems_source: gemfile.gemset.sources,
conservative: conservative?
end

unlock_dependencies
Expand Down
13 changes: 7 additions & 6 deletions lib/pluginmanager/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class LogStash::PluginManager::Update < LogStash::PluginManager::Command
parameter "[PLUGIN] ...", "Plugin name(s) to upgrade to latest version", :attribute_name => :plugins_arg
option "--[no-]verify", :flag, "verify plugin validity before installation", :default => true
option "--local", :flag, "force local-only plugin update. see bin/logstash-plugin package|unpack", :default => false
option "--[no-]conservative", :flag, "do a conservative update of plugin's dependencies", :default => true

def execute
# Turn off any jar dependencies lookup when running with `--local`
Expand Down Expand Up @@ -76,14 +77,14 @@ def update_gems!

puts("Updating #{filtered_plugins.collect(&:name).join(", ")}") unless filtered_plugins.empty?

output = nil
# any errors will be logged to $stderr by invoke!
# Bundler cannot update and clean gems in one operation so we have to call the CLI twice.
options = {:update => plugins, :rubygems_source => gemfile.gemset.sources}
options[:local] = true if local?
output=nil
# Unfreeze the bundle when updating gems
Bundler.settings.temporary({:frozen => false}) do
output = LogStash::Bundler.invoke!(options)
Bundler.settings.temporary(:frozen => false) do # Unfreeze the bundle when updating gems
output = LogStash::Bundler.invoke! update: plugins,
rubygems_source: gemfile.gemset.sources,
local: local?,
conservative: conservative?
output << LogStash::Bundler.genericize_platform unless output.nil?
end

Expand Down
9 changes: 7 additions & 2 deletions spec/unit/plugin_manager/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@

it "pass all gem sources to the bundle update command" do
sources = cmd.gemfile.gemset.sources
expect_any_instance_of(LogStash::Bundler).to receive(:invoke!).with(:update => [], :rubygems_source => sources)
expect_any_instance_of(LogStash::Bundler).to receive(:invoke!).with(
:update => [], :rubygems_source => sources,
:conservative => true, :local => false
)
cmd.execute
end

Expand All @@ -42,7 +45,9 @@
expect(cmd.gemfile).to receive(:find).with(plugin).and_return(plugin)
expect(cmd.gemfile).to receive(:save).and_return(nil)
expect(cmd).to receive(:plugins_to_update).and_return([plugin])
expect_any_instance_of(LogStash::Bundler).to receive(:invoke!).with(:update => [plugin], :rubygems_source => sources).and_return(nil)
expect_any_instance_of(LogStash::Bundler).to receive(:invoke!).with(
hash_including(:update => [plugin], :rubygems_source => sources)
).and_return(nil)
end

it "skips version verification when ask for it" do
Expand Down