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] Refactor run_single_worker find or create record #21436

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

agrare
Copy link
Member

@agrare agrare commented Sep 15, 2021

Everytime I read this method my head hurts, time to fix it

@@ -107,20 +107,14 @@ def all_role_names
end

update_options = create_options.dup
Copy link
Member Author

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

Copy link
Member

@Fryguy Fryguy Sep 15, 2021

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)

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'm not sure why that remained. Good eye.

@agrare agrare changed the title Refactor run_single_worker find or create record [WIP] Refactor run_single_worker find or create record Sep 15, 2021
else
worker_class.create_worker_record(create_options)
end
find_options = options.slice(:guid, :system_uid)
Copy link
Member Author

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

Copy link
Member

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.

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 that's a great point, we can update to pass in the systemd unit name and drop GUID entirely

Copy link
Member Author

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

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

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 ?

@miq-bot miq-bot added the wip label Sep 15, 2021
@Fryguy
Copy link
Member

Fryguy commented Sep 15, 2021

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 find_by!(:guid) (note the !) and the second is find_by(:system_uid) (note the non-!), but this changes it to find_by(:guid AND :system_uid).

@agrare
Copy link
Member Author

agrare commented Sep 15, 2021

Oh yeah this definitely changes the behavior of if a GUID is passed and not found to reduce the complexity (agree with the [comment] TODO: This is really inconsistent and confusing. Why can't GUID follow the same rules?)

Maybe refactor is not accurate, mor simplify/cleanup

@miq-bot
Copy link
Member

miq-bot commented Feb 27, 2023

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 stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s)

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation.

@miq-bot
Copy link
Member

miq-bot commented May 29, 2023

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.

@miq-bot miq-bot closed this May 29, 2023
@kbrock kbrock removed the stale label Jul 13, 2023
@kbrock
Copy link
Member

kbrock commented Jul 13, 2023

is this still valid?

@kbrock kbrock reopened this Jul 13, 2023
@miq-bot
Copy link
Member

miq-bot commented Oct 16, 2023

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 stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s)

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation.

@miq-bot miq-bot added the stale label Oct 16, 2023
@kbrock kbrock removed the stale label Oct 17, 2023
@kbrock
Copy link
Member

kbrock commented Oct 17, 2023

Is there a reason this is WIP?
LGTM

@agrare
Copy link
Member Author

agrare commented Oct 17, 2023

Possibly due to #21436 (comment) ? I need to revisit this as it does clean this code up quite a bit.

@miq-bot miq-bot added the stale label Jan 22, 2024
@miq-bot
Copy link
Member

miq-bot commented Jan 22, 2024

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 stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s).

1 similar comment
@miq-bot
Copy link
Member

miq-bot commented Apr 29, 2024

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 stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s).

else
worker_class.create_worker_record(create_options)
end
find_options = options.slice(:guid, :system_uid)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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?

@agrare agrare force-pushed the refactor_run_single_worker_find_record branch from e08b0fc to c8f9602 Compare April 30, 2024 12:18
@miq-bot
Copy link
Member

miq-bot commented Apr 30, 2024

Checked commits agrare/manageiq@5ee7882~...c8f9602 with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint
2 files checked, 0 offenses detected
Everything looks fine. 🍪

@miq-bot
Copy link
Member

miq-bot commented Jul 25, 2024

This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Nov 1, 2024

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 stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s).

1 similar comment
@miq-bot
Copy link
Member

miq-bot commented Feb 3, 2025

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 stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s).

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.

5 participants