-
Notifications
You must be signed in to change notification settings - Fork 896
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
Fix MiqServer WorkerManager Process with Non Rails workers #23117
Fix MiqServer WorkerManager Process with Non Rails workers #23117
Conversation
8121895
to
e31ddaa
Compare
e31ddaa
to
202f0a9
Compare
3b7a0c9
to
851f342
Compare
sync_from_system | ||
starting = MiqWorker.find_all_starting | ||
starting.where(:pid => miq_processes_by_pid.keys) | ||
.reject(&:rails_worker?) |
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.
Do we have non_rails_worker?
. It might make more sense to select
those instead of rejecting the rails ones.
Is it overkill to have these methods do something like:
def sync_starting_workers
sync_from_system # get the latest from process list
sync_rails_workers # no-op, workers do this on their own
sync_non_rails_workers # move the new code here - it's an extra query but it's just as easy to update the non-rails worker rows by pid to started
MiqWorker.find_all_starting.to_a
end
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.
Do we have non_rails_worker?. It might make more sense to select those instead of rejecting the rails ones.
Ha we don't currently but I got this backwards multiple times while writing specs so I do think having a non_rails_worker? would be good.
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 it possible to do rails_worker as a query scope on MiqWorker? I'm thinking something similar concrete_subclasses where we can get a list of the possible types, then issue a .where(:type => those_subclasses)
. That way we can optimize the update to an update_all.
(Not necessary for this PR, but I can see it being more useful when chaining things later)
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 started doing this as a scope but I think that'd be better off as a separate PR, also the switch to select(&:non_rails_worker?) because we'd want to change the other classes (systemd/kubernetes) 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.
Yeah, I like the scope by worker classes (rails vs non-rails) idea but agree we should do that across the board for other classes.
I'm fine with the existing code if you want to refactor it after to do the inverse non_rails_worker?
+ extract a method. Whatever is easier to verify.
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 do like splitting this up into methods so let me get that in
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.
Done, PTAL
a6afab0
to
c57ae5e
Compare
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.
LGTM - would also like @jrafanie to give another review.
c57ae5e
to
217068b
Compare
Checked commits agrare/manageiq@b20a2d6~...217068b with ruby 3.1.5, rubocop 1.56.3, haml-lint 0.51.0, and yamllint |
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 have some very minor comments that can be addressed in a followup PR if it makes sense. LGTM
end | ||
end | ||
|
||
def sync_starting_non_rails_workers |
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.
super minor... swap the order of these methods for consistency
end | ||
|
||
def sync_stopping_rails_workers | ||
end |
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.
Again very minor... if the intent is to move the logic of setting starting/stopping from the rails workers and into here, maybe comment on how this logic is currently handled by the works so it's a no-op right now but to match systemd's logic, we might move the logic here.
Backported to
|
Fix MiqServer WorkerManager Process with Non Rails workers (cherry picked from commit cffb072)
We only added logic to set non-rails workers to started/stopped for kubernetes and systemd worker manager subclasses. This meant if you ran
rake evm:start
locally with a non-rails worker it wouldn't ever be marked as started.Also updated the systemd side to be consistent with kubernetes in not returning a worker that was just marked as started.
Depends on: