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

[WIP] [Don't merge] Make spawn pass options again #16297

Closed

Conversation

juliancheal
Copy link
Member

@juliancheal juliancheal commented Oct 24, 2017

@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:

ruby lib/workers/bin/run_single_worker.rb --ems-id 17,19,18 ManageIQ::Providers::Amazon::CloudManager::RefreshWorker

And run MIQ Server using MIQ_SPAWN_WORKERS=true

jrafanie and others added 4 commits October 24, 2017 15:28
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"]
@juliancheal juliancheal changed the title Make spawn pass options again [WIP] [Don't merge] Make spawn pass options again Oct 24, 2017
@miq-bot miq-bot added the wip label Oct 24, 2017
@juliancheal
Copy link
Member Author

juliancheal commented Oct 24, 2017

Lol after all that, still back where we started.

id  |                                type                      |  pid  |               q                |  status  | 
456 | ManageIQ::Providers::Amazon::CloudManager::RefreshWorker | 21508 | ["ems_17", "ems_18", "ems_19"] | creating |

@juliancheal
Copy link
Member Author

juliancheal commented Oct 24, 2017

BOOM 🔥 Working @jrafanie

id  |                                type                      |  pid  |               q                |  status | created
464 | ManageIQ::Providers::Amazon::CloudManager::RefreshWorker | 24319 | ["ems_17", "ems_18", "ems_19"] | started | 2017-10-24 22:01:46.12679

Copy link
Member

@NickLaMuro NickLaMuro left a 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 }
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed with the testing!

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

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)
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

¯\(ツ)@Fryguy @jrafanie

Copy link
Member

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.

@@ -42,7 +46,6 @@
exit
end
opt_parser.abort(opt_parser.help) unless worker_class

Copy link
Member

Choose a reason for hiding this comment

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

WHY!!!1!?! :rage4:

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

lolz

@miq-bot
Copy link
Member

miq-bot commented Oct 24, 2017

Checked commits juliancheal/manageiq@255ea34~...e0041d4 with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
6 files checked, 0 offenses detected
Everything looks fine. ⭐

@@ -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|
Copy link
Member

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

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jrafanie Hehehe, thanks!

@jrafanie
Copy link
Member

#lazyreview

LOL @NickLaMuro

@jrafanie
Copy link
Member

@juliancheal I applied your changes to the original PR #16199... We can decide which PR we want to keep tomorrow

@juliancheal
Copy link
Member Author

@jrafanie you're PR has all the good comments, mine is full of snark. Trololo

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

Successfully merging this pull request may close these issues.

4 participants