Skip to content

Commit 0789366

Browse files
committed
Drop Log Collection Backend
In containerized deployments we can't support log collection, because we can't mount the log depot. In appliance deployments, we're trying to get away from the application UI having anything to do with the system it's running on to avoid the need to elevate permissions. As such, this commit removes log collection from backend. The UI will be done separately. Instead, on appliances, users can manually mount an NFS server (or really any server type - even more than our UI supports), and then use the /var/www/miq/vmdb/tools/collect_logs tool. If the user needs scheduling, they can schedule a cron on the appliance to run the tool.
1 parent 013e8cf commit 0789366

File tree

17 files changed

+2
-1436
lines changed

17 files changed

+2
-1436
lines changed

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ gem "rake", ">=12.3.3", :require => false
7575
gem "rest-client", "~>2.1.0", :require => false
7676
gem "ruby_parser", :require => false # Required for i18n string extraction, and DescentdantLoader (via prism)
7777
gem "ruby-progressbar", "~>1.7.0", :require => false
78-
gem "rubyzip", "~>2.0.0", :require => false
7978
gem "rugged", "~>1.9", :require => false
8079
gem "ruport", "~>1.8.0"
8180
gem "snmp", "~>1.2.0", :require => false

app/models/file_depot.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ class FileDepot < ApplicationRecord
55
include YamlImportExportMixin
66

77
has_many :miq_schedules, :dependent => :nullify
8-
has_many :miq_servers, :dependent => :nullify, :foreign_key => :log_file_depot_id
98
has_many :log_files
109
validates_presence_of :uri
1110

app/models/log_file.rb

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -77,54 +77,6 @@ def file_exists?
7777
klass.new(legacy_depot_hash).exist?(log_uri)
7878
end
7979

80-
# main UI method to call to request logs from a server
81-
def self.logs_from_server(*args)
82-
options = args.extract_options!
83-
userid = args[0] || "system"
84-
85-
# If no server provided, use the MiqServer receiving this request
86-
server = args[1] || MiqServer.my_server
87-
88-
# All server types who provide logs must implement the following instance methods:
89-
# - my_zone: which returns the zone in which they reside
90-
# - who_am_i: which returns a log friendly string of the server's class and id
91-
[:my_zone, :who_am_i].each { |meth| raise "#{meth} not implemented for #{server.class.name}" unless server.respond_to?(meth) }
92-
zone = server.my_zone
93-
resource = server.who_am_i
94-
95-
_log.info("Queueing the request by userid: [#{userid}] for logs from server: [#{resource}]")
96-
97-
begin
98-
# Create the task for the UI to check
99-
task = MiqTask.create(:name => "Zipped log retrieval for [#{resource}]", :userid => userid, :miq_server_id => server.id)
100-
101-
# callback only on exceptions.. ie, on errors... second level callback will set status to finished
102-
cb = {:class_name => task.class.name, :instance_id => task.id, :method_name => :queue_callback_on_exceptions, :args => ['Finished']}
103-
104-
# Queue the async fetch of the logs from the server - specifying a timeout, the zone to process this request, and a callback
105-
options = options.merge(:taskid => task.id, :klass => server.class.name, :id => server.id)
106-
107-
MiqQueue.put(
108-
:class_name => name,
109-
:method_name => "_request_logs",
110-
:args => [options],
111-
:zone => zone,
112-
:miq_callback => cb,
113-
:msg_timeout => LOG_REQUEST_TIMEOUT,
114-
:priority => MiqQueue::HIGH_PRIORITY
115-
)
116-
rescue => err
117-
task.queue_callback_on_exceptions('Finished', 'error', err.to_s, nil) if task
118-
raise
119-
else
120-
# return task id to the UI
121-
msg = "Queued the request for logs from server: [#{resource}]"
122-
task.update_status("Queued", "Ok", msg)
123-
_log.info("Task: [#{task.id}] #{msg}")
124-
task.id
125-
end
126-
end
127-
12880
def self.historical_logfile
12981
empty_logfile(true)
13082
end
@@ -139,14 +91,6 @@ def self.empty_logfile(historical)
13991
:description => "Default logfile")
14092
end
14193

142-
def self.ping_timeout
143-
::Settings.log.collection.ping_depot_timeout
144-
end
145-
146-
def self.do_ping?
147-
::Settings.log.collection.ping_depot == true
148-
end
149-
15094
def upload_log_file_ftp
15195
file_depot.upload_file(self)
15296
end
@@ -222,51 +166,4 @@ def legacy_depot_hash
222166
:password => file_depot.authentication_password,
223167
}
224168
end
225-
226-
def self._request_logs(options)
227-
taskid = options[:taskid]
228-
klass = options.delete(:klass).to_s
229-
id = options.delete(:id)
230-
231-
log_header = "Task: [#{taskid}]"
232-
233-
server = Object.const_get(klass).find(id)
234-
resource = server.who_am_i
235-
236-
# server must implement an instance method: started_on? which returns whether the server is started
237-
unless server.respond_to?(:started?)
238-
raise MiqException::Error, _("started? not implemented for %{server_name}") % {:server_name => server.class.name}
239-
end
240-
241-
unless server.started?
242-
if server.respond_to?(:name)
243-
raise MiqException::Error,
244-
_("Log request failed since [%{resource} %{server_name}] is not started") % {:resource => resource,
245-
:server_name => server.name}
246-
else
247-
raise MiqException::Error,
248-
_("Log request failed since [%{resource}] is not started") % {:resource => resource}
249-
end
250-
end
251-
252-
task = MiqTask.find(taskid)
253-
254-
msg = "Requesting logs from server: [#{resource}]"
255-
_log.info("#{log_header} #{msg}")
256-
task.update_status("Active", "Ok", msg)
257-
258-
cb = {:class_name => task.class.name, :instance_id => task.id, :method_name => :queue_callback_on_exceptions, :args => ['Finished']}
259-
unless server.respond_to?(:_post_my_logs)
260-
raise MiqException::Error,
261-
_("_post_my_logs not implemented for %{server_name}") % {:server_name => server.class.name}
262-
end
263-
options = options.merge(:callback => cb, :timeout => LOG_REQUEST_TIMEOUT)
264-
server._post_my_logs(options)
265-
266-
msg = "Requested logs from: [#{resource}]"
267-
_log.info("#{log_header} #{msg}")
268-
task.update_status("Queued", "Ok", msg)
269-
end
270-
271-
private_class_method :_request_logs
272169
end

app/models/miq_server.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ class MiqServer < ApplicationRecord
55
include ServerSmartProxy
66
include ConfigurationManagement
77
include EnvironmentManagement
8-
include LogManagement
98
include QueueManagement
109
include RoleManagement
1110
include StatusManagement
@@ -323,10 +322,6 @@ def friendly_name
323322
_("EVM Server (%{id})") % {:id => pid}
324323
end
325324

326-
def who_am_i
327-
@who_am_i ||= "#{name} #{my_zone} #{self.class.name} #{id}"
328-
end
329-
330325
def database_application_name
331326
"MIQ|#{Process.pid}|#{compressed_id}|-|#{zone.compressed_id}|Server|#{zone.name}".truncate(64)
332327
end

0 commit comments

Comments
 (0)