Skip to content

Commit 16a5f7e

Browse files
FryguyMelsHyrule
andcommitted
Drop Diagnostics > Collect Logs
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 the UI. 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. Replaces #8235 Co-Authored-By: Melody-Ann-Seda-Marotte <[email protected]>
1 parent 03e55ca commit 16a5f7e

31 files changed

+28
-5760
lines changed

app/controllers/application_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ def report_only
427427

428428
# moved this method here so it can be accessed from pxe_server controller as well
429429
# this is a terrible name, it doesn't validate log_depots
430+
# TODO: I think we can move this back to the pxe_server_controller and eliminate all non-pxe code paths
430431
def log_depot_validate
431432
@schedule = nil # setting to nil, since we are using same view for both db_back and log_depot edit
432433
# if zone is selected in tree replace tab#3

app/controllers/miq_ae_class_controller.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,6 @@ def set_method_form_vars
803803
else
804804
_("Editing Automate Method \"%{name}\"") % {:name => @ae_method.name}
805805
end
806-
session[:log_depot_default_verify_status] = false
807806
session[:edit] = @edit
808807
session[:changed] = @changed = false
809808
end
@@ -1024,14 +1023,11 @@ def form_method_field_changed
10241023
end
10251024
@edit[:new][:fields][f[1].to_i]['default_value'] = nil
10261025
end
1027-
if @edit[:default_verify_status] != session[:log_depot_default_verify_status]
1028-
session[:log_depot_default_verify_status] = @edit[:default_verify_status]
1029-
page << if @edit[:default_verify_status]
1030-
"miqValidateButtons('show', 'default_');"
1031-
else
1032-
"miqValidateButtons('hide', 'default_');"
1033-
end
1034-
end
1026+
page << if @edit[:default_verify_status]
1027+
"miqValidateButtons('show', 'default_');"
1028+
else
1029+
"miqValidateButtons('hide', 'default_');"
1030+
end
10351031
page << javascript_for_miq_button_visibility_changed(@changed)
10361032
page << "miqSparkle(false)"
10371033
end

app/controllers/ops_controller.rb

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,12 @@ def display_ae_namespaces
5959
end
6060

6161
OPS_X_BUTTON_ALLOWED_ACTIONS = {
62-
'collect_logs' => :logs_collect,
63-
'collect_current_logs' => :collect_current_logs,
6462
'custom_button' => :custom_buttons,
6563
'delete_server' => :delete_server,
6664
'demote_server' => :demote_server,
6765
'fetch_audit_log' => :fetch_audit_log,
6866
'fetch_log' => :fetch_log,
6967
'fetch_production_log' => :fetch_production_log,
70-
'log_depot_edit' => :log_depot_edit,
7168
'promote_server' => :promote_server,
7269
'rbac_group_add' => :rbac_group_add,
7370
'rbac_group_edit' => :rbac_group_edit,
@@ -104,11 +101,8 @@ def display_ae_namespaces
104101
'ap_host_edit' => :ap_host_edit,
105102
'ap_vm_edit' => :ap_vm_edit,
106103
'ap_copy' => :ap_copy,
107-
'zone_collect_logs' => :logs_collect,
108-
'zone_collect_current_logs' => :collect_current_logs,
109104
'zone_delete_server' => :delete_server,
110105
'zone_demote_server' => :demote_server,
111-
'zone_log_depot_edit' => :log_depot_edit,
112106
'zone_promote_server' => :promote_server,
113107
'zone_role_start' => :role_start,
114108
'zone_role_suspend' => :role_suspend,
@@ -124,11 +118,6 @@ def display_ae_namespaces
124118
'schedule_run_now' => :schedule_run_now
125119
}.freeze
126120

127-
def collect_current_logs
128-
assert_privileges("#{x_node.split('-').first == "z" ? "zone_" : ""}collect_current_logs")
129-
logs_collect(:only_current => true)
130-
end
131-
132121
# handle buttons pressed on the center buttons toolbar
133122
def x_button
134123
generic_x_button(OPS_X_BUTTON_ALLOWED_ACTIONS)
@@ -471,9 +460,6 @@ def set_form_locals
471460
locals[:submit_text] = _("Select Start date and End date to Collect C & U Data")
472461
locals[:no_reset] = true
473462
locals[:no_cancel] = true
474-
elsif @sb[:active_tab] == "diagnostics_collect_logs"
475-
action_url = "log_depot_edit"
476-
record_id = @record && @record.id ? @record.id : "new"
477463
else
478464
action_url = "old_dialogs_update"
479465
record_id = my_server.id
@@ -592,7 +578,6 @@ def replace_right_cell(options = {})
592578
tree_selected_model if @tree_selected_model.nil?
593579

594580
locals = set_form_locals if @in_a_form
595-
build_supported_depots_for_select
596581

597582
presenter = ExplorerPresenter.new(:active_tree => x_active_tree)
598583

@@ -626,9 +611,6 @@ def diagnostics_replace_right_cell(nodetype, presenter)
626611
if %w[accordion_select change_tab explorer tree_select].include?(params[:action]) ||
627612
%w[diagnostics_roles_servers diagnostics_servers_roles].include?(@sb[:active_tab])
628613
presenter.replace(:ops_tabs, r[:partial => "all_tabs"])
629-
elsif nodetype == "log_depot_edit"
630-
@right_cell_text = _("Editing Log Depot settings")
631-
presenter.update(:diagnostics_collect_logs, r[:partial => "ops/log_collection"])
632614
else
633615
presenter.update(@sb[:active_tab], r[:partial => "#{@sb[:active_tab]}_tab"])
634616
end
@@ -791,7 +773,7 @@ def handle_bottom_cell(nodetype, presenter, locals)
791773
if @pages
792774
presenter.hide(:form_buttons_div)
793775
elsif @in_a_form
794-
if ["log_depot_edit", "ze"].include?(nodetype)
776+
if ["ze"].include?(nodetype)
795777
presenter.hide(:form_buttons_div)
796778
else
797779
presenter.update(:form_buttons_div, r[:partial => "layouts/x_edit_buttons", :locals => locals])

app/controllers/ops_controller/diagnostics.rb

Lines changed: 1 addition & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -74,80 +74,6 @@ def pm_refresh_workers
7474
end
7575
alias refresh_workers pm_refresh_workers
7676

77-
def log_depot_edit
78-
assert_privileges("#{@sb[:selected_typ] == "miq_server" ? "" : "zone_"}log_depot_edit")
79-
@record = @sb[:selected_typ].classify.constantize.find(@sb[:selected_server_id])
80-
# @schedule = nil # setting to nil, since we are using same view for both db_back and log_depot edit
81-
case params[:button]
82-
when "cancel"
83-
@in_a_form = false
84-
@edit = session[:edit] = nil
85-
add_flash(_("Edit Log Depot settings was cancelled by the user"))
86-
diagnostics_set_form_vars
87-
replace_right_cell(:nodetype => x_node)
88-
when "save"
89-
if @flash_array
90-
javascript_flash(:spinner_off => true)
91-
return
92-
end
93-
94-
begin
95-
if params[:log_protocol].blank?
96-
@record.log_file_depot.try(:destroy)
97-
else
98-
new_uri = "#{params[:uri_prefix]}://#{params[:uri]}"
99-
raise _("Unsupported log depot protocol: %{protocol}") % {:protocol => params[:log_protocol]} unless FileDepot.supported_depots.key?(params[:log_protocol])
100-
101-
build_supported_depots_for_select
102-
log_protocol = params[:log_protocol]
103-
protocols = FileDepot.supported_depots.map { |k, _v| [k, k.constantize] }.to_h
104-
raise _('Invalid or unsupported file depot type.') unless protocols.key?(log_protocol)
105-
106-
depot = @record.log_file_depot.instance_of?(protocols[log_protocol]) ? @record.log_file_depot : @record.build_log_file_depot(:type => log_protocol)
107-
depot.update(:uri => new_uri, :name => params[:depot_name])
108-
creds = set_credentials
109-
depot.update_authentication(creds) if protocols[log_protocol].try(:requires_credentials?)
110-
@record.save!
111-
end
112-
rescue => bang
113-
add_flash(_("Error during 'Save': %{message}") % {:message => bang.message}, :error)
114-
@changed = true
115-
render :update do |page|
116-
page << javascript_prologue
117-
page.replace_html("diagnostics_collect_logs", :partial => "ops/log_collection")
118-
end
119-
else
120-
add_flash(_("Log Depot Settings were saved"))
121-
@edit = nil
122-
diagnostics_set_form_vars
123-
replace_right_cell(:nodetype => x_node)
124-
end
125-
when "validate"
126-
creds = set_credentials
127-
settings = {
128-
:username => creds[:default][:userid],
129-
:password => creds[:default][:password],
130-
:uri => "#{params[:uri_prefix]}://#{params[:uri]}"
131-
}
132-
133-
begin
134-
log_protocol = params[:log_protocol]
135-
protocols = FileDepot.supported_depots.map { |k, _v| [k, k.constantize] }.to_h
136-
raise _("Unsupported log depot protocol: %{protocol}") % {:protocol => log_protocol} unless protocols.key?(log_protocol)
137-
138-
protocols[log_protocol].validate_settings(settings)
139-
rescue => bang
140-
add_flash(_("Error during 'Validate': %{message}") % {:message => bang.message}, :error)
141-
else
142-
add_flash(_("Log Depot Settings were validated"))
143-
end
144-
javascript_flash(:spinner_off => true)
145-
when nil # Reset or first time in
146-
@in_a_form = true
147-
replace_right_cell(:nodetype => "log_depot_edit")
148-
end
149-
end
150-
15177
# Send the log in text format
15278
def fetch_log
15379
assert_privileges("fetch_log")
@@ -257,36 +183,6 @@ def cu_repair
257183
end
258184
end
259185

260-
def log_collection_form_fields
261-
assert_privileges("#{@sb[:selected_typ] == "miq_server" ? "" : "zone_"}log_depot_edit")
262-
@record = @sb[:selected_typ].classify.constantize.find(@sb[:selected_server_id])
263-
log_depot = @record.log_file_depot
264-
log_depot_json = log_depot ? build_log_depot_json(log_depot) : build_empty_log_depot_json
265-
render :json => log_depot_json
266-
end
267-
268-
def build_log_depot_json(log_depot)
269-
prefix, uri = log_depot[:uri].to_s.split('://')
270-
klass = @record.log_file_depot.try(:class)
271-
272-
log_depot_json = {:depot_name => log_depot[:name],
273-
:uri => uri,
274-
:uri_prefix => prefix,
275-
:log_userid => log_depot.authentication_userid,
276-
:log_protocol => klass.to_s}
277-
log_depot_json
278-
end
279-
280-
def build_empty_log_depot_json
281-
log_depot_json = {:depot_name => '',
282-
:uri => '',
283-
:uri_prefix => '',
284-
:log_userid => '',
285-
:log_password => '',
286-
:log_protocol => ''}
287-
log_depot_json
288-
end
289-
290186
def diagnostics_server_list
291187
assert_privileges("ops_diagnostics_server_view")
292188

@@ -376,31 +272,6 @@ def cu_repair_get_form_vars
376272
end
377273
end
378274

379-
# Collect the current logs from the selected zone or server
380-
def logs_collect(options = {})
381-
options[:support_case] = params[:support_case] if params[:support_case]
382-
obj, id = x_node.split("-")
383-
assert_privileges("#{obj == "z" ? "zone_" : ""}collect_logs")
384-
klass = obj == "svr" ? MiqServer : Zone
385-
instance = @selected_server = klass.find(id.to_i)
386-
if !instance.active?
387-
add_flash(_("Cannot start log collection, requires a started server"), :error)
388-
elsif instance.log_collection_active_recently?
389-
add_flash(_("Cannot start log collection, a log collection is already in progress within this scope"), :error)
390-
else
391-
begin
392-
options[:context] = klass.name
393-
instance.synchronize_logs(session[:userid], options)
394-
rescue => bang
395-
add_flash(_("Log collection error returned: %{error_message}") % {:error_message => bang.message}, :error)
396-
else
397-
add_flash(_("Log collection for %{product} %{object_type} %{name} has been initiated") % {:product => Vmdb::Appliance.PRODUCT_NAME, :object_type => klass.name, :name => instance.display_name})
398-
end
399-
end
400-
get_node_info(x_node)
401-
replace_right_cell(:nodetype => x_node)
402-
end
403-
404275
# Reload the selected node and redraw the screen via ajax
405276
def refresh_server_summary
406277
assert_privileges("refresh_server_summary")
@@ -677,7 +548,7 @@ def diagnostics_set_form_vars
677548
@sb[:selected_typ] = "miq_server"
678549
end
679550
else
680-
@sb[:active_tab] = "diagnostics_collect_logs" # setting it to show collect logs tab as first tab for the servers that are not started
551+
@sb[:active_tab] = "diagnostics_summary" # setting it to summary tab as first tab for the servers that are not started
681552
@record = @selected_server = MiqServer.find(x_node.split("-").last.to_i)
682553
@sb[:selected_server_id] = @selected_server.id
683554
@sb[:selected_typ] = "miq_server"
@@ -726,20 +597,4 @@ def diagnostics_get_info
726597
diagnostics_set_form_vars
727598
end
728599
end
729-
730-
def build_supported_depots_for_select
731-
not_supported_depots = %w[FileDepotS3 FileDepotSwift]
732-
supported_depots = FileDepot.supported_depots.reject { |model, _desc| not_supported_depots.include?(model) }
733-
@uri_prefixes = supported_depots.keys.map { |model| [model, model.constantize.uri_prefix] }.to_h
734-
@supported_depots_for_select = {'' => _('<No Depot>')}.merge(supported_depots)
735-
end
736-
737-
def set_credentials
738-
creds = {}
739-
if params[:log_userid]
740-
log_password = params[:log_password] || @record.log_file_depot.authentication_password
741-
creds[:default] = {:userid => params[:log_userid], :password => log_password}
742-
end
743-
creds
744-
end
745600
end

app/controllers/ops_controller/settings/schedules.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ def schedule_disable
267267
schedule_toggle(false)
268268
end
269269

270+
# TODO: I think we can drop this now that log collection is dropped, however, PXE needs FileDepot validation, and
271+
# I'm not sure if this method is also used by PXE validation. Note that application_controller has a log_depot_validate
272+
# as well, which might be the one used for PXE. By extension, build_uri_settings can probably also be dropped.
270273
def log_depot_validate
271274
assert_privileges("schedule_admin")
272275

app/helpers/application_helper/button/collect_logs.rb

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/helpers/application_helper/button/log_depot_edit.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.

app/helpers/application_helper/button/mixins/button_prompt_mixin.rb

Lines changed: 0 additions & 6 deletions
This file was deleted.

app/helpers/application_helper/button/zone_collect_logs.rb

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/helpers/application_helper/toolbar/diagnostics_server_center.rb

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,34 +57,6 @@ class ApplicationHelper::Toolbar::DiagnosticsServerCenter < ApplicationHelper::T
5757
:klass => ApplicationHelper::Button::DiagnosticsProductionLogs),
5858
])
5959
button_group('ldap_domain_vmdb', [
60-
select(
61-
:server_collect_logs_choice,
62-
nil,
63-
N_('Collect Logs'),
64-
N_('Collect'),
65-
:items => [
66-
button(
67-
:collect_current_logs,
68-
'fa fa-filter fa-lg',
69-
N_('Collect the current logs from the selected Server'),
70-
N_('Collect current logs'),
71-
:klass => ApplicationHelper::Button::CollectLogs
72-
),
73-
button(
74-
:collect_logs,
75-
'fa fa-filter fa-lg',
76-
N_('Collect all logs from the selected Server'),
77-
N_('Collect all logs'),
78-
:klass => ApplicationHelper::Button::CollectLogs
79-
),
80-
]
81-
),
82-
button(
83-
:log_depot_edit,
84-
'pficon pficon-edit fa-lg',
85-
N_('Edit the Log Depot settings for the selected Server'),
86-
N_('Edit'),
87-
:klass => ApplicationHelper::Button::LogDepotEdit),
8860
select(
8961
:restart_vmdb_choice,
9062
nil,

0 commit comments

Comments
 (0)