Skip to content
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

Don't allow objects into MiqQueue. #8963

Merged
merged 1 commit into from
Jul 8, 2016

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented May 25, 2016

For tests and development only, ensure no ar objects are inserted into the queue.

Currently, a Vm is being inserted into the Queue for refresh and it is very large. This puts some protective measure for developers to catch these errors early on in the development process

code to be fixed:

@kbrock
Copy link
Member Author

kbrock commented Jun 2, 2016

@Fryguy looks like this only detected that one place in code where a report is put on the queue.

It is for new records only (can't serialize the id here) - ideas how to address / if we want to address it?

@kbrock kbrock changed the title [WIP] Don't allow objects into MiqQueue. Don't allow objects into MiqQueue. Jun 15, 2016
@kbrock kbrock removed the wip label Jun 15, 2016
@kbrock
Copy link
Member Author

kbrock commented Jun 15, 2016

@Fryguy we agreed that for MiqReport, if it was a new record, let it go onto the queue.
This should now pass.

Question: Do we want this check to go into miq_queue?
If not, then lets just close.

@kbrock kbrock force-pushed the miq_queue_prevent_objects branch from edacfe7 to 747911f Compare June 15, 2016 18:04
@Fryguy
Copy link
Member

Fryguy commented Jul 1, 2016

I'm not sure about this one. On one hand I like the idea of blocking AR objects on the queue a lot. On the other hand, I'm not sure about what restrictions this might impose to using the queue.

@jrafanie @gtanzillo @chessbyte Thoughts?

@gtanzillo
Copy link
Member

@Fryguy @kbrock Seems ok to me. So if there are places where we need to existing objects on the queue we should be putting just the id or some other identifying info?

I'm a bit surprised that those were the only places you found where we're doing this. I recall it being done in a lot more places. Perhaps those have been cleaned up over the years.

@kbrock
Copy link
Member Author

kbrock commented Jul 1, 2016

@gtanzillo Yes. The object on the queue can get big, and tends to get stale. So we have been all but removed them.

@Fryguy This is development only. Does that change your mind? I'm hearing you say close w/o merge but unsure.

@jrafanie
Copy link
Member

jrafanie commented Jul 5, 2016

I agree with @gtanzillo, I'm surprised there were only 2 places that did this. I'm ok with this as we try to see if this happens elsewhere.

@@ -116,6 +116,11 @@ def self.put(options)

options[:args] = [options[:args]] if options[:args] && !options[:args].kind_of?(Array)

if !Rails.env.production? && options[:args] &&
(arg = options[:args].detect { |a| a.kind_of?(ActiveRecord::Base) && ! a.new_record? })
raise "MiqQueue.put(:args =>[]) does not support #{arg.class.name} objects"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't help people fix the code though... should we suggest you provide class and id so the resulting method can lookup the record instead of us serializing it on the queue?

@kbrock
Copy link
Member Author

kbrock commented Jul 6, 2016

@jrafanie I only had class.name in there, just added id as well. thanks

@kbrock kbrock force-pushed the miq_queue_prevent_objects branch 3 times, most recently from 216de8f to ff41dae Compare July 6, 2016 12:49
@@ -116,6 +116,11 @@ def self.put(options)

options[:args] = [options[:args]] if options[:args] && !options[:args].kind_of?(Array)

if !Rails.env.production? && options[:args] &&
(arg = options[:args].detect { |a| a.kind_of?(ActiveRecord::Base) && ! a.new_record? })
raise "MiqQueue.put(:args =>[]) does not support #{arg.class.name}[#{arg.try(:id)}] objects"
Copy link
Member

@jrafanie jrafanie Jul 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kbrock Maybe something like this:

raise "MiqQueue.put(:args =>[]) does not support #{arg.class.name} objects, try passing the object(s) class name and id as args to #{options[:class_name]} #{options[:method_name]} instead"

@kbrock kbrock force-pushed the miq_queue_prevent_objects branch from ff41dae to ac0fcc2 Compare July 6, 2016 14:20
This does not raise in production. It is there to assist developers

In a few instances, a changed (non-created) object is passed on the
queue. We may want to address this issue at a later time
@kbrock kbrock force-pushed the miq_queue_prevent_objects branch from ac0fcc2 to 8fa5c63 Compare July 6, 2016 15:56
@miq-bot
Copy link
Member

miq-bot commented Jul 6, 2016

Checked commit kbrock@8fa5c63 with ruby 2.2.4, rubocop 0.37.2, and haml-lint 0.16.1
2 files checked, 1 offense detected

app/models/miq_queue.rb

@kbrock
Copy link
Member Author

kbrock commented Jul 6, 2016

@jrafanie added method and class to alert message - now are you good?

@chessbyte chessbyte merged commit 3bc4b5f into ManageIQ:master Jul 8, 2016
@chessbyte chessbyte self-assigned this Jul 8, 2016
@chessbyte chessbyte added this to the Sprint 43 Ending July 11, 2016 milestone Jul 8, 2016
@kbrock kbrock deleted the miq_queue_prevent_objects branch July 8, 2016 20:06
@jrafanie
Copy link
Member

It's better @kbrock. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants