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

Remove return value sync_workers/sync_starting_workers #22942

Merged
merged 4 commits into from
Mar 15, 2024

Conversation

agrare
Copy link
Member

@agrare agrare commented Mar 13, 2024

These return values don't appear to be used anywhere and make the code slightly more complicated.

Related to: #22941

@agrare agrare force-pushed the remove_return_value_sync_workers branch from d0970fc to 5e1d97d Compare March 15, 2024 13:21
@Fryguy
Copy link
Member

Fryguy commented Mar 15, 2024

These return values don't appear to be used anywhere and make the code slightly more complicated.

I thought these were used for logging purposes somewhere (maybe not the starting_workers, but the sync_workers results. I recall logging with something showing the current and desired and then which ones it's starting and which ones it's taking down to get to the desired state.

EDIT: I might be thinking of this:

_log.info("Workers are being synchronized: Current: #{current.inspect}, Desired: #{desired.inspect}")
dups = current.uniq.find_all { |u| current.find_all { |c| c == u }.length > 1 }
_log.info("Duplicate workers found: Current: #{current.inspect}, Desired: #{desired.inspect}, Dups: #{dups.inspect}") unless dups.empty?
current -= dups

Comment on lines 40 to 41
result = klass.sync_workers
result[:adds].each { |pid| worker_add(pid) unless pid.nil? }
Copy link
Member

Choose a reason for hiding this comment

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

Naming it result is confusing, since we aren't actually returning it anymore. Think this is clearer to read:

Suggested change
result = klass.sync_workers
result[:adds].each { |pid| worker_add(pid) unless pid.nil? }
workers = klass.sync_workers
workers[:adds].each { |pid| worker_add(pid) unless pid.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.

There's an instance-var and attr_reader named workers so I think a local var named the same is also confusing

Copy link
Member

Choose a reason for hiding this comment

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

Oh ok, but I still think result is confusing... w or synced_workers could also work... Naming is hard 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay will go with synced_workers then

@agrare
Copy link
Member Author

agrare commented Mar 15, 2024

@Fryguy
Copy link
Member

Fryguy commented Mar 15, 2024

Haha yeah I just edited my last comment 😅

I thought that was higher up for some reason.

@miq-bot
Copy link
Member

miq-bot commented Mar 15, 2024

Checked commits agrare/manageiq@49ffc18~...a5c4698 with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint
6 files checked, 0 offenses detected
Everything looks fine. 🍪

@Fryguy Fryguy merged commit bcf46ae into ManageIQ:master Mar 15, 2024
8 checks passed
@Fryguy Fryguy self-assigned this Mar 15, 2024
@agrare agrare deleted the remove_return_value_sync_workers branch March 15, 2024 17:29
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.

3 participants