-
Notifications
You must be signed in to change notification settings - Fork 900
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
Remove queue serialization #13722
Remove queue serialization #13722
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -153,12 +153,13 @@ def scan_job_create(entity) | |||
check_policy_prevent(:request_containerimage_scan, entity, :raw_scan_job_create) | ||||
end | ||||
|
||||
def raw_scan_job_create(entity) | ||||
def raw_scan_job_create(target_class, target_id = nil) | ||||
target_class, target_id = target_class.class.name, target_class.id if target_class.kind_of?(ContainerImage) | ||||
Job.create_job( | ||||
"ManageIQ::Providers::Kubernetes::ContainerManager::Scanning::Job", | ||||
:name => "Container image analysis", | ||||
:target_class => entity.class.name, | ||||
:target_id => entity.id, | ||||
:target_class => target_class, | ||||
:target_id => target_id, | ||||
:zone => my_zone, | ||||
:miq_server_host => MiqServer.my_server.hostname, | ||||
:miq_server_guid => MiqServer.my_server.guid, | ||||
|
@@ -174,7 +175,7 @@ def check_policy_prevent(policy_event, event_target, cb_method) | |||
:class_name => self.class.to_s, | ||||
:instance_id => id, | ||||
:method_name => :check_policy_prevent_callback, | ||||
:args => [cb_method, event_target], | ||||
:args => [cb_method, event_target.class.name, event_target.id], | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at other
I like that better because one can understand There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree with @cben here. And, unlike those other poorly documented examples, you could extend your useful comment here to indicate that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cben So you are suggesting accepting any input and copying them straight to the queue? I view the purpose of methods like these to dictate and protect the messages that go onto the queue. If you are going to document what parameters are going into But I was having trouble understanding the full implications of comment from @cben - sorry if I totally botched it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good point. The ability to understand scan_job_create -> raw_scan_job_create without thinking about how check_policy_prevent() works might actually be a drawback :-|
isn't it "obvious" that a raw_scan_job_create(name, id) callback is being queued? P.S. I wish there was a way to actually prevent AR serializion, instead of constrained coding style that "dictates and protects"... I know it's a hard problem.
👍 The function is trying to be generic, but could at least take Anyway, feel free to override me. My suggestion was purely cosmetic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
would having a (dev mode?) functionality of preventing args of a type (application record?) from going in the queue work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @moolitayer Does I think I'm misreading the code before your change: cb = {
:class_name => self.class.to_s,
:instance_id => id,
:method_name => :check_policy_prevent_callback,
:args => [cb_method, event_target],
:server_guid => MiqServer.my_guid
}
def check_policy_prevent_callback(*action, _status, _message, result)
end I don't see how this callback can produce an I expected something closer to Then this PR would proceed by changing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kbrock I hope I understand your comment Turns out in ruby: def strange_example(*a,b,c)
puts "[#{a}] [#{b}] [#{c}]"
end
> strange_example(1,2,3,4)
[[1, 2]] [3] [4]
> strange_example(1,2)
[[]] [1] [2] Also I tested this code (which wasn't introduced here). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kbrock actually that wasn't the correct answer, manageiq/app/models/miq_queue.rb Line 412 in b3574a3
you wrote that line actually There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UGH - totally (to be fair, I only modified that line. but sure enough, my name is on it) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I wan't saying you should have remembered it since 2015 😄 just commenting on the coincidence ⭐ |
||||
:server_guid => MiqServer.my_guid | ||||
} | ||||
enforce_policy(event_target, policy_event, {}, { :miq_callback => cb }) unless policy_event.nil? | ||||
|
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.
thanks.
This allows us to be backward compatible and to not require a migration.