-
Notifications
You must be signed in to change notification settings - Fork 900
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] Refactor run_single_worker find or create record #21436
base: master
Are you sure you want to change the base?
[WIP] Refactor run_single_worker find or create record #21436
Conversation
lib/workers/bin/run_single_worker.rb
Outdated
@@ -107,20 +107,14 @@ def all_role_names | |||
end | |||
|
|||
update_options = create_options.dup |
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.
NOTE I'm not sure why we're dup'ing create_options
here anymore, we used to add in pid / system_uid to update_options
but not after #21068 as far as I can tell
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 that's good point - there's no need to dup it or even have the var at all other than readability (i.e. we care about updates here vs creates)
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'm not sure why that remained. Good eye.
lib/workers/bin/run_single_worker.rb
Outdated
else | ||
worker_class.create_worker_record(create_options) | ||
end | ||
find_options = options.slice(:guid, :system_uid) |
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.
NOTE need to check if either of these ever get passed in as nil
in which case we would have to drop those
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.
Hmm, I'm concerned about this part. I'd rather get the appliance side to use system_uid and drop guid. Podified should always have a system_uid, I think. I was reluctant to change the appliance side at that time.
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 that's a great point, we can update to pass in the systemd unit name and drop GUID entirely
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.
We are now setting the system_uid for systemd workers as well as of #22915
lib/workers/bin/run_single_worker.rb
Outdated
# Podified needs to create on the first run_single_worker and update after since | ||
# the GUID can't be predetermined for each replica | ||
worker = worker_class.find_by(find_options).tap { |w| w.update(update_options) } if find_options.present? | ||
worker ||= worker_class.create_worker_record(create_options) |
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.
NOTE could we extract MiqWorker.init_worker_object
params and do a simple find_or_update
?
I don't think this is a clean refactoring, particularly if both guid and system-uid are passed (not sure that's possible). Even so, the first conditional is |
Oh yeah this definitely changes the behavior of if a GUID is passed and not found to reduce the complexity (agree with the [comment] Maybe refactor is not accurate, mor simplify/cleanup |
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation. |
This pull request has been automatically closed because it has not been updated for at least 3 months. Feel free to reopen this pull request if these changes are still valid. Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation. |
is this still valid? |
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation. |
Is there a reason this is WIP? |
Possibly due to #21436 (comment) ? I need to revisit this as it does clean this code up quite a bit. |
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the |
1 similar comment
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the |
lib/workers/bin/run_single_worker.rb
Outdated
else | ||
worker_class.create_worker_record(create_options) | ||
end | ||
find_options = options.slice(:guid, :system_uid) |
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.
find_options = options.slice(:guid, :system_uid) | |
find_options = options.slice(:guid, :system_uid).compact |
This will clear out nil
values.
I'm not sure that worrying about the user specifying 2 ids is warranted.
Can we merge after this change?
e08b0fc
to
c8f9602
Compare
Checked commits agrare/manageiq@5ee7882~...c8f9602 with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint |
This pull request is not mergeable. Please rebase and repush. |
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the |
1 similar comment
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the |
Everytime I read this method my head hurts, time to fix it