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

Make spawn pass worker options again #16199

Merged
merged 6 commits into from
Oct 25, 2017

Conversation

jrafanie
Copy link
Member

When #16130 was merged, it revealed that spawn was not properly passing worker_options, specifically, the ems id needed by provider workers.

That PR was reverted and now we need to get spawn working properly again.

This PR adds the --ems-id option to run_single_worker.rb, updates the Procfile example to leverage this instead of the QUEUE environment variable, removes support for that env variable and the now unused MIQ_GUID environment variable.

There's still some bugs to fix with spawn + BUNDLER_GROUPS excluding ui-classic for all non-ui workers but those can be done as follows up while fork is still the default (report_formatter in ui repo being used by our reporting code, ick).

We also want to support passing multiple ems id values for amazon workers cc @juliancheal @agrare but that will be done also as a followup to this PR.

To test this PR as is, you'll need to enable spawn workers locally: MIQ_SPAWN_WORKERS=true bin/rake evm:start or use the Procfile via bin/rake evm:foreman:start and make sure your provider workers get the proper ems_id passed down.

Copy link
Member

@agrare agrare left a comment

Choose a reason for hiding this comment

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

👍 tested with 2 vSphere providers and a SCVMM provider, and confirmed it doesn't work for Amazon/multiple ems_ids yet

@jrafanie
Copy link
Member Author

@agrare according to a link @juliancheal sent me here, we shouldn't need to pass multiple ems_ids to the runner initialize. It sounds like as long as you have an amazon ems with many managers, it should automatically, pickup the managers in the refresh worker.

@jrafanie
Copy link
Member Author

@agrare Or, more importantly, if we need to have multiple ems_id's passed to the runner initialize, what is the proper queue name for that worker?

@agrare
Copy link
Member

agrare commented Oct 17, 2017

@jrafanie hm well amazon workers weren't starting up so there is something else up.
@juliancheal can you help debug this?

@juliancheal
Copy link
Member

juliancheal commented Oct 17, 2017 via email

Copy link
Member

@carbonin carbonin left a comment

Choose a reason for hiding this comment

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

This looks good to me.

Just waiting on @juliancheal to give the 👍 for the amazon multi-manager stuff.

@@ -43,8 +43,6 @@ def self.interrupt_signals

def initialize(cfg = {})
@cfg = cfg
@cfg[:guid] ||= ENV['MIQ_GUID']
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -370,8 +375,12 @@ def self.runner_script
script
end

def command_line
self.class.build_command_line(worker_options)
Copy link
Member

Choose a reason for hiding this comment

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

If guid and ems_id are the only things we are using worker_options for, I think we should probably make this less opaque and pass those values explicitly.

The fact that worker_options is a hash makes it tough to see if we are covering all the cases for all the worker sub classes.

This can definitely be done in a follow up though.

@juliancheal
Copy link
Member

juliancheal commented Oct 24, 2017

I need to see what's going on, as so far with Amazon we get as far as this

 id  |                               type                        |  pid  |               q                |  status  |        
 321 | ManageIQ::Providers::Amazon::CloudManager::RefreshWorker  | 12426 | ["ems_12", "ems_13", "ems_14"] | creating |

@jrafanie jrafanie force-pushed the make_spawn_pass_options_again branch 2 times, most recently from 0539b65 to 54462a1 Compare October 24, 2017 19:30
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 Author

Choose a reason for hiding this comment

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

This one is for @carbonin 🎁

@jrafanie
Copy link
Member Author

@juliancheal I added a commit to address @carbonin's concern about YAOH (yet another options hash)

@juliancheal
Copy link
Member

Fixed the Amazon provider issue over here #16297

jrafanie and others added 6 commits October 24, 2017 22:09
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"]
@miq-bot
Copy link
Member

miq-bot commented Oct 25, 2017

Checked commits jrafanie/manageiq@26b5ac9~...1c75bc4 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.

This could probably be explained better, and formatted better.

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 }
end
Copy link
Member

@juliancheal juliancheal Oct 25, 2017

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 how I did this. The problem is, create_options[:queue_name] & runner_options[:ems_id] can accept an array when there are multiple ems ids. However when there is just a singular ems id, I don't think that works as well. So I am trying to pass a single ems id, but it just makes this look a mess.

Any suggestions to make it look nicer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's try to find a better way to do it. I can't think of one right now. Your changes are great for now. We can clean this up when we find a better place for this logic.

@gtanzillo gtanzillo added this to the Sprint 72 Ending Oct 30, 2017 milestone Oct 25, 2017
@gtanzillo gtanzillo merged commit b60ef1f into ManageIQ:master Oct 25, 2017
@Fryguy Fryguy deleted the make_spawn_pass_options_again branch October 25, 2017 16:25
jrafanie added a commit to jrafanie/manageiq that referenced this pull request Nov 25, 2019
Make systemd optional on systemd enabled systems

Api/web service worker needs ui-classic as it can try to read an existing UI session, which
can contain serialized classes from ui-classic.

Previously, we tried removing fork here: ManageIQ#16130
It was reverted here: ManageIQ#16154

Some of the followups needed to fix the original problems including passing down
ems_id to per ems workers, resolved in:
ManageIQ#16199 and
ManageIQ#18648

At this point, things should just work.
jrafanie added a commit to jrafanie/manageiq that referenced this pull request Nov 25, 2019
Make systemd optional on systemd enabled systems

Api/web service worker needs ui-classic as it can try to read an existing UI session, which
can contain serialized classes from ui-classic.

Previously, we tried removing fork here: ManageIQ#16130
It was reverted here: ManageIQ#16154

Some of the followups needed to fix the original problems including passing down
ems_id to per ems workers, resolved in:
ManageIQ#16199 and
ManageIQ#18648

At this point, things should just work.
jrafanie added a commit to jrafanie/manageiq that referenced this pull request Nov 25, 2019
Make systemd optional on systemd enabled systems

Api/web service worker needs ui-classic as it can try to read an existing UI session, which
can contain serialized classes from ui-classic.

Previously, we tried removing fork here: ManageIQ#16130
It was reverted here: ManageIQ#16154

Some of the followups needed to fix the original problems including passing down
ems_id to per ems workers, resolved in:
ManageIQ#16199 and
ManageIQ#18648

At this point, things should just work.
jrafanie added a commit to jrafanie/manageiq that referenced this pull request Nov 25, 2019
Make systemd optional on systemd enabled systems

Api/web service worker needs ui-classic as it can try to read an existing UI session, which
can contain serialized classes from ui-classic.

Previously, we tried removing fork here: ManageIQ#16130
It was reverted here: ManageIQ#16154

Some of the followups needed to fix the original problems including passing down
ems_id to per ems workers, resolved in:
ManageIQ#16199 and
ManageIQ#18648

At this point, things should just work.
jrafanie added a commit to jrafanie/manageiq that referenced this pull request Nov 25, 2019
Make systemd optional on systemd enabled systems

Api/web service worker needs ui-classic as it can try to read an existing UI session, which
can contain serialized classes from ui-classic.

Previously, we tried removing fork here: ManageIQ#16130
It was reverted here: ManageIQ#16154

Some of the followups needed to fix the original problems including passing down
ems_id to per ems workers, resolved in:
ManageIQ#16199 and
ManageIQ#18648

At this point, things should just work.
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.

7 participants