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

Fix MiqServer WorkerManager Process with Non Rails workers #23117

Merged
merged 3 commits into from
Aug 16, 2024

Conversation

agrare
Copy link
Member

@agrare agrare commented Jul 30, 2024

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:

@agrare agrare force-pushed the non_rails_worker_process_starting branch from 8121895 to e31ddaa Compare July 30, 2024 15:40
@Fryguy Fryguy self-assigned this Jul 31, 2024
@agrare agrare force-pushed the non_rails_worker_process_starting branch from e31ddaa to 202f0a9 Compare July 31, 2024 17:00
@agrare agrare closed this Aug 1, 2024
@agrare agrare reopened this Aug 1, 2024
@agrare agrare force-pushed the non_rails_worker_process_starting branch 2 times, most recently from 3b7a0c9 to 851f342 Compare August 1, 2024 15:00
sync_from_system
starting = MiqWorker.find_all_starting
starting.where(:pid => miq_processes_by_pid.keys)
.reject(&:rails_worker?)
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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)

Copy link
Member Author

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.

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 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.

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 do like splitting this up into methods so let me get that in

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, PTAL

@agrare agrare force-pushed the non_rails_worker_process_starting branch 2 times, most recently from a6afab0 to c57ae5e Compare August 8, 2024 16:04
Copy link
Member

@Fryguy Fryguy left a 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.

@agrare agrare force-pushed the non_rails_worker_process_starting branch from c57ae5e to 217068b Compare August 16, 2024 14:56
@miq-bot
Copy link
Member

miq-bot commented Aug 16, 2024

Checked commits agrare/manageiq@b20a2d6~...217068b with ruby 3.1.5, rubocop 1.56.3, haml-lint 0.51.0, and yamllint
4 files checked, 0 offenses detected
Everything looks fine. 🏆

Copy link
Member

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

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

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.

@jrafanie jrafanie merged commit cffb072 into ManageIQ:master Aug 16, 2024
8 checks passed
@jrafanie jrafanie assigned jrafanie and unassigned Fryguy Aug 16, 2024
@agrare agrare deleted the non_rails_worker_process_starting branch August 16, 2024 19:56
@Fryguy
Copy link
Member

Fryguy commented Aug 22, 2024

Backported to radjabov in commit 2075352.

commit 2075352834988b549ae2697961bbda14bfab458e
Author: Joe Rafaniello <jrafanie@users.noreply.github.com>
Date:   Fri Aug 16 15:53:44 2024 -0400

    Merge pull request #23117 from agrare/non_rails_worker_process_starting
    
    Fix MiqServer WorkerManager Process with Non Rails workers
    
    (cherry picked from commit cffb072312449f4c922ca6d62755d7ecb479ab99)

Fryguy pushed a commit that referenced this pull request Aug 22, 2024
Fix MiqServer WorkerManager Process with Non Rails workers

(cherry picked from commit cffb072)
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.

4 participants