-
Notifications
You must be signed in to change notification settings - Fork 74
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
Add logging to RequestLog model #516
Conversation
5e44217
to
0094f34
Compare
0094f34
to
bada475
Compare
59fe421
to
216592a
Compare
7df1a0d
to
b2b5248
Compare
cabe711
to
dce93fd
Compare
Discussed with @DavidResende0 and we are skipping the bot suggestion because the current code stays consistent with the other trivial accessors in the file. |
lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_builtin_method.rb
Outdated
Show resolved
Hide resolved
lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_method.rb
Outdated
Show resolved
Hide resolved
@@ -218,10 +233,14 @@ def self.run_method(cmd) | |||
yield stdin if block_given? | |||
stdin.close | |||
threads << Thread.new do | |||
stdout.each_line { |msg| $miq_ae_logger.info("Method STDOUT: #{msg.strip}") } | |||
stdout.each_line do |msg| | |||
$request_log.request_info("Method STDOUT: #{msg.strip}", {:resource_id => miq_request_id}, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm - this didn't come out the way I'd expect and I think I led you down the wrong path.
I think maybe instead of RequestLogger, we should have modified the AutomateLogger to accept a request_id. Then the AutomateLogger would additionally write to the Request table (or a simpler RequestLogger).
lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb
Show resolved
Hide resolved
d657a69
to
04a905b
Compare
@@ -78,7 +78,6 @@ def self.deliver(*args) | |||
begin | |||
miq_task&.state_active | |||
object_name = "#{options[:object_type]}.#{options[:object_id]}" | |||
_log.info("Delivering #{ManageIQ::Password.sanitize_string(options[:attrs].inspect)} for object [#{object_name}] with state [#{state}] to Automate") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this one - I'm concerned it's going to be logged too late if we do it after resolve_automation_object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We my want to keep this line as "Attempting to Deliver". Then later between the create_automation_object and resolve_automation_object, we can try to get the request_id from the uri.
@DavidResende0 I updated a bunch of stuff here - Going to look at the core changes and regular Too tired tonight though 😴 |
message = progname | ||
progname = @progname | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish that was extracted in upstream Ruby - I'm considering pull this out into a private method upstream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, what they're probably going to suggest is to create a different LogDevice and Formatter. I might consider that.
@DavidResende0 I'm seeing some issues locally caused by #519, but those are unrelated. Hoping to get that merged first, then I can rebase this. |
b2bff93
to
8442a27
Compare
8442a27
to
1c5e577
Compare
a35639a
to
5122734
Compare
8bc8222
to
f76cf72
Compare
Co-Authored-By: DavidResende0 <david.resende@ibm.com> Co-Authored-By: Jason Frey <fryguy9@gmail.com>
Checked commit DavidResende0@f28f0a2 with ruby 2.6.10, rubocop 1.28.2, haml-lint 0.35.0, and yamllint lib/manageiq/automation_engine/logger.rb
lib/miq_automation_engine/engine/miq_ae_engine.rb
spec/miq_ae_service_spec.rb
|
miq_request_id = nil | ||
if args['MiqRequest::miq_request'] | ||
miq_request_id = args['MiqRequest::miq_request'] | ||
elsif args['vmdb_object_type'].to_s.include?("task") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you verify the vmdb_object_type is lowercase all the time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah just checked and can confirm that vmdb_object_type
is always lowercase. It always looks something like vm_retire_task
, vm_retire_request
, or vm
elsif !defined?(root.attributes[root.attributes['vmdb_object_type']].object.miq_request_id).nil? | ||
root.attributes[root.attributes['vmdb_object_type']].object.miq_request_id | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a rescue here so at the very worst, we log something without a resource_id. We probably don't want to blow up automation when trying to cut a record and log it.
@@ -270,6 +270,19 @@ def respond_to_missing?(method_name, include_private = false) | |||
super | |||
end | |||
|
|||
def self.find_miq_request_id(object) | |||
if !defined?(object.type).nil? | |||
if object.type.to_s.match?("RequestEvent") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use include? here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, let's tackle any changes in a followup.
(the defensive rescue on failing to extract the resource_id comes to mind)
Parent Issue: ManageIQ/manageiq#21188
Continuation of: #503