-
Notifications
You must be signed in to change notification settings - Fork 898
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
[WIP] [Don't merge] Make spawn pass options again #16297
[WIP] [Don't merge] Make spawn pass options again #16297
Conversation
Fixes a bug first discovered after ManageIQ#16130 was merged. That PR was subsequently reverted. We'll remove fork support once spawn has complete parity without bugs.
Don't break an interface for yet another option hash. Change the tests to not care about the order of some of the CLI arguments since awesome spawn builds them in hash insertion order and we don't really care of the order of some of them anyway.
Sometimes a provider handles multiple managers with a single worker. This change allows spawn to be passed multiple ids (or just one id) in the format 1,2,3,4 with no spaces. The queue_name is then generated from the ids to look like either ems_1 or ["ems_1", "ems_2", "ems_3"]
Lol after all that, still back where we started.
|
BOOM 🔥 Working @jrafanie
|
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.
Just some thoughts, but nothing show stopping. Seems like it should work, but I didn't test...
#lazyreview
runner_options[:ems_id] = worker_class.ems_id_from_queue_name(ENV["QUEUE"]) if worker_class.respond_to?(:ems_id_from_queue_name) | ||
if options[:ems_id] | ||
create_options[:queue_name] = options[:ems_id].length == 1 ? "ems_#{options[:ems_id].first}" : options[:ems_id].collect { |id| "ems_#{id}" } | ||
runner_options[:ems_id] = options[:ems_id].length == 1 ? options[:ems_id].first : options[:ems_id].collect { |id| id } |
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 get rid of your last commit and just turn this [:ems_id]
line into this?
runner_options[:ems_id] = worker_class.ems_id_from_queue_name(create_options[:queue_name]) if worker_class.respond_to?(:ems_id_from_queue_name)
The reason I am suggesting this is the code in ems_id_from_queue_name
should already be tested, where as this script isn't (something I would prefer, but haven't gotten around to refactoring), as well as it seems like these two lines are duplicate work.
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.
Scratch the bit about getting rid of your last commit... that was handling allowing MiqServer
spawning workers with multiple Ems ids and sending it to the script, not the other way around.
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.
Agreed with the testing!
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 really don't like any of these lines tbh.
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 did think the same thing with ems_id_from_queue_name
its what we want, as this really is just duplicating that, I feel to an extent.
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, I'd like to understand how we can move this knowledge and write tests for it. It's fine here for now. Testing by using foreman/Procfile is not easy to test all the various combinations.
def self.build_command_line(guid) | ||
command_line = "#{Gem.ruby} #{runner_script} --heartbeat --guid=#{guid} #{name}" | ||
ENV['APPLIANCE'] ? "nice #{nice_increment} #{command_line}" : command_line | ||
def self.build_command_line(guid, ems_id = 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.
Is there a reason this is a class method? I realize this was already here, just not sure why we are going from a instance method to a class method in this case.
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.
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.
@NickLaMuro Yes, but I don't believe they're good reasons. I can't recall but it's worth changing in a followup PR if it's easy. There's a few class methods that would need to also change to instance methods.
lib/workers/bin/run_single_worker.rb
Outdated
@@ -42,7 +46,6 @@ | |||
exit | |||
end | |||
opt_parser.abort(opt_parser.help) unless worker_class | |||
|
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.
WHY!!!1!?!
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.
Oh that'll be me putting in logging and when I removed it i've changed the formatting. That or Atom did it. Yeah I'll blame Atom.
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.
lolz
5b3a375
to
e0041d4
Compare
Checked commits juliancheal/manageiq@255ea34~...e0041d4 with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0 |
@@ -27,6 +27,10 @@ | |||
options[:guid] = val | |||
end | |||
|
|||
opts.on("-e=ems_id", "--ems-id=ems_id,ems_id", Array, "Provide a list of ems ids (without spaces) to a provider worker. This requires, at least one argument.") do |val| |
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.
Mr. Fancypants using Array. Someone read the optparse documentation. 😎
Nice @juliancheal
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 admit to that catching me off guard when I first read that as well.
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.
@jrafanie Hehehe, thanks!
LOL @NickLaMuro |
@juliancheal I applied your changes to the original PR #16199... We can decide which PR we want to keep tomorrow |
@jrafanie you're PR has all the good comments, mine is full of snark. Trololo |
@jrafanie
This change allows spawn to be passed multiple ids (or just one id) in the format 1,2,3,4 with no spaces.
The queue_name is then generated from the ids to look like either
ems_1
or["ems_1", "ems_2", "ems_3"]
I have tested this on the command line with:
And run MIQ Server using
MIQ_SPAWN_WORKERS=true