Skip to content

Commit

Permalink
Merge pull request #1135 from OpenC3/handle_upgrade_with_multiple_ins…
Browse files Browse the repository at this point in the history
…talls

Handle upgrade with multiple installed same plugins
  • Loading branch information
ryanmelt authored Mar 10, 2024
2 parents 6b9e120 + c28fd75 commit a7dd92d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
12 changes: 7 additions & 5 deletions openc3/lib/openc3/models/gem_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,15 @@ def self.install(name_or_path, scope:)
raise err
end

def self.destroy(name)
def self.destroy(name, log_and_raise_needed_errors: true)
gem_name, version = self.extract_name_and_version(name)
plugin_gem_names = PluginModel.gem_names
if plugin_gem_names.include?(name)
message = "Gem file #{name} can't be uninstalled because needed by installed plugin"
Logger.error message
raise message
if log_and_raise_needed_errors
message = "Gem file #{name} can't be uninstalled because needed by installed plugin"
Logger.error message
raise message
end
else
begin
Gem::Uninstaller.new(gem_name, {:version => version, :force => true}).uninstall
Expand All @@ -131,7 +133,7 @@ def self.destroy_all_other_versions(name)
GemModel.names.each do |gem_full_name|
gem_name, gem_version = GemModel.extract_name_and_version(gem_full_name)
if gem_name == keep_gem_name and gem_version != keep_gem_version
GemModel.destroy(gem_full_name)
GemModel.destroy(gem_full_name, log_and_raise_needed_errors: false)
end
end
end
Expand Down
12 changes: 8 additions & 4 deletions openc3/lib/openc3/utilities/process_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,15 @@ def monitor
process.status.update
end
processes_to_delete.each do |process|
Logger.info("Process #{process.status.name}:#{process.process_type}:#{process.detail} completed with state #{process.status.state}", scope: process.scope)
if process.status.state == "Warning"
Logger.warn("Process Output:\n#{process.status.output}", scope: process.scope)
message = "Process #{process.status.name}:#{process.process_type}:#{process.detail} completed with state #{process.status.state}\nProcess Output:\n#{process.status.output}"
if process.status.state != "Complete"
if process.status.state == "Warning"
Logger.warn(message, scope: process.scope)
else
Logger.error(message, scope: process.scope)
end
else
Logger.error("Process Output:\n#{process.status.output}", scope: process.scope)
Logger.info(message, scope: process.scope)
end

@processes.delete(process)
Expand Down

0 comments on commit a7dd92d

Please sign in to comment.